-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
.eslintrc.js
195 lines (190 loc) · 6.54 KB
/
.eslintrc.js
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
const tsconfigs = [
'tsconfig.json',
'*/tsconfig.json',
'packages/*/tsconfig.json',
'packages/*/test/tsconfig.json',
]
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
project: tsconfigs,
},
env: {
es6: true,
node: true,
},
settings: {
'import/resolver': {
// Use eslint-import-resolver-typescript to obey "paths" in tsconfig.json.
typescript: {
directory: tsconfigs,
},
},
},
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'standard-with-typescript',
'plugin:import/recommended',
'plugin:import/typescript',
],
rules: {
'comma-dangle': ['error', 'always-multiline'],
'linebreak-style': ['error', 'unix'],
// Changed from error to warn and enabled ignoreEOLComments.
'no-multi-spaces': ['warn', {
ignoreEOLComments: true,
}],
// Changed from error to warn and adjusted options.
'no-multiple-empty-lines': ['warn', {
max: 2,
maxEOF: 1,
maxBOF: 1,
}],
'no-template-curly-in-string': 'off',
// Changed from 'after' to 'before'.
'operator-linebreak': ['error', 'before'],
// Changed from error and all 'never' to warn and switches 'never'.
'padded-blocks': ['warn', {
switches: 'never',
}],
// Changed from 'as-needed' to 'consistent-as-needed'.
'quote-props': ['error', 'consistent-as-needed'],
// Import
// Some packages have wrong type declarations.
'import/default': 'off',
'import/newline-after-import': 'warn',
// This rule disallows using both wildcard and selective imports from the same module.
'import/no-duplicates': 'off',
// Some packages have it wrong in type declarations (e.g. katex, marked).
'import/no-named-as-default-member': 'off',
// TypeScript
// Changed options.
'@typescript-eslint/ban-types': ['error', {
// Allow to use {} and object - they are actually useful.
types: {
'{}': false,
'object': false,
},
extendDefaults: true,
}],
'@typescript-eslint/class-literal-property-style': ['error', 'fields'],
// Changed from error to off.
'@typescript-eslint/consistent-type-definitions': 'off',
// Changed from error to off.
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-member-accessibility': ['error', {
accessibility: 'no-public',
overrides: {
parameterProperties: 'off',
},
}],
// Changed from warn to error and adjusted options.
'@typescript-eslint/explicit-module-boundary-types': ['error', {
allowArgumentsExplicitlyTypedAsAny: true,
}],
'@typescript-eslint/indent': ['error', 2, {
SwitchCase: 1,
VariableDeclarator: 1,
outerIIFEBody: 1,
MemberExpression: 1,
// Changed parameters from 1 to off.
FunctionDeclaration: { parameters: 'off', body: 1 },
// Changed parameters from 1 to off.
FunctionExpression: { parameters: 'off', body: 1 },
// Changed arguments from 1 to off.
CallExpression: { arguments: 'off' },
ArrayExpression: 1,
ObjectExpression: 1,
ImportDeclaration: 1,
// Changed from false to true.
flatTernaryExpressions: true,
ignoreComments: false,
}],
// Changed from error to warn.
'@typescript-eslint/lines-between-class-members': 'warn',
// Changed delimiter for type literals from none to comma.
// The reason is just aesthetic symmetry with object literals.
'@typescript-eslint/member-delimiter-style': ['error', {
multiline: { delimiter: 'comma', requireLast: true },
singleline: { delimiter: 'comma', requireLast: false },
overrides: {
interface: {
multiline: { delimiter: 'none' },
},
},
}],
'@typescript-eslint/member-ordering': 'warn',
// Changed from warn to off.
'@typescript-eslint/no-explicit-any': 'off',
// Changed from error to warn.
'@typescript-eslint/no-extra-semi': 'warn',
// It disallows using void even in valid cases.
'@typescript-eslint/no-invalid-void-type': 'off',
// Changed from error to warn.
'@typescript-eslint/no-namespace': 'warn',
// Changed from error to warn.
'@typescript-eslint/no-non-null-assertion': 'warn',
'@typescript-eslint/no-require-imports': 'error',
// Changed from error to warn.
'@typescript-eslint/no-unsafe-assignment': 'warn',
// Changed from error to warn.
'@typescript-eslint/no-unsafe-member-access': 'warn',
// Disabled in favour of the next rule.
'@typescript-eslint/no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars-experimental': 'error',
// Changed options.
'@typescript-eslint/no-use-before-define': ['error', {
functions: false,
typedefs: false,
}],
'@typescript-eslint/prefer-for-of': 'warn',
// Changed from error to warn.
'@typescript-eslint/prefer-includes': 'warn',
// Changed from error to warn.
'@typescript-eslint/prefer-regexp-exec': 'warn',
'@typescript-eslint/prefer-string-starts-ends-with': 'warn',
// It has too many false positives.
'@typescript-eslint/restrict-template-expressions': 'off',
// Changed from error to off.
'@typescript-eslint/strict-boolean-expressions': 'off',
'@typescript-eslint/switch-exhaustiveness-check': 'error',
// Changed from error to warn and adjusted options.
'@typescript-eslint/unbound-method': ['warn', {
ignoreStatic: true,
}],
},
overrides: [
{
files: ['*.test.ts?(x)'],
rules: {
// Allow to format arrays for parametrized tests as tables.
'array-bracket-spacing': 'off',
'comma-dangle': ['error', {
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
// Changed to not require comma in a multiline expect().
functions: 'only-multiline',
}],
'object-curly-spacing': 'off',
'no-multi-spaces': 'off',
'standard/array-bracket-even-spacing': 'off',
// Allow spaces inside expect( foo ).
'space-in-parens': 'off',
// jest.mock() must be above imports.
'import/first': 'off',
'@typescript-eslint/comma-spacing': 'off',
// False positive on expect() functions.
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-return': 'warn',
},
},
],
}