fix: type aware linting when trigged by tsconfig.eslint.json

This commit is contained in:
Anthony Fu 2022-11-30 09:02:21 +08:00
parent afc680cb29
commit 1c4260a937
2 changed files with 6 additions and 2 deletions

View File

@ -54,6 +54,10 @@ Install [VS Code ESLint extension](https://marketplace.visualstudio.com/items?it
} }
``` ```
### TypeScript Aware Rules
Type aware rules are enabled when a `tsconfig.eslint.json` is found in the project root. Refer to [this file](https://github.com/antfu/eslint-config/blob/main/packages/typescript/index.js#L17).
## Extended Reading ## Extended Reading
Learn more about the context - [Why I don't use Prettier](https://antfu.me/posts/why-not-prettier). Learn more about the context - [Why I don't use Prettier](https://antfu.me/posts/why-not-prettier).

View File

@ -14,7 +14,7 @@ module.exports = {
}, },
}, },
overrides: basic.overrides.concat( overrides: basic.overrides.concat(
!fs.existsSync(join(process.cwd(), 'tsconfig.json')) !fs.existsSync(join(process.cwd(), 'tsconfig.eslint.json'))
? [] ? []
: [{ : [{
parserOptions: { parserOptions: {
@ -31,7 +31,7 @@ module.exports = {
'@typescript-eslint/no-implied-eval': 'error', '@typescript-eslint/no-implied-eval': 'error',
'dot-notation': 'off', 'dot-notation': 'off',
'@typescript-eslint/dot-notation': ['error', { allowKeywords: true }], '@typescript-eslint/dot-notation': ['error', { allowKeywords: true }],
'no-void': ['error', { 'allowAsStatement': true }], 'no-void': ['error', { allowAsStatement: true }],
'@typescript-eslint/no-floating-promises': 'error', '@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error', '@typescript-eslint/no-misused-promises': 'error',
}, },