1
- module . exports =
2
- {
3
- env :
4
- {
5
- browser : false ,
1
+ const eslintConfig = {
2
+ env : {
6
3
es6 : true ,
7
- node : true
4
+ node : true ,
8
5
} ,
9
- extends :
10
- [
11
- 'eslint:recommended'
12
- ] ,
6
+ plugins : [ 'prettier' ] ,
13
7
settings : { } ,
14
- parserOptions :
15
- {
16
- ecmaVersion : 2018 ,
8
+ parserOptions : {
9
+ ecmaVersion : 2022 ,
17
10
sourceType : 'module' ,
18
- ecmaFeatures :
19
- {
20
- impliedStrict : true
21
- }
11
+ ecmaFeatures : {
12
+ impliedStrict : true ,
13
+ } ,
14
+ lib : [ 'es2022' ] ,
22
15
} ,
23
- rules :
24
- {
25
- 'array-bracket-spacing' : [ 2 , 'always' ,
26
- {
27
- objectsInArrays : true ,
28
- arraysInArrays : true
29
- } ] ,
30
- 'arrow-parens' : [ 2 , 'always' ] ,
31
- 'arrow-spacing' : 2 ,
32
- 'block-spacing' : [ 2 , 'always' ] ,
33
- 'brace-style' : [ 2 , 'allman' , { allowSingleLine : true } ] ,
34
- 'camelcase' : 2 ,
35
- 'comma-dangle' : 2 ,
36
- 'comma-spacing' : [ 2 , { before : false , after : true } ] ,
37
- 'comma-style' : 2 ,
38
- 'computed-property-spacing' : 2 ,
16
+ globals : {
17
+ NodeJS : 'readonly' ,
18
+ } ,
19
+ extends : [ 'eslint:recommended' , 'plugin:prettier/recommended' ] ,
20
+ rules : {
21
+ 'prettier/prettier' : 2 ,
39
22
'constructor-super' : 2 ,
40
- 'func-call-spacing' : 2 ,
41
- 'generator-star-spacing' : 2 ,
42
- 'guard-for-in' : 2 ,
43
- 'indent' : [ 2 , 'tab' , { 'SwitchCase' : 1 } ] ,
44
- 'key-spacing' : [ 2 ,
45
- {
46
- singleLine :
23
+ curly : [ 2 , 'all' ] ,
24
+ // Unfortunatelly `curly` does not apply to blocks in `switch` cases so
25
+ // this is needed.
26
+ 'no-restricted-syntax' : [
27
+ 2 ,
47
28
{
48
- beforeColon : false ,
49
- afterColon : true
29
+ selector : 'SwitchCase > *.consequent[type!="BlockStatement"]' ,
30
+ message : 'Switch cases without blocks are disallowed' ,
50
31
} ,
51
- multiLine :
52
- {
53
- beforeColon : true ,
54
- afterColon : true ,
55
- align : 'colon'
56
- }
57
- } ] ,
58
- 'keyword-spacing' : 2 ,
59
- 'linebreak-style' : [ 2 , 'unix' ] ,
60
- 'lines-around-comment' : [ 2 ,
61
- {
62
- allowBlockStart : true ,
63
- allowObjectStart : true ,
64
- beforeBlockComment : true ,
65
- beforeLineComment : false
66
- } ] ,
67
- 'max-len' : [ 2 , 90 ,
68
- {
69
- tabWidth : 2 ,
70
- comments : 100 ,
71
- ignoreUrls : true ,
72
- ignoreStrings : true ,
73
- ignoreTemplateLiterals : true ,
74
- ignoreRegExpLiterals : true
75
- } ] ,
32
+ ] ,
33
+ 'guard-for-in' : 2 ,
76
34
'newline-after-var' : 2 ,
77
35
'newline-before-return' : 2 ,
78
- 'newline-per-chained-call' : 2 ,
79
36
'no-alert' : 2 ,
80
37
'no-caller' : 2 ,
81
38
'no-case-declarations' : 2 ,
82
39
'no-catch-shadow' : 2 ,
83
40
'no-class-assign' : 2 ,
84
- 'no-confusing-arrow' : 2 ,
85
41
'no-console' : 2 ,
86
42
'no-const-assign' : 2 ,
87
43
'no-debugger' : 2 ,
88
44
'no-dupe-args' : 2 ,
89
45
'no-dupe-keys' : 2 ,
90
46
'no-duplicate-case' : 2 ,
91
47
'no-div-regex' : 2 ,
92
- 'no-empty' : [ 2 , { allowEmptyCatch : true } ] ,
48
+ 'no-empty' : [ 2 , { allowEmptyCatch : true } ] ,
93
49
'no-empty-pattern' : 2 ,
94
50
'no-else-return' : 0 ,
95
51
'no-eval' : 2 ,
@@ -98,7 +54,6 @@ module.exports =
98
54
'no-extra-bind' : 2 ,
99
55
'no-extra-boolean-cast' : 2 ,
100
56
'no-extra-label' : 2 ,
101
- 'no-extra-semi' : 2 ,
102
57
'no-fallthrough' : 2 ,
103
58
'no-func-assign' : 2 ,
104
59
'no-global-assign' : 2 ,
@@ -109,11 +64,7 @@ module.exports =
109
64
'no-invalid-this' : 2 ,
110
65
'no-irregular-whitespace' : 2 ,
111
66
'no-lonely-if' : 2 ,
112
- 'no-mixed-operators' : 2 ,
113
- 'no-mixed-spaces-and-tabs' : 2 ,
114
- 'no-multi-spaces' : 2 ,
115
67
'no-multi-str' : 2 ,
116
- 'no-multiple-empty-lines' : [ 1 , { max : 1 , maxEOF : 0 , maxBOF : 0 } ] ,
117
68
'no-native-reassign' : 2 ,
118
69
'no-negated-in-lhs' : 2 ,
119
70
'no-new' : 2 ,
@@ -131,43 +82,97 @@ module.exports =
131
82
'no-sequences' : 2 ,
132
83
'no-shadow' : 2 ,
133
84
'no-shadow-restricted-names' : 2 ,
134
- 'no-spaced-func' : 2 ,
135
85
'no-sparse-arrays' : 2 ,
136
86
'no-this-before-super' : 2 ,
137
87
'no-throw-literal' : 2 ,
138
88
'no-undef' : 2 ,
139
- 'no-unexpected-multiline' : 2 ,
140
89
'no-unmodified-loop-condition' : 2 ,
141
90
'no-unreachable' : 2 ,
142
- 'no-unused-vars' : [ 1 , { vars : 'all' , args : 'after-used' } ] ,
143
- 'no-use-before-define' : [ 2 , { functions : false } ] ,
91
+ 'no-unused-vars' : [ 1 , { vars : 'all' , args : 'after-used' } ] ,
92
+ 'no-use-before-define' : 0 ,
144
93
'no-useless-call' : 2 ,
145
94
'no-useless-computed-key' : 2 ,
146
95
'no-useless-concat' : 2 ,
147
96
'no-useless-rename' : 2 ,
148
97
'no-var' : 2 ,
149
- 'no-whitespace-before-property' : 2 ,
150
98
'object-curly-newline' : 0 ,
151
- 'object-curly-spacing' : [ 2 , 'always' ] ,
152
- 'object-property-newline' : [ 2 , { allowMultiplePropertiesPerLine : true } ] ,
153
99
'prefer-const' : 2 ,
154
100
'prefer-rest-params' : 2 ,
155
101
'prefer-spread' : 2 ,
156
102
'prefer-template' : 2 ,
157
- 'quotes' : [ 2 , 'single' , { avoidEscape : true } ] ,
158
- 'semi' : [ 2 , 'always' ] ,
159
- 'semi-spacing' : 2 ,
160
- 'space-before-blocks' : 2 ,
161
- 'space-before-function-paren' : [ 2 ,
162
- {
163
- anonymous : 'never' ,
164
- named : 'never' ,
165
- asyncArrow : 'always'
166
- } ] ,
167
- 'space-in-parens' : [ 2 , 'never' ] ,
168
- 'spaced-comment' : [ 2 , 'always' ] ,
169
- 'strict' : 2 ,
103
+ 'spaced-comment' : [ 2 , 'always' ] ,
104
+ strict : 2 ,
170
105
'valid-typeof' : 2 ,
171
- 'yoda' : 2
172
- }
106
+ yoda : 2 ,
107
+ } ,
108
+ overrides : [ ] ,
173
109
} ;
110
+
111
+ const tsRules = {
112
+ 'no-unused-vars' : 0 ,
113
+ '@typescript-eslint/ban-types' : 0 ,
114
+ '@typescript-eslint/ban-ts-comment' : 0 ,
115
+ '@typescript-eslint/ban-ts-ignore' : 0 ,
116
+ '@typescript-eslint/explicit-module-boundary-types' : 0 ,
117
+ '@typescript-eslint/semi' : 2 ,
118
+ '@typescript-eslint/member-delimiter-style' : [
119
+ 2 ,
120
+ {
121
+ multiline : { delimiter : 'semi' , requireLast : true } ,
122
+ singleline : { delimiter : 'semi' , requireLast : false } ,
123
+ } ,
124
+ ] ,
125
+ '@typescript-eslint/no-explicit-any' : 0 ,
126
+ '@typescript-eslint/no-unused-vars' : [
127
+ 2 ,
128
+ {
129
+ vars : 'all' ,
130
+ args : 'after-used' ,
131
+ ignoreRestSiblings : false ,
132
+ } ,
133
+ ] ,
134
+ '@typescript-eslint/no-use-before-define' : [ 2 , { functions : false } ] ,
135
+ '@typescript-eslint/no-empty-function' : 0 ,
136
+ '@typescript-eslint/no-non-null-assertion' : 0 ,
137
+ } ;
138
+
139
+ eslintConfig . overrides . push ( {
140
+ files : [ '*.ts' ] ,
141
+ parser : '@typescript-eslint/parser' ,
142
+ parserOptions : {
143
+ ...eslintConfig . parserOptions ,
144
+ project : 'tsconfig.json' ,
145
+ } ,
146
+ plugins : [ ...eslintConfig . plugins , '@typescript-eslint' ] ,
147
+ extends : [
148
+ 'plugin:@typescript-eslint/eslint-recommended' ,
149
+ 'plugin:@typescript-eslint/recommended' ,
150
+ ...eslintConfig . extends ,
151
+ ] ,
152
+ rules : { ...eslintConfig . rules , ...tsRules } ,
153
+ } ) ;
154
+
155
+ eslintConfig . overrides . push ( {
156
+ files : [ 'src/test/*.ts' ] ,
157
+ parserOptions : {
158
+ ...eslintConfig . parserOptions ,
159
+ project : 'tsconfig.json' ,
160
+ } ,
161
+ env : {
162
+ ...eslintConfig . env ,
163
+ 'jest/globals' : true ,
164
+ } ,
165
+ extends : [
166
+ 'plugin:@typescript-eslint/eslint-recommended' ,
167
+ 'plugin:@typescript-eslint/recommended' ,
168
+ ...eslintConfig . extends ,
169
+ ] ,
170
+ plugins : [ ...eslintConfig . plugins , '@typescript-eslint' , 'jest' ] ,
171
+ rules : {
172
+ ...eslintConfig . rules ,
173
+ ...tsRules ,
174
+ 'jest/no-disabled-tests' : 2 ,
175
+ } ,
176
+ } ) ;
177
+
178
+ module . exports = eslintConfig ;
0 commit comments