Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions eslint-pre-commit.config.mjs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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'])
),
},
]);
15 changes: 9 additions & 6 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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/
Expand Down
Loading