From bba2c9cd79f0bc04627675763e776a001a68dee0 Mon Sep 17 00:00:00 2001 From: Kevin Heis Date: Wed, 22 Oct 2025 12:06:03 -0700 Subject: [PATCH] Move eslint.config.js to Typescript (#58027) --- eslint-plugins.d.ts | 57 +++++++++++++++++++ eslint.config.js => eslint.config.ts | 83 ---------------------------- package-lock.json | 21 +++++++ package.json | 2 + src/ai-tools/scripts/ai-tools.ts | 2 - src/metrics/scripts/docsaudit.ts | 2 - src/metrics/scripts/docstat.ts | 2 - 7 files changed, 80 insertions(+), 89 deletions(-) create mode 100644 eslint-plugins.d.ts rename eslint.config.js => eslint.config.ts (65%) diff --git a/eslint-plugins.d.ts b/eslint-plugins.d.ts new file mode 100644 index 0000000000..acbb6a1890 --- /dev/null +++ b/eslint-plugins.d.ts @@ -0,0 +1,57 @@ +// Type declarations for ESLint plugins without official TypeScript definitions + +declare module 'eslint-plugin-github' { + import type { ESLint, Linter } from 'eslint' + + const plugin: ESLint.Plugin & { + configs: { + recommended: Linter.FlatConfig + } + } + + export default plugin +} + +declare module 'eslint-plugin-primer-react' { + import type { ESLint, Linter } from 'eslint' + + const plugin: ESLint.Plugin & { + configs: { + recommended: Linter.FlatConfig + } + } + + export default plugin +} + +declare module 'eslint-plugin-eslint-comments' { + import type { ESLint } from 'eslint' + + const plugin: ESLint.Plugin + + export default plugin +} + +declare module 'eslint-plugin-i18n-text' { + import type { ESLint } from 'eslint' + + const plugin: ESLint.Plugin + + export default plugin +} + +declare module 'eslint-plugin-filenames' { + import type { ESLint } from 'eslint' + + const plugin: ESLint.Plugin + + export default plugin +} + +declare module 'eslint-plugin-no-only-tests' { + import type { ESLint } from 'eslint' + + const plugin: ESLint.Plugin + + export default plugin +} diff --git a/eslint.config.js b/eslint.config.ts similarity index 65% rename from eslint.config.js rename to eslint.config.ts index 8fa152a4b4..aeb30e33a9 100644 --- a/eslint.config.js +++ b/eslint.config.ts @@ -14,89 +14,6 @@ import prettier from 'eslint-config-prettier' import globals from 'globals' export default [ - // JavaScript and MJS files configuration - { - files: ['**/*.{js,mjs}'], - languageOptions: { - ecmaVersion: 2022, - sourceType: 'module', - globals: { - ...globals.browser, - ...globals.node, - ...globals.commonjs, - ...globals.es2020, - }, - parserOptions: { - requireConfigFile: false, - }, - }, - settings: { - 'import/resolver': { - typescript: true, - node: true, - }, - }, - plugins: { - github, - import: importPlugin, - 'eslint-comments': eslintComments, - 'i18n-text': i18nText, - filenames, - 'no-only-tests': noOnlyTests, - prettier: prettierPlugin, - }, - rules: { - // ESLint recommended rules - ...js.configs.recommended.rules, - - // GitHub plugin recommended rules - ...github.configs.recommended.rules, - - // Import plugin error rules - ...importPlugin.configs.errors.rules, - - // JavaScript-specific overrides - 'import/no-extraneous-dependencies': [ - 'error', - { - packageDir: '.', - }, - ], - 'import/extensions': 'off', - 'no-console': 'off', - camelcase: 'off', - 'no-shadow': 'off', - 'prefer-template': 'off', - 'no-constant-condition': 'off', - 'no-unused-vars': 'off', - 'import/no-named-as-default-member': 'off', - 'one-var': 'off', - 'import/no-namespace': 'off', - 'import/no-anonymous-default-export': 'off', - 'object-shorthand': 'off', - 'no-empty': 'off', - 'prefer-const': 'off', - 'import/no-named-as-default': 'off', - 'no-useless-concat': 'off', - 'func-style': 'off', - - // Disable GitHub plugin rules that were disabled in original config - 'github/array-foreach': 'off', - 'github/no-then': 'off', - - // Disable rules that might not exist or cause issues initially - 'i18n-text/no-en': 'off', - 'filenames/match-regex': 'off', - 'eslint-comments/no-use': 'off', - 'eslint-comments/no-unused-disable': 'off', - 'eslint-comments/no-unlimited-disable': 'off', - - // Disable new ESLint 9 rules that are causing issues - 'no-constant-binary-expression': 'off', - }, - }, - - // TypeScript and TSX files configuration { files: ['**/*.{ts,tsx}'], languageOptions: { diff --git a/package-lock.json b/package-lock.json index d3f93f38b2..2a7d689f08 100644 --- a/package-lock.json +++ b/package-lock.json @@ -116,6 +116,7 @@ "@types/connect-timeout": "1.9.0", "@types/cookie": "0.6.0", "@types/cookie-parser": "1.4.8", + "@types/eslint-plugin-jsx-a11y": "^6.10.1", "@types/event-to-promise": "^0.7.5", "@types/express": "^5.0.3", "@types/imurmurhash": "^0.1.4", @@ -156,6 +157,7 @@ "graphql": "^16.9.0", "http-status-code": "^2.1.0", "husky": "^9.1.7", + "jiti": "^2.6.1", "json-schema-merge-allof": "^0.8.1", "lint-staged": "^16.0.0", "markdownlint": "^0.34.0", @@ -4063,6 +4065,16 @@ "@types/ms": "*" } }, + "node_modules/@types/eslint-plugin-jsx-a11y": { + "version": "6.10.1", + "resolved": "https://registry.npmjs.org/@types/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.10.1.tgz", + "integrity": "sha512-5RtuPVe0xz8BAhrkn2oww6Uw885atf962Q4fqZo48QdO3EQA7oCEDSXa6optgJ1ZMds3HD9ITK5bfm4AWuoXFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint": "^9" + } + }, "node_modules/@types/estree": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.7.tgz", @@ -10183,6 +10195,15 @@ "version": "2.1.0", "license": "MIT" }, + "node_modules/jiti": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.6.1.tgz", + "integrity": "sha512-ekilCSN1jwRvIbgeg/57YFh8qQDNbwDb9xT/qu2DAHbFFZUicIl4ygVaAvzveMhMVr3LnpSKTNnwt8PoOfmKhQ==", + "dev": true, + "bin": { + "jiti": "lib/jiti-cli.mjs" + } + }, "node_modules/joi": { "version": "17.13.3", "resolved": "https://registry.npmjs.org/joi/-/joi-17.13.3.tgz", diff --git a/package.json b/package.json index a2e3b94592..eae47fc34d 100644 --- a/package.json +++ b/package.json @@ -258,6 +258,7 @@ "@types/connect-timeout": "1.9.0", "@types/cookie": "0.6.0", "@types/cookie-parser": "1.4.8", + "@types/eslint-plugin-jsx-a11y": "^6.10.1", "@types/event-to-promise": "^0.7.5", "@types/express": "^5.0.3", "@types/imurmurhash": "^0.1.4", @@ -298,6 +299,7 @@ "graphql": "^16.9.0", "http-status-code": "^2.1.0", "husky": "^9.1.7", + "jiti": "^2.6.1", "json-schema-merge-allof": "^0.8.1", "lint-staged": "^16.0.0", "markdownlint": "^0.34.0", diff --git a/src/ai-tools/scripts/ai-tools.ts b/src/ai-tools/scripts/ai-tools.ts index 0d2cc4b25f..0237c017b2 100644 --- a/src/ai-tools/scripts/ai-tools.ts +++ b/src/ai-tools/scripts/ai-tools.ts @@ -1,5 +1,3 @@ -#!/usr/bin/env node - import { fileURLToPath } from 'url' import { Command } from 'commander' import fs from 'fs' diff --git a/src/metrics/scripts/docsaudit.ts b/src/metrics/scripts/docsaudit.ts index f371599596..a49d6ccce9 100644 --- a/src/metrics/scripts/docsaudit.ts +++ b/src/metrics/scripts/docsaudit.ts @@ -1,5 +1,3 @@ -#!/usr/bin/env node - import fs from 'fs' import path from 'path' import { fileURLToPath } from 'url' diff --git a/src/metrics/scripts/docstat.ts b/src/metrics/scripts/docstat.ts index bc1850e09e..2e1f6bad7a 100644 --- a/src/metrics/scripts/docstat.ts +++ b/src/metrics/scripts/docstat.ts @@ -1,5 +1,3 @@ -#!/usr/bin/env node - import fs from 'fs' import path from 'path' import { Command } from 'commander'