1
+ const fs = require ( 'fs' )
2
+ const { join } = require ( 'path' )
1
3
const basic = require ( '@antfu/eslint-config-basic' )
2
4
3
5
module . exports = {
@@ -11,7 +13,30 @@ module.exports = {
11
13
node : { extensions : [ '.js' , '.jsx' , '.mjs' , '.ts' , '.tsx' , '.d.ts' ] } ,
12
14
} ,
13
15
} ,
14
- overrides : basic . overrides ,
16
+ overrides : basic . overrides . concat (
17
+ ! fs . existsSync ( join ( process . cwd ( ) , 'tsconfig.json' ) )
18
+ ? [ ]
19
+ : [ {
20
+ parserOptions : {
21
+ tsconfigRootDir : process . cwd ( ) ,
22
+ project : [ 'tsconfig.json' ] ,
23
+ } ,
24
+ parser : '@typescript-eslint/parser' ,
25
+ excludedFiles : [ '**/*.md/*.*' ] ,
26
+ files : [ '*.ts' , '*.tsx' ] ,
27
+ rules : {
28
+ 'no-throw-literal' : 'off' ,
29
+ '@typescript-eslint/no-throw-literal' : 'error' ,
30
+ 'no-implied-eval' : 'off' ,
31
+ '@typescript-eslint/no-implied-eval' : 'error' ,
32
+ 'dot-notation' : 'off' ,
33
+ '@typescript-eslint/dot-notation' : [ 'error' , { allowKeywords : true } ] ,
34
+ 'no-void' : [ 'error' , { 'allowAsStatement' : true } ] ,
35
+ '@typescript-eslint/no-floating-promises' : 'error' ,
36
+ '@typescript-eslint/no-misused-promises' : 'error' ,
37
+ } ,
38
+ } ] ,
39
+ ) ,
15
40
rules : {
16
41
'import/named' : 'off' ,
17
42
@@ -109,17 +134,6 @@ module.exports = {
109
134
// antfu
110
135
'antfu/generic-spacing' : 'error' ,
111
136
112
- // The following rule overrides require a parser service, aka. require a `typescript.json` path.
113
- // This needs to be done individually for each project, and it slows down linting significantly.
114
- // 'no-throw-literal': 'off',
115
- // '@typescript-eslint/no-throw-literal': 'error',
116
- // 'no-implied-eval': 'off',
117
- // '@typescript-eslint/no-implied-eval': 'error',
118
- // 'dot-notation': 'off',
119
- // '@typescript-eslint/dot-notation': ['error', { allowKeywords: true }],
120
- // '@typescript-eslint/no-floating-promises': 'error',
121
- // '@typescript-eslint/no-misused-promises': 'error',
122
-
123
137
// off
124
138
'@typescript-eslint/consistent-indexed-object-style' : 'off' ,
125
139
'@typescript-eslint/naming-convention' : 'off' ,
0 commit comments