1
0
mirror of synced 2025-12-19 09:57:42 -05:00

Move eslint.config.js to Typescript (#58027)

This commit is contained in:
Kevin Heis
2025-10-22 12:06:03 -07:00
committed by GitHub
parent 8c6e5a3071
commit bba2c9cd79
7 changed files with 80 additions and 89 deletions

143
eslint.config.ts Normal file
View File

@@ -0,0 +1,143 @@
import js from '@eslint/js'
import tseslint from '@typescript-eslint/eslint-plugin'
import tsParser from '@typescript-eslint/parser'
import github from 'eslint-plugin-github'
import importPlugin from 'eslint-plugin-import'
import jsxA11y from 'eslint-plugin-jsx-a11y'
import primerReact from 'eslint-plugin-primer-react'
import eslintComments from 'eslint-plugin-eslint-comments'
import i18nText from 'eslint-plugin-i18n-text'
import filenames from 'eslint-plugin-filenames'
import noOnlyTests from 'eslint-plugin-no-only-tests'
import prettierPlugin from 'eslint-plugin-prettier'
import prettier from 'eslint-config-prettier'
import globals from 'globals'
export default [
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: tsParser,
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,
'@typescript-eslint': tseslint,
'primer-react': primerReact,
'jsx-a11y': jsxA11y,
},
rules: {
// ESLint recommended rules
...js.configs.recommended.rules,
// GitHub plugin recommended rules
...github.configs.recommended.rules,
// Import plugin error rules
...importPlugin.configs.errors.rules,
// TypeScript ESLint recommended rules
...tseslint.configs.recommended.rules,
// Primer React recommended rules
...primerReact.configs.recommended.rules,
// JSX A11y recommended rules
...jsxA11y.configs.recommended.rules,
// TypeScript-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',
'no-undef': 'off',
'no-use-before-define': 'off',
'no-redeclare': 'off', // Allow function overloads in TypeScript
'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',
// TypeScript ESLint specific rules
'@typescript-eslint/no-unused-vars': 'error',
// 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',
// Disable stricter TypeScript rules initially
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-wrapper-object-types': 'off',
'@typescript-eslint/no-non-null-asserted-optional-chain': 'off',
'@typescript-eslint/no-unsafe-function-type': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/prefer-as-const': 'off',
// React/JSX specific rules
'jsx-a11y/no-onchange': 'off',
},
},
// Ignored patterns
{
ignores: [
'tmp/*',
'.next/',
'rest-api-description/',
'docs-internal-data/',
'src/code-scanning/scripts/generate-code-scanning-query-list.ts',
],
},
// Prettier config (should be last to override formatting rules)
prettier,
]