Skip to content

Commit

Permalink
feat(ts): support type aware and update overrides recommended rules
Browse files Browse the repository at this point in the history
  • Loading branch information
haoziqaq committed Jan 7, 2025
1 parent 654c880 commit 079cfdd
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions src/configs/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ export function createTsConfig(options: CreateTsConfigOptions = {}): Linter.Conf

const files = ['**/*.?([cm])ts', '**/*.?([cm])tsx', ...exts.map((ext) => `**/*.${ext}`)]

console.log(tsPlugin.configs['eslint-recommended'].overrides![0].rules)

return [
{
name: createConfigName('ts/setup'),
Expand All @@ -27,16 +29,39 @@ export function createTsConfig(options: CreateTsConfigOptions = {}): Linter.Conf
parserOptions: {
sourceType: 'module',
extraFileExtensions: exts.map((ext) => `.${ext}`),
tsconfigRootDir: process.cwd(),
projectService: {
allowDefaultProject: ['./*.js'],
},
},
},
},
{
name: createConfigName('ts/rules'),
files,
rules: {
'no-array-constructor': 'off',
'no-unused-vars': 'off',
'no-unused-expressions': 'off',
'constructor-super': 'off',
'getter-return': 'off',
'no-class-assign': 'off',
'no-const-assign': 'off',
'no-dupe-args': 'off',
'no-dupe-class-members': 'off',
'no-dupe-keys': 'off',
'no-func-assign': 'off',
'no-import-assign': 'off',
'no-new-symbol': 'off',
'no-new-native-nonconstructor': 'off',
'no-obj-calls': 'off',
'no-redeclare': 'off',
'no-setter-return': 'off',
'no-this-before-super': 'off',
'no-undef': 'off',
'no-unreachable': 'off',
'no-unsafe-negation': 'off',
'no-var': 'error',
'prefer-const': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'@typescript-eslint/no-array-constructor': 'error',
'@typescript-eslint/no-duplicate-enum-values': 'error',
'@typescript-eslint/no-extra-non-null-assertion': 'error',
Expand All @@ -48,7 +73,6 @@ export function createTsConfig(options: CreateTsConfigOptions = {}): Linter.Conf
'@typescript-eslint/no-unnecessary-type-constraint': 'error',
'@typescript-eslint/no-unsafe-declaration-merging': 'error',
'@typescript-eslint/no-unsafe-function-type': 'error',
'@typescript-eslint/no-unused-expressions': 'error',
'@typescript-eslint/no-unused-vars': 'error',
'@typescript-eslint/no-wrapper-object-types': 'error',
'@typescript-eslint/prefer-as-const': 'error',
Expand All @@ -58,6 +82,14 @@ export function createTsConfig(options: CreateTsConfigOptions = {}): Linter.Conf
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-for-in-array': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-unused-expressions': [
'error',
{
allowShortCircuit: true,
allowTaggedTemplates: true,
allowTernary: true,
},
],
},
},
]
Expand Down

0 comments on commit 079cfdd

Please sign in to comment.