Skip to content

Commit 6dad413

Browse files
authored
fix: do not use typescript.configs.disableTypeChecked (#88786)
as it turns off too many rules, and the pre-commit --fix changes things that we need
1 parent 73c708c commit 6dad413

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

eslint-pre-commit.config.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import typescript from 'typescript-eslint';
22

3-
import configs from './eslint.config.mjs';
3+
import configs, {typeAwareLintRules} from './eslint.config.mjs';
44

55
export default typescript.config([
66
...configs,
@@ -13,6 +13,9 @@ export default typescript.config([
1313
},
1414
},
1515
{
16-
extends: [typescript.configs.disableTypeChecked],
16+
name: typeAwareLintRules.name,
17+
rules: Object.fromEntries(
18+
Object.entries(typeAwareLintRules.rules).map(([key]) => [key, 'off'])
19+
),
1720
},
1821
]);

eslint.config.mjs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ invariant(react.configs.flat, 'For typescript');
3737
invariant(react.configs.flat.recommended, 'For typescript');
3838
invariant(react.configs.flat['jsx-runtime'], 'For typescript');
3939

40+
// lint rules that need type information need to go here
41+
export const typeAwareLintRules = {
42+
name: 'plugin/typescript-eslint/type-aware-linting',
43+
rules: {
44+
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
45+
},
46+
};
47+
4048
const restrictedImportPaths = [
4149
{
4250
name: '@testing-library/react',
@@ -444,12 +452,7 @@ export default typescript.config([
444452
// https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/eslint-plugin/src/configs/stylistic.ts
445453
...typescript.configs.strict.map(c => ({...c, name: `plugin/${c.name}`})),
446454
...typescript.configs.stylistic.map(c => ({...c, name: `plugin/${c.name}`})),
447-
{
448-
name: 'plugin/typescript-eslint/typed-aware-linting',
449-
rules: {
450-
'@typescript-eslint/no-unnecessary-type-assertion': 'error',
451-
},
452-
},
455+
typeAwareLintRules,
453456
{
454457
name: 'plugin/typescript-eslint/overrides',
455458
// https://typescript-eslint.io/rules/

0 commit comments

Comments
 (0)