Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/typecheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: TypeCheck
on: [pull_request, push]

jobs:
typecheck:
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Install dependencies
run: npm install

- name: Run TypeScript check
run: npx tsc
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ hs_err_*.log
replay_*.log
*.hprof
*.jfr

# node

node_modules/
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"devDependencies": {
"typescript": "^5.7.2"
}
}
16 changes: 9 additions & 7 deletions src/client/resources/web/js/message_parsing.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ function escapeHtml(unsafe) {
return '';
}
return unsafe
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;')
.replace(/`/g, '&#x60;')
.replace(/\\/g, '&#x5c;');
.replaceAll('&', '&amp;')
.replaceAll('<', '&lt;')
.replaceAll('>', '&gt;')
.replaceAll('"', '&quot;')
.replaceAll("'", '&#039;')
.replaceAll('`', '&#x60;')
.replaceAll('\\', '&#x5c;');
}

// Imitates Minecraft's obfuscated text.
Expand Down Expand Up @@ -132,6 +132,8 @@ export function initializeObfuscation() {

for (let i = 0; i < elementsToProcess; i++) {
const element = elements[i];
if (!element) continue;

const length = element.textContent ? element.textContent.length : 0;
let result = '';

Expand Down
1 change: 1 addition & 0 deletions src/client/resources/web/js/translations.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
'use strict';

// https://github.com/PrismarineJS/minecraft-data 1.21.1
/** @type {Record<string, string>} */
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeps TypeScript from being overly strict with indexing this hash map.

export const translations = {
"accessibility.onboarding.accessibility.button": "Accessibility Settings...",
"accessibility.onboarding.screen.narrator": "Press enter to enable the narrator",
Expand Down
44 changes: 44 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"compilerOptions": {
"lib": ["dom", "ES2021"],

// JavaScript Support
"allowJs": true,
"checkJs": true,
"noEmit": true,

// Module Settings
"module": "ES2020",
"moduleResolution": "node",
"target": "ES2021",

// Strictness
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"useUnknownInCatchVariables": true,
"alwaysStrict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,

// Additional Safety
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true,
"verbatimModuleSyntax": true,
"isolatedModules": true
},
"include": [
"src/client/resources/web/js/**/*.js",
"src/client/resources/web/js/**/*.mjs"
],
"exclude": [
"node_modules"
]
}