-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.cjs
401 lines (397 loc) · 17.6 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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
// Source: https://github.com/color-js/color.js/blob/main/.eslintrc.cjs
// Commit c04f61cc1ae128c5ae052e45b1722a37bbe862e1
module.exports = {
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"ecmaFeatures": {
"impliedStrict": true,
},
},
"env": {
"browser": true,
"es2020": true,
},
"plugins": ["@typescript-eslint", "@stylistic"],
"rules": {
/**
* ESLint rules: https://eslint.org/docs/latest/rules/
* Based off of: https://github.com/eslint/eslint/blob/v8.54.0/packages/js/src/configs/eslint-recommended.js
*/
// Require `super()` calls in constructors
// https://eslint.org/docs/latest/rules/constructor-super
"constructor-super": 1,
// Enforce curly braces for all control statements
// https://eslint.org/docs/latest/rules/curly
"curly": 1,
// Enforce “for” loop update clause moving the counter in the right direction
// https://eslint.org/docs/latest/rules/for-direction
"for-direction": 1,
// Enforce `return` statements in getters
// https://eslint.org/docs/latest/rules/getter-return
"getter-return": 1,
// Disallow using an async function as a Promise executor
// https://eslint.org/docs/latest/rules/no-async-promise-executor
"no-async-promise-executor": 1,
// Disallow `let`/const`/function`/`class` in `case`/`default` clauses
// https://eslint.org/docs/latest/rules/no-case-declarations
"no-case-declarations": 1,
// Disallow reassigning class members
// https://eslint.org/docs/latest/rules/no-class-assign
"no-class-assign": 1,
// Disallow comparing against -0
// https://eslint.org/docs/latest/rules/no-compare-neg-zero
"no-compare-neg-zero": 1,
// Disallow reassigning `const` variables
// https://eslint.org/docs/latest/rules/no-const-assign
"no-const-assign": 1,
// Disallow constant expressions in conditions
// https://eslint.org/docs/latest/rules/no-constant-condition
"no-constant-condition": 1,
// Disallow control characters in regular expressions
// https://eslint.org/docs/latest/rules/no-control-regex
"no-control-regex": 1,
// Disallow the use of `debugger`
// https://eslint.org/docs/latest/rules/no-debugger
"no-debugger": 1,
// Disallow deleting variables
// https://eslint.org/docs/latest/rules/no-delete-var
"no-delete-var": 1,
// Disallow duplicate arguments in `function` definitions
// https://eslint.org/docs/latest/rules/no-dupe-args
"no-dupe-args": 1,
// Disallow duplicate class members
// https://eslint.org/docs/latest/rules/no-dupe-class-members
"no-dupe-class-members": 1,
// Disallow duplicate conditions in if-else-if chains
// https://eslint.org/docs/latest/rules/no-dupe-else-if
"no-dupe-else-if": 1,
// Disallow duplicate keys in object literals
// https://eslint.org/docs/latest/rules/no-dupe-keys
"no-dupe-keys": 1,
// Disallow duplicate case labels
// https://eslint.org/docs/latest/rules/no-duplicate-case
"no-duplicate-case": 1,
// Disallow empty character classes in regular expressions
// https://eslint.org/docs/latest/rules/no-empty-character-class
"no-empty-character-class": 1,
// Disallow empty destructuring patterns
// https://eslint.org/docs/latest/rules/no-empty-pattern
"no-empty-pattern": 1,
// Disallow reassigning exceptions in `catch` clauses
// https://eslint.org/docs/latest/rules/no-ex-assign
"no-ex-assign": 1,
// Disallow unnecessary boolean casts
// https://eslint.org/docs/latest/rules/no-extra-boolean-cast
"no-extra-boolean-cast": 1,
// Disallow fallthrough of `case` statements
// unless marked with a comment that matches `/falls?\s?through/i` regex
// https://eslint.org/docs/latest/rules/no-fallthrough
"no-fallthrough": 1,
// Disallow reassigning `function` declarations
// https://eslint.org/docs/latest/rules/no-func-assign
"no-func-assign": 1,
// Disallow assignments to native objects or read-only global variables
// https://eslint.org/docs/latest/rules/no-global-assign
"no-global-assign": 1,
// Disallow assigning to imported bindings
// https://eslint.org/docs/latest/rules/no-import-assign
"no-import-assign": 1,
// Disallow invalid regular expression strings in `RegExp` constructors
// https://eslint.org/docs/latest/rules/no-invalid-regexp
"no-invalid-regexp": 1,
// Disallow whitespace that is not `tab` or `space` except in string literals
// https://eslint.org/docs/latest/rules/no-irregular-whitespace
"no-irregular-whitespace": 1,
// Disallow characters which are made with multiple code points in character class syntax
// https://eslint.org/docs/latest/rules/no-misleading-character-class
"no-misleading-character-class": 1,
// Disallow `new` operators with the `Symbol` object
// https://eslint.org/docs/latest/rules/no-new-symbol
"no-new-symbol": 1,
// Disallow `\8` and `\9` escape sequences in string literals
// https://eslint.org/docs/latest/rules/no-nonoctal-decimal-escape
"no-nonoctal-decimal-escape": 1,
// Disallow calling global object properties as functions
// https://eslint.org/docs/latest/rules/no-obj-calls
"no-obj-calls": 1,
// Disallow octal literals
// https://eslint.org/docs/latest/rules/no-octal
"no-octal": 1,
// Disallow calling some `Object.prototype` methods directly on objects
// https://eslint.org/docs/latest/rules/no-prototype-builtins
"no-prototype-builtins": 1,
// Disallow multiple spaces in regular expressions
// https://eslint.org/docs/latest/rules/no-regex-spaces
"no-regex-spaces": 1,
// Disallow assignments where both sides are exactly the same
// https://eslint.org/docs/latest/rules/no-self-assign
"no-self-assign": 1,
// Disallow identifiers from shadowing restricted names
// https://eslint.org/docs/latest/rules/no-shadow-restricted-names
"no-shadow-restricted-names": 1,
// Disallow `this`/`super` before calling `super()` in constructors
// https://eslint.org/docs/latest/rules/no-this-before-super
"no-this-before-super": 1,
// Disallow the use of undeclared variables unless mentioned in `/*global */` comments
// https://eslint.org/docs/latest/rules/no-undef
// TODO: At-risk; subject to change.
"no-undef": 1,
// Disallow confusing multiline expressions
// https://eslint.org/docs/latest/rules/no-unexpected-multiline
// TODO: At-risk; subject to change.
"no-unexpected-multiline": 1,
// Disallow unreachable code after `return`, `throw`, `continue`, and `break` statements
// https://eslint.org/docs/latest/rules/no-unreachable
"no-unreachable": 1,
// Disallow control flow statements in `finally` blocks
// https://eslint.org/docs/latest/rules/no-unsafe-finally
"no-unsafe-finally": 1,
// Disallow negating the left operand of relational operators
// https://eslint.org/docs/latest/rules/no-unsafe-negation
"no-unsafe-negation": 1,
// Disallow use of optional chaining in contexts where the `undefined` value is not allowed
// https://eslint.org/docs/latest/rules/no-unsafe-optional-chaining
"no-unsafe-optional-chaining": 1,
// Disallow unused labels
// https://eslint.org/docs/latest/rules/no-unused-labels
"no-unused-labels": 1,
// Disallow useless backreferences in regular expressions
// https://eslint.org/docs/latest/rules/no-useless-backreference
"no-useless-backreference": 1,
// Disallow unnecessary calls to `.call()` and `.apply()`
// https://eslint.org/docs/latest/rules/no-useless-call
"no-useless-call": 1,
// Disallow unnecessary `catch` clauses
// https://eslint.org/docs/latest/rules/no-useless-catch
"no-useless-catch": 1,
// Disallow unnecessary escape characters
// https://eslint.org/docs/latest/rules/no-useless-escape
"no-useless-escape": 1,
// Disallow `with` statements
// https://eslint.org/docs/latest/rules/no-with
"no-with": 1,
// Require generator functions to contain `yield`
// https://eslint.org/docs/latest/rules/require-yield
"require-yield": 1,
// Require calls to `isNaN()` when checking for `NaN`
// https://eslint.org/docs/latest/rules/use-isnan
"use-isnan": 1,
// Enforce comparing `typeof` expressions against valid strings
// https://eslint.org/docs/latest/rules/valid-typeof
"valid-typeof": 1,
/**
* ESLint Stylistic rules: https://eslint.style/packages/default#rules
*/
// Enforce a space before and after `=>` in arrow functions
// https://eslint.style/rules/default/arrow-spacing
"@stylistic/arrow-spacing": 1,
// Enforce consistent brace style for blocks
// https://eslint.style/rules/default/brace-style
"@stylistic/brace-style": [1, "stroustrup"],
// Enforce no space before and one or more spaces after a comma
// https://eslint.style/rules/default/comma-spacing
"@stylistic/comma-spacing": 1,
// Require newline at the end of files
// https://eslint.style/rules/default/eol-last
"@stylistic/eol-last": 1,
// Enforce consistent indentation
// https://eslint.style/rules/default/indent
"@stylistic/indent": [1, "tab", { "SwitchCase": 1, "outerIIFEBody": 0 }],
// Enforce consistent spacing before and after keywords
// https://eslint.style/rules/default/keyword-spacing
"@stylistic/keyword-spacing": 1,
// Disallow unnecessary semicolons
// https://eslint.style/rules/default/no-extra-semi
"@stylistic/no-extra-semi": 1,
// Disallow mixed spaces and tabs for indentation
// https://eslint.style/rules/default/no-mixed-spaces-and-tabs
"@stylistic/no-mixed-spaces-and-tabs": [1, "smart-tabs"],
// Disallow trailing whitespace at the end of lines
// https://eslint.style/rules/default/no-trailing-spaces
"@stylistic/no-trailing-spaces": 1,
// Enforce the consistent use of double quotes
// https://eslint.style/rules/default/quotes
"@stylistic/quotes": [
1,
"double",
{ "avoidEscape": true, "allowTemplateLiterals": true },
],
// Require semicolons instead of ASI
// https://eslint.style/rules/default/semi
"@stylistic/semi": 1,
// Enforce at least one space before blocks
// https://eslint.style/rules/default/space-before-blocks
"@stylistic/space-before-blocks": 1,
// Enforce a space before `function` definition opening parenthesis
// https://eslint.style/rules/default/space-before-function-paren
"@stylistic/space-before-function-paren": 1,
// Require spaces around infix operators (e.g. `+`, `=`, `?`, `:`)
// https://eslint.style/rules/default/space-infix-ops
"@stylistic/space-infix-ops": 1,
// Enforce a space after unary word operators (`new`, `delete`, `typeof`, `void`, `yield`)
// https://eslint.style/rules/default/space-unary-ops
"@stylistic/space-unary-ops": 1,
// Enforce whitespace after the `//` or `/*` in a comment
// https://eslint.style/rules/default/spaced-comment
"@stylistic/spaced-comment": [
1,
"always",
{ "block": { "exceptions": ["*"] } },
],
/**
* typescript-eslint rules: https://typescript-eslint.io/rules/
* Based off of: https://github.com/typescript-eslint/typescript-eslint/blob/v6.13.1/packages/eslint-plugin/src/configs/recommended.ts
*/
// Disallow `@ts-<directive>` comments
// https://typescript-eslint.io/rules/ban-ts-comment
"@typescript-eslint/ban-ts-comment": 1,
// Disallow certain built-in types
// https://typescript-eslint.io/rules/ban-types
"@typescript-eslint/ban-types": 1,
// Disallow generic `Array` constructors
// https://typescript-eslint.io/rules/no-array-constructor
"@typescript-eslint/no-array-constructor": 1,
// Disallow duplicate enum member values
// https://typescript-eslint.io/rules/no-duplicate-enum-values
"@typescript-eslint/no-duplicate-enum-values": 1,
// Disallow extra non-null assertions
// https://typescript-eslint.io/rules/no-extra-non-null-assertion
"@typescript-eslint/no-extra-non-null-assertion": 1,
// Enforce valid definition of `new` and `constructor`
// https://typescript-eslint.io/rules/no-misused-new
"@typescript-eslint/no-misused-new": 1,
// Disallow TypeScript namespaces
// https://typescript-eslint.io/rules/no-namespace
"@typescript-eslint/no-namespace": 1,
// Disallow non-null assertions after an optional chain expression
// https://typescript-eslint.io/rules/no-non-null-asserted-optional-chain
"@typescript-eslint/no-non-null-asserted-optional-chain": 1,
// Disallow aliasing `this`
// https://typescript-eslint.io/rules/no-this-alias
"@typescript-eslint/no-this-alias": 1,
// Disallow unnecessary constraints on generic types
// https://typescript-eslint.io/rules/no-unnecessary-type-constraint
"@typescript-eslint/no-unnecessary-type-constraint": 1,
// Disallow unsafe declaration merging
// https://typescript-eslint.io/rules/no-unsafe-declaration-merging
"@typescript-eslint/no-unsafe-declaration-merging": 1,
// Disallow `require` statements except in import statements
// https://typescript-eslint.io/rules/no-var-requires
"@typescript-eslint/no-var-requires": 1,
// Enforce the use of `as const` over literal type
// https://typescript-eslint.io/rules/prefer-as-const
"@typescript-eslint/prefer-as-const": 1,
// Disallow certain triple slash directives in favor of ES6-style import declarations
// https://typescript-eslint.io/rules/triple-slash-reference
"@typescript-eslint/triple-slash-reference": 1,
/**
* Based off of: https://github.com/typescript-eslint/typescript-eslint/blob/v6.13.1/packages/eslint-plugin/src/configs/stylistic.ts
*/
// Require that function overload signatures be consecutive
// https://typescript-eslint.io/rules/adjacent-overload-signatures
"@typescript-eslint/adjacent-overload-signatures": 1,
// Require consistently using `T[]` for arrays instead of `Array<T>`
// https://typescript-eslint.io/rules/array-type
"@typescript-eslint/array-type": 1,
// Disallow `// tslint:<rule-flag>` comments
// https://typescript-eslint.io/rules/ban-tslint-comment
"@typescript-eslint/ban-tslint-comment": 1,
// Enforce that literals on classes are exposed in a consistent style
// https://typescript-eslint.io/rules/class-literal-property-style
"@typescript-eslint/class-literal-property-style": 1,
// Enforce specifying generic type arguments on type annotation or constructor name of a constructor call
// https://typescript-eslint.io/rules/consistent-generic-constructors
"@typescript-eslint/consistent-generic-constructors": 1,
// Require the `Record` type instead of index signatures
// https://typescript-eslint.io/rules/consistent-indexed-object-style
"@typescript-eslint/consistent-indexed-object-style": 1,
// Enforce consistent usage of type assertions
// https://typescript-eslint.io/rules/consistent-type-assertions
"@typescript-eslint/consistent-type-assertions": 1,
// Enforce type definitions to consistently use `interface` instead of `type`
// https://typescript-eslint.io/rules/consistent-type-definitions
"@typescript-eslint/consistent-type-definitions": 1,
// Disallow non-null assertion in locations that may be confusing
// https://typescript-eslint.io/rules/no-confusing-non-null-assertion
"@typescript-eslint/no-confusing-non-null-assertion": 1,
// Disallow the declaration of empty interfaces
// https://typescript-eslint.io/rules/no-empty-interface
"@typescript-eslint/no-empty-interface": 1,
// Disallow explicit type declarations for variables or parameters initialized to a number, string, or boolean
// https://typescript-eslint.io/rules/no-inferrable-types
"@typescript-eslint/no-inferrable-types": 1,
// Enforce the use of `for-of` loop over the standard `for` loop where possible
// https://typescript-eslint.io/rules/prefer-for-of
"@typescript-eslint/prefer-for-of": 1,
// Enforce using function types instead of interfaces with call signatures
// https://typescript-eslint.io/rules/prefer-function-type
"@typescript-eslint/prefer-function-type": 1,
// Require using `namespace` keyword over `module` keyword to declare custom TypeScript modules
// https://typescript-eslint.io/rules/prefer-namespace-keyword
"@typescript-eslint/prefer-namespace-keyword": 1,
},
"overrides": [
{
// Based off of: https://github.com/typescript-eslint/typescript-eslint/blob/v6.13.1/packages/eslint-plugin/src/configs/eslint-recommended.ts
files: ["*.ts"],
rules: {
// Disable ESLint rules already handled by TypeScript
"constructor-super": 0, // ts(2335) & ts(2377)
"getter-return": 0, // ts(2378)
"no-const-assign": 0, // ts(2588)
"no-dupe-args": 0, // ts(2300)
"no-dupe-class-members": 0, // ts(2393) & ts(2300)
"no-dupe-keys": 0, // ts(1117)
"no-func-assign": 0, // ts(2630)
"no-import-assign": 0, // ts(2632) & ts(2540)
"no-new-symbol": 0, // ts(7009)
"no-obj-calls": 0, // ts(2349)
"no-redeclare": 0, // ts(2451)
"no-setter-return": 0, // ts(2408)
"no-this-before-super": 0, // ts(2376) & ts(17009)
"no-undef": 0, // ts(2304) & ts(2552)
"no-unreachable": 0, // ts(7027)
"no-unsafe-negation": 0, // ts(2365) & ts(2322) & ts(2358)
// Enable ESLint rules that make sense in TypeScript files
"no-var": 1, // ts transpiles let/const to var, so no need for vars any more
"prefer-const": 1, // ts provides better types with const
"prefer-rest-params": 1, // ts provides better types with rest args over arguments
"prefer-spread": 1, // ts transpiles spread to apply, so no need for manual apply
},
},
{
"files": [
"apps/**/*",
"assets/**/*",
"get/**/*",
"notebook/**/*",
"scripts/**/*",
"tests/**/*",
],
"rules": {
// These directories reference implicit global variables
"no-undef": 0,
},
},
{
"files": ["*.cjs"],
"env": {
"browser": false,
"node": true,
},
"rules": {
// Allow `require()` usage in CJS files
"@typescript-eslint/no-var-requires": 0,
},
},
{
"files": ["types/test/**/*"],
"rules": {
// Allow `@ts-expect-error` comments in TypeScript test files
"@typescript-eslint/ban-ts-comment": 0,
},
},
],
};