From 43b634b7c14406c64ce8279d2cdd9a9a777f0b16 Mon Sep 17 00:00:00 2001 From: Popie <86546258+Popie52@users.noreply.github.com> Date: Sat, 6 Dec 2025 12:18:03 +0530 Subject: [PATCH 1/3] refactor: migrate to Node16 module resolution and ESLint flat config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated TypeScript and ESLint setup to remove deprecated configuration fields. - Migrated from `moduleResolution: "node"` → `moduleResolution: "node16"`. - Set `module: "node16"` to satisfy TS 5+ validation rules. - Replaced deprecated `tseslint.config()` usage with the recommended flat config export. - Modernized ESLint parser options and config structure. - Ensures compatibility with latest TypeScript, ESLint, and typescript-eslint releases. This improves maintainability, resolves deprecation warnings, and aligns the repository with current ecosystem standards. --- src/content/9/en/part9b.md | 106 ++++++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 43 deletions(-) diff --git a/src/content/9/en/part9b.md b/src/content/9/en/part9b.md index ad95b4e357..f3982dc96c 100644 --- a/src/content/9/en/part9b.md +++ b/src/content/9/en/part9b.md @@ -733,7 +733,7 @@ This is because we banned unused parameters in our *tsconfig.json*: "noFallthroughCasesInSwitch": true, "noImplicitAny": true, "esModuleInterop": true, - "moduleResolution": "node" + "moduleResolution": "node16" } } ``` @@ -907,22 +907,32 @@ We will configure ESlint to [disallow explicit any](https://github.com/typescrip import eslint from '@eslint/js'; import tseslint from 'typescript-eslint'; -export default tseslint.config({ - files: ['**/*.ts'], - extends: [ - eslint.configs.recommended, - ...tseslint.configs.recommendedTypeChecked, - ], - languageOptions: { - parserOptions: { - project: true, - tsconfigRootDir: import.meta.dirname, - }, +export default [ + { + ignores: ["dist/**", "build/**", "eslint.config.*", "**/*.js", "**/*.mjs"], }, - rules: { - '@typescript-eslint/no-explicit-any': 'error', + { + files: ["**/*.ts"], }, -}); + + // Base ESLint recommended rules + eslint.configs.recommended, + + // TypeScript ESLint rules (type-aware) + ...tseslint.configs.recommendedTypeChecked, + + { + languageOptions: { + parserOptions: { + project: true, // looks for tsconfig.json automatically + tsconfigRootDir: import.meta.dirname, + }, + }, + rules: { + "@typescript-eslint/no-explicit-any": "error", + }, + }, +]; ``` Let us also set up a *lint* npm script to inspect the files by modifying the *package.json* file: @@ -955,39 +965,49 @@ npm install --save-dev @stylistic/eslint-plugin Our final *eslint.config.mjs* looks as follows: ```js -import eslint from '@eslint/js'; -import tseslint from 'typescript-eslint'; +import eslint from "@eslint/js"; +import tseslint from "typescript-eslint"; import stylistic from "@stylistic/eslint-plugin"; -export default tseslint.config({ - files: ['**/*.ts'], - extends: [ - eslint.configs.recommended, - ...tseslint.configs.recommendedTypeChecked, - ], - languageOptions: { - parserOptions: { - project: true, - tsconfigRootDir: import.meta.dirname, - }, +export default [ + { + ignores: ["dist/**", "build/**", "eslint.config.*", "**/*.js", "**/*.mjs"], }, - plugins: { - "@stylistic": stylistic, + { + files: ["**/*.ts"], }, - rules: { - '@stylistic/semi': 'error', - '@typescript-eslint/no-unsafe-assignment': 'error', - '@typescript-eslint/no-explicit-any': 'error', - '@typescript-eslint/explicit-function-return-type': 'off', - '@typescript-eslint/explicit-module-boundary-types': 'off', - '@typescript-eslint/restrict-template-expressions': 'off', - '@typescript-eslint/restrict-plus-operands': 'off', - '@typescript-eslint/no-unused-vars': [ - 'error', - { 'argsIgnorePattern': '^_' } - ], + + // Base ESLint recommended rules + eslint.configs.recommended, + + // TypeScript ESLint rules (type-aware) + ...tseslint.configs.recommendedTypeChecked, + + { + languageOptions: { + parserOptions: { + project: true, // looks for tsconfig.json automatically + tsconfigRootDir: import.meta.dirname, + }, + }, + plugins: { + "@stylistic": stylistic, + }, + rules: { + "@stylistic/semi": "error", + // "@typescript-eslint/no-unsafe-assignment": "error", + // "@typescript-eslint/no-explicit-any": "error", + "@typescript-eslint/explicit-function-return-type": "off", + "@typescript-eslint/explicit-module-boundary-types": "off", + "@typescript-eslint/restrict-template-expressions": "off", + "@typescript-eslint/restrict-plus-operands": "off", + "@typescript-eslint/no-unused-vars": [ + "error", + { argsIgnorePattern: "^_" }, + ], + }, }, -}); +]; ``` Quite a few semicolons are missing, but those are easy to add. We also have to solve the ESlint issues concerning the *any* type: From 7e9f001bb97cbe351ca215e1c045357ff0e1951a Mon Sep 17 00:00:00 2001 From: Popie <86546258+Popie52@users.noreply.github.com> Date: Sat, 6 Dec 2025 12:25:23 +0530 Subject: [PATCH 2/3] Part 9b: refactor: migrate to Node16 module resolution and ESLint flat config MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated TypeScript and ESLint setup to remove deprecated configuration fields. - Migrated from `moduleResolution: "node"` → `moduleResolution: "node16"`. - Set `module: "node16"` to satisfy TS 5+ validation rules. - Replaced deprecated `tseslint.config()` usage with the recommended flat config export. - Modernized ESLint parser options and config structure. - Ensures compatibility with latest TypeScript, ESLint, and typescript-eslint releases. This improves maintainability, resolves deprecation warnings, and aligns the repository with current ecosystem standards. --- src/content/9/en/part9b.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/content/9/en/part9b.md b/src/content/9/en/part9b.md index f3982dc96c..3a304c3634 100644 --- a/src/content/9/en/part9b.md +++ b/src/content/9/en/part9b.md @@ -622,7 +622,8 @@ Let's specify the following configuration in our *tsconfig.json* file: "noFallthroughCasesInSwitch": true, "noImplicitAny": true, // highlight-line "esModuleInterop": true, - "moduleResolution": "node" + "module": "node16", + "moduleResolution": "node16" } } ``` @@ -733,6 +734,7 @@ This is because we banned unused parameters in our *tsconfig.json*: "noFallthroughCasesInSwitch": true, "noImplicitAny": true, "esModuleInterop": true, + "module": "node16", "moduleResolution": "node16" } } From 4a858a3dae3966a633a56c062d11f2fdfc157b20 Mon Sep 17 00:00:00 2001 From: Popie <86546258+Popie52@users.noreply.github.com> Date: Sat, 6 Dec 2025 12:37:08 +0530 Subject: [PATCH 3/3] Uncomment TypeScript ESLint rules --- src/content/9/en/part9b.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/9/en/part9b.md b/src/content/9/en/part9b.md index 3a304c3634..b3f226ea94 100644 --- a/src/content/9/en/part9b.md +++ b/src/content/9/en/part9b.md @@ -997,8 +997,8 @@ export default [ }, rules: { "@stylistic/semi": "error", - // "@typescript-eslint/no-unsafe-assignment": "error", - // "@typescript-eslint/no-explicit-any": "error", + "@typescript-eslint/no-unsafe-assignment": "error", + "@typescript-eslint/no-explicit-any": "error", "@typescript-eslint/explicit-function-return-type": "off", "@typescript-eslint/explicit-module-boundary-types": "off", "@typescript-eslint/restrict-template-expressions": "off",