-
Notifications
You must be signed in to change notification settings - Fork 33
/
eslint.config.mjs
128 lines (123 loc) · 5.78 KB
/
eslint.config.mjs
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
import eslint from '@eslint/js';
import tsEslint from 'typescript-eslint';
import stylisticEslint from '@stylistic/eslint-plugin';
export default tsEslint.config(
eslint.configs.recommended,
...tsEslint.configs.recommended,
...tsEslint.configs.stylistic,
{
plugins: {
'@stylistic': stylisticEslint,
},
rules: {
// RELAX RECOMMENDED RULES
'prefer-const': [
'error',
{
destructuring: 'all', // Allow `let` when at least one destructured element will be changed
},
],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/consistent-indexed-object-style': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
// ADDITIONAL RULES - GENERAL
'eqeqeq': 'error', // Forbid using `==`, enforce `===`
'no-eval': 'error', // Forbid using `eval`
'no-new-wrappers': 'error',
'no-restricted-syntax': [
'error',
{
selector: 'ExportDefaultDeclaration',
message: 'Default exports are not allowed',
},
],
'no-var': 'error', // Forbid using `var`
'no-void': 'error', // Forbid using `void 0`, use `undefined` instead
'no-throw-literal': 'error', // Forbid throwing anything that's not Error, e.g. `throw 'Blabla'`
'@typescript-eslint/prefer-namespace-keyword': 'error', // Forbid `module` keyword
// ADDITIONAL RULES - @stylistic
'@stylistic/indent': ['error', 4],
'@stylistic/semi': 'error', // Enforce trailing semicolons, including after type definitions
'@stylistic/comma-dangle': ['error', { // Enforce comma after last listed item when closing ] or } is on the next line
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
enums: 'always-multiline',
tuples: 'always-multiline',
functions: 'only-multiline', // This would look ugly after JSX syntax in `map`
}],
'@stylistic/eol-last': 'error', // Enforce newline at the end of file
'@stylistic/quotes': [
'error',
'single',
{
// Enforce single quotes: 'hello'
avoidEscape: true,
allowTemplateLiterals: true,
},
],
'@stylistic/brace-style': [
'error',
'1tbs',
{
// Enforce line break after { and before }
allowSingleLine: true,
},
],
'@stylistic/member-delimiter-style': [
'error',
{
// Enforce commas in interfaces and types
multiline: {
delimiter: 'comma',
requireLast: true,
},
singleline: {
delimiter: 'comma',
requireLast: false,
},
multilineDetection: 'brackets',
},
],
// ADDITIONAL RULES - @stylistic - SPACING
'@stylistic/array-bracket-spacing': 'error', // Forbid spaces in array: [_1, 2_]
'@stylistic/arrow-spacing': 'error', // Enforce space in lambda function: x_=>_x**2
'@stylistic/block-spacing': 'error', // Enforce space in one-line block: () => {_return true;_}
'@stylistic/comma-spacing': 'error', // Enforce space after comma: [1,_2,_3]
'@stylistic/computed-property-spacing': 'error', // Forbid spaces in indexing: a[_0_]
'@stylistic/function-call-spacing': 'error', // Forbid space when calling function: f_(0)
'@stylistic/key-spacing': 'error', // Enforce space after colon in object: { a:_1, b:_2 }
'@stylistic/keyword-spacing': 'error', // Enforce space after `if`, `try`, etc.: if_(true)
'@stylistic/no-multi-spaces': 'error', // Forbid more than one space: x =__5
'@stylistic/no-trailing-spaces': 'error', // No spaces at the end of line: foo()_
'@stylistic/object-curly-spacing': ['error', 'always'], // Enforce spaces in object: {_a: 1, b: 2_}
'@stylistic/semi-spacing': 'error', // Enforce space after semicolon: for (let i = 0;_i < n;_i++)
'@stylistic/space-before-blocks': 'error', // Enforce space before block: if (true)_{}
'@stylistic/space-before-function-paren': [
'error',
{
anonymous: 'always', // function_() {}
named: 'never', // function foo_() {}
asyncArrow: 'always', // async_() {}
},
],
'@stylistic/space-in-parens': 'error', // Forbid spaces in parentheses: (_1, 2_)
'@stylistic/space-infix-ops': 'error', // Enforce space around infix operators: 1_+_2
'@stylistic/spaced-comment': [
'error',
'always',
{
// Enforce space in comment: /**_Comment_*/ //_comment
block: {
balanced: true,
},
},
],
'@stylistic/type-annotation-spacing': 'error', // Enforce space after type annotation colon: let x:_string;
},
},
);