feat(ts): add rules that required parserOptions (#131)
Closes https://github.com/antfu/eslint-config/issues/112
This commit is contained in:
parent
6189a9225c
commit
7c769fee49
@ -1,3 +1,5 @@
|
|||||||
|
const fs = require('fs')
|
||||||
|
const { join } = require('path')
|
||||||
const basic = require('@antfu/eslint-config-basic')
|
const basic = require('@antfu/eslint-config-basic')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@ -11,7 +13,30 @@ module.exports = {
|
|||||||
node: { extensions: ['.js', '.jsx', '.mjs', '.ts', '.tsx', '.d.ts'] },
|
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 }],
|
||||||
|
'no-void': ['error', { 'allowAsStatement': true }],
|
||||||
|
'@typescript-eslint/no-floating-promises': 'error',
|
||||||
|
'@typescript-eslint/no-misused-promises': 'error',
|
||||||
|
},
|
||||||
|
}],
|
||||||
|
),
|
||||||
rules: {
|
rules: {
|
||||||
'import/named': 'off',
|
'import/named': 'off',
|
||||||
|
|
||||||
@ -109,17 +134,6 @@ module.exports = {
|
|||||||
// antfu
|
// antfu
|
||||||
'antfu/generic-spacing': 'error',
|
'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
|
// off
|
||||||
'@typescript-eslint/consistent-indexed-object-style': 'off',
|
'@typescript-eslint/consistent-indexed-object-style': 'off',
|
||||||
'@typescript-eslint/naming-convention': 'off',
|
'@typescript-eslint/naming-convention': 'off',
|
||||||
|
Loading…
Reference in New Issue
Block a user