-
Notifications
You must be signed in to change notification settings - Fork 2
/
.eslintrc.cjs
308 lines (291 loc) · 6.35 KB
/
.eslintrc.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
module.exports = {
root: true,
env: {
browser: true,
es2021: true,
node: false,
},
extends: [
'eslint:recommended',
],
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
},
rules: {
/////////////////////////
// Overriding defaults //
/////////////////////////
// Sometimes it's useful to leave a name for an unused argument,
// in case it might be used in the future
'no-unused-vars': [
'error',
{
'vars': 'all',
'args': 'none',
'destructuredArrayIgnorePattern': '.',
'ignoreRestSiblings': false,
},
],
// There are legitimate uses for empty functions
'no-empty-function': 'off',
////////////////////////
// Debugging warnings //
////////////////////////
'no-debugger': 'warn',
'no-constant-condition': 'warn',
'no-warning-comments': [
'warn',
{
'terms': ['TODO'],
'location': 'start',
},
],
////////////////
// Code style //
////////////////
'array-bracket-spacing': ['error', 'never'],
'arrow-parens': ['error', 'always'],
'arrow-spacing': [
'error', {
'before': true,
'after': true,
},
],
'block-spacing': ['error', 'always'],
'brace-style': [
'error',
'1tbs',
{
'allowSingleLine': true,
},
],
'comma-dangle': [
'error',
{
'arrays': 'always-multiline',
'objects': 'always-multiline',
'imports': 'always-multiline',
'exports': 'always-multiline',
'functions': 'only-multiline',
},
],
'comma-spacing': [
'error',
{
'before': false,
'after': true,
},
],
'comma-style': ['error', 'last'],
'curly': ['error', 'all'],
'default-case-last': 'error',
'eol-last': ['error', 'always'],
'func-call-spacing': ['error', 'never'],
'indent': [
'error',
'tab',
{
'SwitchCase': 1,
'ignoredNodes': [
// Ignore indentation within template literals to allow them to be indented like markup
'TemplateLiteral *',
],
},
],
'no-trailing-spaces': ['error'],
'no-undefined': 'error',
'no-var': 'error',
'one-var': ['error', 'never'],
'prefer-template': 'error',
'quotes': [
'error',
'single',
{
'allowTemplateLiterals': true,
},
],
'rest-spread-spacing': ['error', 'never'],
'semi': ['error', 'always'],
'semi-spacing': [
'error',
{
'before': false,
'after': true,
},
],
'space-before-blocks': ['error', 'always'],
'space-before-function-paren': [
'error',
{
anonymous: 'always',
named: 'never',
asyncArrow: 'always',
},
],
'space-in-parens': ['error', 'never'],
'space-unary-ops': [
'error', {
'words': true,
},
],
'spaced-comment': [
'error',
'always',
{
'exceptions': ['/'],
'markers': ['/'],
'block': {
'balanced': true,
},
},
],
'no-mixed-spaces-and-tabs': ['error', 'smart-tabs'],
},
overrides: [
{
files: ['**/*.cjs'],
env: {
commonjs: true,
},
},
{
files: ['**/*.ts'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: [
'./tsconfig.dom.json',
'./tsconfig.node.json',
'./tsconfig.shared.json',
'./tsconfig.workers.json',
],
},
plugins: ['@typescript-eslint'],
rules: {
/////////////////////////
// Overriding defaults //
/////////////////////////
// Sometimes it's useful to leave a name for an unused argument,
// in case it might be used in the future
'@typescript-eslint/no-unused-vars': [
'error',
{
'vars': 'all',
'args': 'none',
'destructuredArrayIgnorePattern': '.',
'ignoreRestSiblings': false,
},
],
// Sometimes it's useful to use a clearer name than `this`
'@typescript-eslint/no-this-alias': 'off',
// There can be value in being explicit about a type that could be inferred,
// especially if a variable's default value might change in the future
'@typescript-eslint/no-inferrable-types': 'off',
// A function returning a `Promise<void>` should be able to go unchecked just
// like a function that returns `void`
'@typescript-eslint/no-misused-promises': [
'error',
{
'checksVoidReturn': false,
},
],
// I like being able to use `'' + val` to coerce an unknown type to a string
'@typescript-eslint/restrict-plus-operands': 'off',
// I don't mind type coercion in string literal expressions
'@typescript-eslint/restrict-template-expressions': 'off',
// There are legitimate uses for empty functions
'@typescript-eslint/no-empty-function': 'off',
// Using `any[]` for rest arguments can sometimes be necessary
'@typescript-eslint/no-explicit-any': [
'warn',
{
'ignoreRestArgs': true,
},
],
// There are plenty of times where it's safe to use a Promise without error handling
'@typescript-eslint/no-floating-promises': 'off',
////////////////
// Code style //
////////////////
'comma-dangle': 'off',
'@typescript-eslint/comma-dangle': [
'error',
{
'arrays': 'always-multiline',
'objects': 'always-multiline',
'imports': 'always-multiline',
'exports': 'always-multiline',
'functions': 'only-multiline',
'enums': 'always-multiline',
'generics': 'always-multiline',
'tuples': 'always-multiline',
},
],
'@typescript-eslint/consistent-type-assertions': [
'error',
{
'assertionStyle': 'as',
},
],
'space-before-function-paren': 'off',
'@typescript-eslint/space-before-function-paren': [
'error',
{
'anonymous': 'always',
'named': 'never',
'asyncArrow': 'always',
},
],
},
},
{
files: ['src/assets/**/*.ts'],
env: {
browser: true,
es2021: true,
node: false,
},
rules: {
////////////////////////
// Debugging warnings //
////////////////////////
'no-console': [
'warn', {
'allow': [
'warn',
'error',
],
},
],
},
},
{
files: ['build/**/*.ts'],
env: {
browser: false,
es2021: true,
node: true,
},
},
{
files: ['schema/**/*.ts'],
env: {
browser: false,
es2021: true,
node: true,
},
},
{
files: ['spec/**/*.ts'],
env: {
browser: false,
es2021: true,
node: true,
},
},
],
};