Skip to content

Commit

Permalink
feat(ts): add rules that required parserOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
zanminkian committed Nov 24, 2022
1 parent 2a1e59f commit 704a883
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/basic/index.js
Expand Up @@ -279,7 +279,7 @@ module.exports = {
'no-multi-spaces': 'error',
'no-multi-str': 'error',
'no-with': 'error',
'no-void': 'error',
'no-void': ['error', { 'allowAsStatement': true }],
'no-useless-escape': 'off',
'vars-on-top': 'error',
'require-await': 'off',
Expand Down
37 changes: 25 additions & 12 deletions packages/typescript/index.js
@@ -1,3 +1,5 @@
const fs = require('fs')
const { join } = require('path')
const basic = require('@antfu/eslint-config-basic')

module.exports = {
Expand All @@ -11,7 +13,29 @@ module.exports = {
node: { extensions: ['.js', '.jsx', '.mjs', '.ts', '.tsx', '.d.ts'] },
},
},
overrides: basic.overrides,
overrides: basic.overrides.concat(
!fs.existsSync(join(process.cwd(), 'tsconfig.json'))
? []
: [{
parserOptions: {
tsconfigRootDir: process.cwd(),
project: ['tsconfig.json'],
},
parser: '@typescript-eslint/parser',
excludedFiles: ['**/*.md/*.*'],
files: ['*.ts', '*.tsx'],
rules: {
'no-throw-literal': 'off',
'@typescript-eslint/no-throw-literal': 'error',
'no-implied-eval': 'off',
'@typescript-eslint/no-implied-eval': 'error',
'dot-notation': 'off',
'@typescript-eslint/dot-notation': ['error', { allowKeywords: true }],
'@typescript-eslint/no-floating-promises': 'error',
'@typescript-eslint/no-misused-promises': 'error',
},
}],
),
rules: {
'import/named': 'off',

Expand Down Expand Up @@ -109,17 +133,6 @@ module.exports = {
// antfu
'antfu/generic-spacing': 'error',

// The following rule overrides require a parser service, aka. require a `typescript.json` path.
// This needs to be done individually for each project, and it slows down linting significantly.
// 'no-throw-literal': 'off',
// '@typescript-eslint/no-throw-literal': 'error',
// 'no-implied-eval': 'off',
// '@typescript-eslint/no-implied-eval': 'error',
// 'dot-notation': 'off',
// '@typescript-eslint/dot-notation': ['error', { allowKeywords: true }],
// '@typescript-eslint/no-floating-promises': 'error',
// '@typescript-eslint/no-misused-promises': 'error',

// off
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/naming-convention': 'off',
Expand Down

0 comments on commit 704a883

Please sign in to comment.