diff --git a/eslint-pre-commit.config.mjs b/eslint-pre-commit.config.mjs index c0a4a65fa2109e..0ac7baf1a14942 100644 --- a/eslint-pre-commit.config.mjs +++ b/eslint-pre-commit.config.mjs @@ -1,6 +1,6 @@ import typescript from 'typescript-eslint'; -import configs from './eslint.config.mjs'; +import configs, {typeAwareLintRules} from './eslint.config.mjs'; export default typescript.config([ ...configs, @@ -13,6 +13,9 @@ export default typescript.config([ }, }, { - extends: [typescript.configs.disableTypeChecked], + name: typeAwareLintRules.name, + rules: Object.fromEntries( + Object.entries(typeAwareLintRules.rules).map(([key]) => [key, 'off']) + ), }, ]); diff --git a/eslint.config.mjs b/eslint.config.mjs index e68275bf05e744..919ae564d65469 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -37,6 +37,14 @@ invariant(react.configs.flat, 'For typescript'); invariant(react.configs.flat.recommended, 'For typescript'); invariant(react.configs.flat['jsx-runtime'], 'For typescript'); +// lint rules that need type information need to go here +export const typeAwareLintRules = { + name: 'plugin/typescript-eslint/type-aware-linting', + rules: { + '@typescript-eslint/no-unnecessary-type-assertion': 'error', + }, +}; + const restrictedImportPaths = [ { name: '@testing-library/react', @@ -444,12 +452,7 @@ export default typescript.config([ // https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/stylistic.ts ...typescript.configs.strict.map(c => ({...c, name: `plugin/${c.name}`})), ...typescript.configs.stylistic.map(c => ({...c, name: `plugin/${c.name}`})), - { - name: 'plugin/typescript-eslint/typed-aware-linting', - rules: { - '@typescript-eslint/no-unnecessary-type-assertion': 'error', - }, - }, + typeAwareLintRules, { name: 'plugin/typescript-eslint/overrides', // https://typescript-eslint.io/rules/