Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: type aware linting when trigged by tsconfig.eslint.json
  • Loading branch information
antfu committed Nov 30, 2022
1 parent afc680c commit 1c4260a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -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

Learn more about the context - [Why I don't use Prettier](https://antfu.me/posts/why-not-prettier).
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript/index.js
Expand Up @@ -14,7 +14,7 @@ module.exports = {
},
},
overrides: basic.overrides.concat(
!fs.existsSync(join(process.cwd(), 'tsconfig.json'))
!fs.existsSync(join(process.cwd(), 'tsconfig.eslint.json'))
? []
: [{
parserOptions: {
Expand All @@ -31,7 +31,7 @@ module.exports = {
'@typescript-eslint/no-implied-eval': 'error',
'dot-notation': 'off',
'@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-misused-promises': 'error',
},
Expand Down

2 comments on commit 1c4260a

@zanminkian
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should line 22 to be project: ['tsconfig.eslint.json'],?

@antfu
Copy link
Owner Author

@antfu antfu commented on 1c4260a Nov 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, pr welcome

Please sign in to comment.