1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | const fs = require('fs');
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | module.exports = {
|
14 | root: true,
|
15 |
|
16 | parser: '@typescript-eslint/parser',
|
17 |
|
18 | plugins: ['eslint-plugin', '@typescript-eslint', 'mocha'],
|
19 | env: {
|
20 | es6: true,
|
21 | node: true,
|
22 | mocha: true,
|
23 | },
|
24 | parserOptions: {
|
25 | sourceType: 'module',
|
26 | |
27 |
|
28 |
|
29 |
|
30 |
|
31 | project: getProjectFile(),
|
32 | ecmaFeatures: {
|
33 | ecmaVersion: 2017,
|
34 | jsx: false,
|
35 | },
|
36 | noWatch: true,
|
37 | },
|
38 | extends: [
|
39 | 'eslint:recommended',
|
40 | 'plugin:@typescript-eslint/recommended',
|
41 | |
42 |
|
43 |
|
44 |
|
45 | 'prettier',
|
46 | ],
|
47 | rules: {
|
48 | 'prefer-const': 'error',
|
49 | 'no-mixed-operators': 'off',
|
50 | 'no-console': 'off',
|
51 |
|
52 | 'no-inner-declarations': 'off',
|
53 |
|
54 | 'no-dupe-class-members': 'off',
|
55 | 'no-useless-escape': 'off',
|
56 |
|
57 | 'no-redeclare': 'off',
|
58 |
|
59 | |
60 |
|
61 |
|
62 | 'mocha/handle-done-callback': 'error',
|
63 | 'mocha/no-exclusive-tests': 'error',
|
64 | 'mocha/no-identical-title': 'error',
|
65 | 'mocha/no-nested-tests': 'error',
|
66 | 'no-array-constructor': 'error',
|
67 |
|
68 | |
69 |
|
70 |
|
71 |
|
72 | '@typescript-eslint/array-type': 'off',
|
73 | '@typescript-eslint/indent': 'off',
|
74 | '@typescript-eslint/no-non-null-assertion': 'off',
|
75 | '@typescript-eslint/explicit-function-return-type': 'off',
|
76 | '@typescript-eslint/explicit-member-accessibility': 'off',
|
77 | '@typescript-eslint/no-var-requires': 'off',
|
78 | '@typescript-eslint/no-use-before-define': 'off',
|
79 | '@typescript-eslint/no-object-literal-type-assertion': 'off',
|
80 | '@typescript-eslint/no-parameter-properties': 'off',
|
81 | '@typescript-eslint/no-angle-bracket-type-assertion': 'off',
|
82 | '@typescript-eslint/prefer-interface': 'off',
|
83 | '@typescript-eslint/no-namespace': 'off',
|
84 | '@typescript-eslint/ban-types': 'off',
|
85 | '@typescript-eslint/no-triple-slash-reference': 'off',
|
86 | '@typescript-eslint/no-empty-interface': 'off',
|
87 | '@typescript-eslint/no-non-null-asserted-optional-chain': 'error',
|
88 |
|
89 |
|
90 | '@typescript-eslint/explicit-module-boundary-types': 'off',
|
91 |
|
92 | |
93 |
|
94 |
|
95 |
|
96 |
|
97 | '@typescript-eslint/adjacent-overload-signatures': 'error',
|
98 | '@typescript-eslint/prefer-for-of': 'error',
|
99 | '@typescript-eslint/unified-signatures': 'error',
|
100 | '@typescript-eslint/no-explicit-any': 'error',
|
101 |
|
102 | 'no-unused-labels': 'error',
|
103 | 'no-caller': 'error',
|
104 | 'no-new-wrappers': 'error',
|
105 |
|
106 |
|
107 | 'no-invalid-this': 'off',
|
108 | '@typescript-eslint/no-invalid-this': ['error'],
|
109 | '@typescript-eslint/no-misused-new': 'error',
|
110 |
|
111 |
|
112 | 'no-shadow': 'off',
|
113 | '@typescript-eslint/no-shadow': 'error',
|
114 |
|
115 | 'no-throw-literal': 'error',
|
116 |
|
117 | '@typescript-eslint/no-unused-vars': [
|
118 | 'error',
|
119 | {
|
120 | vars: 'all',
|
121 | args: 'none',
|
122 | ignoreRestSiblings: false,
|
123 | },
|
124 | ],
|
125 | 'no-unused-expressions': 'error',
|
126 | 'no-var': 'error',
|
127 | eqeqeq: ['error', 'smart'],
|
128 |
|
129 |
|
130 | '@typescript-eslint/await-thenable': 'error',
|
131 | '@typescript-eslint/no-floating-promises': 'error',
|
132 |
|
133 | 'no-void': 'error',
|
134 |
|
135 | '@typescript-eslint/no-empty-function': 'off',
|
136 | '@typescript-eslint/consistent-type-assertions': 'off',
|
137 | '@typescript-eslint/no-misused-promises': 'error',
|
138 |
|
139 | '@typescript-eslint/prefer-optional-chain': 'error',
|
140 | '@typescript-eslint/prefer-nullish-coalescing': 'error',
|
141 | '@typescript-eslint/no-extra-non-null-assertion': 'error',
|
142 |
|
143 |
|
144 | '@typescript-eslint/return-await': 'error',
|
145 |
|
146 | 'no-return-await': 'off',
|
147 |
|
148 |
|
149 | camelcase: 'off',
|
150 | '@typescript-eslint/naming-convention': [
|
151 | 'error',
|
152 | {
|
153 | selector: 'default',
|
154 | format: ['camelCase'],
|
155 | },
|
156 |
|
157 | {
|
158 | selector: 'variable',
|
159 | format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
|
160 | },
|
161 |
|
162 | {
|
163 | selector: 'variable',
|
164 | format: null,
|
165 | filter: '^_$',
|
166 | },
|
167 |
|
168 |
|
169 | {
|
170 | selector: 'function',
|
171 | format: ['PascalCase'],
|
172 | filter: 'Mixin$',
|
173 | },
|
174 |
|
175 | {
|
176 | selector: 'parameter',
|
177 | format: ['camelCase'],
|
178 | leadingUnderscore: 'allow',
|
179 | },
|
180 |
|
181 |
|
182 | {
|
183 | selector: 'enumMember',
|
184 | format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
|
185 | leadingUnderscore: 'allow',
|
186 | },
|
187 |
|
188 |
|
189 | {
|
190 | selector: 'property',
|
191 | format: ['camelCase', 'UPPER_CASE', 'PascalCase'],
|
192 | leadingUnderscore: 'allow',
|
193 | },
|
194 |
|
195 | {
|
196 | selector: 'method',
|
197 | format: ['camelCase'],
|
198 | leadingUnderscore: 'allow',
|
199 | },
|
200 |
|
201 |
|
202 | {
|
203 | selector: 'memberLike',
|
204 | modifiers: ['static'],
|
205 | format: ['camelCase', 'UPPER_CASE'],
|
206 | },
|
207 |
|
208 |
|
209 | {
|
210 | selector: 'memberLike',
|
211 | modifiers: ['private'],
|
212 | format: ['camelCase'],
|
213 | leadingUnderscore: 'allow',
|
214 | },
|
215 |
|
216 |
|
217 | {
|
218 | selector: 'memberLike',
|
219 | modifiers: ['protected'],
|
220 | format: ['camelCase'],
|
221 | leadingUnderscore: 'allow',
|
222 | },
|
223 |
|
224 | {
|
225 | selector: 'typeLike',
|
226 | format: ['PascalCase'],
|
227 | },
|
228 |
|
229 | {
|
230 | selector: 'objectLiteralProperty',
|
231 | format: null,
|
232 |
|
233 | modifiers: ['requiresQuotes'],
|
234 | },
|
235 | ],
|
236 | },
|
237 |
|
238 | overrides: [
|
239 | {
|
240 | files: ['**/*.js'],
|
241 | rules: {
|
242 | '@typescript-eslint/prefer-optional-chain': 'off',
|
243 | '@typescript-eslint/prefer-nullish-coalescing': 'off',
|
244 | },
|
245 | },
|
246 | ],
|
247 | };
|
248 |
|
249 |
|
250 |
|
251 |
|
252 | function getProjectFile() {
|
253 | if (fs.existsSync('./tsconfig.build.json')) return './tsconfig.build.json';
|
254 | if (fs.existsSync('./tsconfig.json')) return './tsconfig.json';
|
255 | return undefined;
|
256 | }
|