1
- const { rules : baseBestPracticesRules } = require ( 'eslint-config-airbnb-base/rules/best-practices' ) ;
2
- const { rules : baseErrorsRules } = require ( 'eslint-config-airbnb-base/rules/errors' ) ;
3
- const { rules : baseES6Rules } = require ( 'eslint-config-airbnb-base/rules/es6' ) ;
4
- const { rules : baseImportsRules } = require ( 'eslint-config-airbnb-base/rules/imports' ) ;
5
1
const { rules : baseStyleRules } = require ( 'eslint-config-airbnb-base/rules/style' ) ;
6
- const { rules : baseVariablesRules } = require ( 'eslint-config-airbnb-base/rules/variables' ) ;
7
2
const tsconfigJson = require ( './tsconfig.json' ) ;
3
+ require ( '@rushstack/eslint-patch/modern-module-resolution' ) ;
8
4
9
5
module . exports = {
10
6
root : true ,
@@ -17,9 +13,7 @@ module.exports = {
17
13
'plugin:vue/essential' ,
18
14
19
15
// Extends eslint-config-airbnb
20
- // Added by Vue CLI
21
- // Here until https://github.com/vuejs/eslint-config-airbnb/issues/23 is done
22
- '@vue/airbnb' ,
16
+ '@vue/eslint-config-airbnb-with-typescript' ,
23
17
24
18
// Extends @typescript -eslint/recommended
25
19
// Uses the recommended rules from the @typescript -eslint/eslint-plugin
@@ -52,18 +46,6 @@ module.exports = {
52
46
mocha : true ,
53
47
} ,
54
48
} ,
55
- {
56
- files : [ '**/*.ts?(x)' , '**/*.d.ts' ] ,
57
- parserOptions : {
58
- // Setting project is required for some rules such as @typescript -eslint/dot-notation,
59
- // @typescript -eslint/return-await and @typescript-eslint/no-throw-literal.
60
- // If this property is missing they fail due to missing parser.
61
- project : [ './tsconfig.json' ] ,
62
- } ,
63
- rules : {
64
- ...getTypeScriptOverrides ( ) ,
65
- } ,
66
- } ,
67
49
{
68
50
files : [ '**/tests/**/*.{j,t}s?(x)' ] ,
69
51
rules : {
@@ -115,6 +97,7 @@ function getOpinionatedRuleOverrides() {
115
97
return {
116
98
// https://erkinekici.com/articles/linting-trap#no-use-before-define
117
99
'no-use-before-define' : 'off' ,
100
+ '@typescript-eslint/no-use-before-define' : 'off' ,
118
101
// https://erkinekici.com/articles/linting-trap#arrow-body-style
119
102
'arrow-body-style' : 'off' ,
120
103
// https://erkinekici.com/articles/linting-trap#no-plusplus
@@ -134,164 +117,6 @@ function getOpinionatedRuleOverrides() {
134
117
} ;
135
118
}
136
119
137
- function getTypeScriptOverrides ( ) {
138
- /*
139
- Here until Vue supports AirBnb Typescript overrides (vuejs/eslint-config-airbnb#23).
140
- Based on `eslint-config-airbnb-typescript`.
141
- Source: https://github.com/iamturns/eslint-config-airbnb-typescript/blob/v16.1.0/lib/shared.js
142
- It cannot be used directly due to compilation errors.
143
- */
144
- return {
145
- 'brace-style' : 'off' ,
146
- '@typescript-eslint/brace-style' : baseStyleRules [ 'brace-style' ] ,
147
-
148
- camelcase : 'off' ,
149
- '@typescript-eslint/naming-convention' : [
150
- 'error' ,
151
- { selector : 'variable' , format : [ 'camelCase' , 'PascalCase' , 'UPPER_CASE' ] } ,
152
- { selector : 'function' , format : [ 'camelCase' , 'PascalCase' ] } ,
153
- { selector : 'typeLike' , format : [ 'PascalCase' ] } ,
154
- ] ,
155
-
156
- 'comma-dangle' : 'off' ,
157
- '@typescript-eslint/comma-dangle' : [
158
- baseStyleRules [ 'comma-dangle' ] [ 0 ] ,
159
- {
160
- ...baseStyleRules [ 'comma-dangle' ] [ 1 ] ,
161
- enums : baseStyleRules [ 'comma-dangle' ] [ 1 ] . arrays ,
162
- generics : baseStyleRules [ 'comma-dangle' ] [ 1 ] . arrays ,
163
- tuples : baseStyleRules [ 'comma-dangle' ] [ 1 ] . arrays ,
164
- } ,
165
- ] ,
166
-
167
- 'comma-spacing' : 'off' ,
168
- '@typescript-eslint/comma-spacing' : baseStyleRules [ 'comma-spacing' ] ,
169
-
170
- 'default-param-last' : 'off' ,
171
- '@typescript-eslint/default-param-last' : baseBestPracticesRules [ 'default-param-last' ] ,
172
-
173
- 'dot-notation' : 'off' ,
174
- '@typescript-eslint/dot-notation' : baseBestPracticesRules [ 'dot-notation' ] ,
175
-
176
- 'func-call-spacing' : 'off' ,
177
- '@typescript-eslint/func-call-spacing' : baseStyleRules [ 'func-call-spacing' ] ,
178
-
179
- // ❌ Broken for some cases, but still useful.
180
- // Here until Prettifier is used.
181
- indent : 'off' ,
182
- '@typescript-eslint/indent' : baseStyleRules . indent ,
183
-
184
- 'keyword-spacing' : 'off' ,
185
- '@typescript-eslint/keyword-spacing' : baseStyleRules [ 'keyword-spacing' ] ,
186
-
187
- 'lines-between-class-members' : 'off' ,
188
- '@typescript-eslint/lines-between-class-members' : baseStyleRules [ 'lines-between-class-members' ] ,
189
-
190
- 'no-array-constructor' : 'off' ,
191
- '@typescript-eslint/no-array-constructor' : baseStyleRules [ 'no-array-constructor' ] ,
192
-
193
- 'no-dupe-class-members' : 'off' ,
194
- '@typescript-eslint/no-dupe-class-members' : baseES6Rules [ 'no-dupe-class-members' ] ,
195
-
196
- 'no-empty-function' : 'off' ,
197
- '@typescript-eslint/no-empty-function' : baseBestPracticesRules [ 'no-empty-function' ] ,
198
-
199
- 'no-extra-parens' : 'off' ,
200
- '@typescript-eslint/no-extra-parens' : baseErrorsRules [ 'no-extra-parens' ] ,
201
-
202
- 'no-extra-semi' : 'off' ,
203
- '@typescript-eslint/no-extra-semi' : baseErrorsRules [ 'no-extra-semi' ] ,
204
-
205
- // ❌ Fails due to missing parser
206
- // 'no-implied-eval': 'off',
207
- // 'no-new-func': 'off',
208
- // '@typescript-eslint/no-implied-eval': baseBestPracticesRules['no-implied-eval'],
209
-
210
- 'no-loss-of-precision' : 'off' ,
211
- '@typescript-eslint/no-loss-of-precision' : baseErrorsRules [ 'no-loss-of-precision' ] ,
212
-
213
- 'no-loop-func' : 'off' ,
214
- '@typescript-eslint/no-loop-func' : baseBestPracticesRules [ 'no-loop-func' ] ,
215
-
216
- 'no-magic-numbers' : 'off' ,
217
- '@typescript-eslint/no-magic-numbers' : baseBestPracticesRules [ 'no-magic-numbers' ] ,
218
-
219
- 'no-redeclare' : 'off' ,
220
- '@typescript-eslint/no-redeclare' : baseBestPracticesRules [ 'no-redeclare' ] ,
221
-
222
- // ESLint variant does not work with TypeScript enums.
223
- 'no-shadow' : 'off' ,
224
- '@typescript-eslint/no-shadow' : baseVariablesRules [ 'no-shadow' ] ,
225
-
226
- 'no-throw-literal' : 'off' ,
227
- '@typescript-eslint/no-throw-literal' : baseBestPracticesRules [ 'no-throw-literal' ] ,
228
-
229
- 'no-unused-expressions' : 'off' ,
230
- '@typescript-eslint/no-unused-expressions' : baseBestPracticesRules [ 'no-unused-expressions' ] ,
231
-
232
- 'no-unused-vars' : 'off' ,
233
- '@typescript-eslint/no-unused-vars' : baseVariablesRules [ 'no-unused-vars' ] ,
234
-
235
- // https://erkinekici.com/articles/linting-trap#no-use-before-define
236
- // 'no-use-before-define': 'off',
237
- // '@typescript-eslint/no-use-before-define': baseVariablesRules['no-use-before-define'],
238
-
239
- // ESLint variant does not understand TypeScript constructors.
240
- // eslint/eslint/#14118, typescript-eslint/typescript-eslint#873
241
- 'no-useless-constructor' : 'off' ,
242
- '@typescript-eslint/no-useless-constructor' : baseES6Rules [ 'no-useless-constructor' ] ,
243
-
244
- quotes : 'off' ,
245
- '@typescript-eslint/quotes' : baseStyleRules . quotes ,
246
-
247
- semi : 'off' ,
248
- '@typescript-eslint/semi' : baseStyleRules . semi ,
249
-
250
- 'space-before-function-paren' : 'off' ,
251
- '@typescript-eslint/space-before-function-paren' : baseStyleRules [ 'space-before-function-paren' ] ,
252
-
253
- 'require-await' : 'off' ,
254
- '@typescript-eslint/require-await' : baseBestPracticesRules [ 'require-await' ] ,
255
-
256
- 'no-return-await' : 'off' ,
257
- '@typescript-eslint/return-await' : baseBestPracticesRules [ 'no-return-await' ] ,
258
-
259
- 'space-infix-ops' : 'off' ,
260
- '@typescript-eslint/space-infix-ops' : baseStyleRules [ 'space-infix-ops' ] ,
261
-
262
- 'object-curly-spacing' : 'off' ,
263
- '@typescript-eslint/object-curly-spacing' : baseStyleRules [ 'object-curly-spacing' ] ,
264
-
265
- 'import/extensions' : [
266
- baseImportsRules [ 'import/extensions' ] [ 0 ] ,
267
- baseImportsRules [ 'import/extensions' ] [ 1 ] ,
268
- {
269
- ...baseImportsRules [ 'import/extensions' ] [ 2 ] ,
270
- ts : 'never' ,
271
- tsx : 'never' ,
272
- } ,
273
- ] ,
274
-
275
- // Changes required is not yet implemented:
276
- // 'import/no-extraneous-dependencies': [
277
- // baseImportsRules['import/no-extraneous-dependencies'][0],
278
- // {
279
- // ...baseImportsRules['import/no-extraneous-dependencies'][1],
280
- // devDependencies: baseImportsRules[
281
- // 'import/no-extraneous-dependencies'
282
- // ][1].devDependencies.reduce((result, devDep) => {
283
- // const toAppend = [devDep];
284
- // const devDepWithTs = devDep.replace(/\bjs(x?)\b/g, 'ts$1');
285
- // if (devDepWithTs !== devDep) {
286
- // toAppend.push(devDepWithTs);
287
- // }
288
- // return [...result, ...toAppend];
289
- // }, []),
290
- // },
291
- // ],
292
- } ;
293
- }
294
-
295
120
function getAliasesFromTsConfig ( ) {
296
121
return Object . keys ( tsconfigJson . compilerOptions . paths )
297
122
. map ( ( path ) => `${ path } *` ) ;
0 commit comments