-
Notifications
You must be signed in to change notification settings - Fork 295
/
.eslintrc.js
277 lines (275 loc) · 10.6 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
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
module.exports = {
env: {
browser: true,
es6: true,
node: true
},
extends: ['prettier'],
ignorePatterns: ['*.js', 'vscode.*.d.ts', 'vscode.d.ts', 'types'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: [
'tsconfig.json',
'tsconfig.datascience-ui.json',
'src/tsconfig.extension.node.json',
'src/tsconfig.extension.web.json'
],
sourceType: 'module'
},
plugins: [
'eslint-plugin-import',
'eslint-plugin-jsdoc',
'eslint-plugin-no-null',
'eslint-plugin-prefer-arrow',
'eslint-plugin-react',
'@typescript-eslint',
'@typescript-eslint/tslint',
'eslint-plugin-local-rules',
'no-only-tests',
'header'
],
rules: {
'no-only-tests/no-only-tests': ['error', { block: ['test', 'suite'], focus: ['only'] }],
// Overriding ESLint rules with Typescript-specific ones
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-ignore': 'allow-with-description'
}
],
'@typescript-eslint/explicit-module-boundary-types': 'off',
'no-bitwise': 'off',
'no-dupe-class-members': 'off',
'@typescript-eslint/no-dupe-class-members': 'error',
'no-empty-function': 'off',
'@typescript-eslint/no-empty-function': ['error'],
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '_\\w*' }],
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': [
'error',
{
functions: false
}
],
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
'@typescript-eslint/no-var-requires': 'off',
'@typescript-eslint/no-floating-promises': [
'error',
{
ignoreVoid: true
}
],
// Other rules
'class-methods-use-this': 'off',
'func-names': 'off',
'import/extensions': 'off',
'import/namespace': 'off',
'import/no-extraneous-dependencies': 'off',
'import/no-unresolved': [
'error',
{
ignore: ['monaco-editor', 'vscode']
}
],
'import/prefer-default-export': 'off',
'linebreak-style': 'off',
'no-await-in-loop': 'off',
'no-console': 'off',
'no-control-regex': 'off',
'no-extend-native': 'off',
'no-multi-str': 'off',
'no-param-reassign': 'off',
'no-prototype-builtins': 'off',
'no-restricted-syntax': [
'error',
{
selector: 'ForInStatement',
message:
'for..in loops iterate over the entire prototype chain, which is virtually never what you want. Use Object.{keys,values,entries}, and iterate over the resulting array.'
},
{
selector: 'LabeledStatement',
message:
'Labels are a form of GOTO; using them makes code confusing and hard to maintain and understand.'
},
{
selector: 'WithStatement',
message: '`with` is disallowed in strict mode because it makes code impossible to predict and optimize.'
}
],
'no-template-curly-in-string': 'off',
'no-underscore-dangle': 'off',
'no-useless-escape': 'off',
'no-void': [
'error',
{
allowAsStatement: true
}
],
'operator-assignment': 'off',
'react/jsx-filename-extension': [
1,
{
extensions: ['.tsx']
}
],
'react/jsx-uses-vars': 'error',
'react/jsx-uses-react': 'error',
'no-restricted-imports': 'off',
// 'no-restricted-imports': [
'@typescript-eslint/no-restricted-imports': [
'error',
{
paths: ['lodash', 'lodash/noop'],
patterns: [
{
group: ['@jupyterlab/*'],
message: 'Convert to `import type` or dynamic import',
allowTypeImports: true
}
]
}
],
'import/no-restricted-paths': [
'error',
{
zones: [
{
target: './src/**[!test]**/**/*[!.unit].ts',
from: './src/test/**/*.ts',
message: 'Importing test modules from ./src/test into extension code is not allowed.'
},
{
target: './src/**[!test]**/**/*[!.node|.unit].ts',
from: './src/**/*.node.ts',
message: 'Importing node modules into non node files is not allowed.'
},
{
target: './src/**[!test]**/**/*[!.web|.unit].ts',
from: './src/**/*.web.ts',
message: 'Importing web modules into non web files is not allowed.'
},
{
target: './src/extension.node.ts',
from: './src/**/*.web.ts',
message: 'Importing web modules into extension.node.ts is not allowed.'
},
{
target: './src/extension.web.ts',
from: './src/**/*.node.ts',
message: 'Importing node modules into extension.web.ts is not allowed.'
},
{
target: './src/kernels/**/*[!.unit].ts',
from: './src/**[!platform,telemetry,kernels]**/**/*.ts',
message:
'Only modules from ./src/platform and ./src/telemetry can be imported into ./src/kernels.'
},
{
target: './src/notebooks/**/*[!.unit].ts',
from: './src/**[!platform,telemetry,kernels,notebooks]**/**/*.ts',
message:
'Only modules from ./src/platform, ./src/telemetry and ./src/kernels can be imported into ./src/notebooks.'
},
{
target: './src/interactive-window/**/*[!.unit].ts',
from: './src/**webview**/**/*.ts',
message:
'Only modules from ./src/platform, ./src/telemetry, ./src/kernels and ./src/notebooks can be imported into ./src/interactive-window.'
},
{
target: './src/**[!test,standalone,webviews]**/**/*.ts',
from: './src/webviews/**/*.ts',
message:
'Importing modules from ./src/webviews into core components (platform, kernels, notebooks, interactive-window) is not allowed.'
},
{
target: './src/**[!test,standalone]**/*.ts',
from: './src/standalone/**/*.ts',
message: 'Importing modules from ./src/standalone into other components is not allowed.'
},
{
target: './src/telemetry/**/**[!types]**.ts',
from: './src/**[!telemetry,platform]**/**/*.ts',
message: 'Importing non-telemetry modules into telemetry files is not allowed.'
},
{
target: './src/platform/**/*[!.unit].ts',
from: './src/**[!platform]**/**/*.ts',
message: 'Importing non-platform modules into platform files is not allowed.'
}
]
}
],
'local-rules/node-imports': ['error', { allow: ['events'] }],
'local-rules/dont-use-process': ['error'],
'local-rules/dont-use-fspath': ['error'],
'local-rules/dont-use-filename': ['error'],
strict: 'off',
'header/header': [
'error',
'line',
[' Copyright (c) Microsoft Corporation.', ' Licensed under the MIT License.'],
2
]
},
overrides: [
{
files: ['gulpfile.js', 'build/**/*.js'],
rules: {
'local-rules/node-imports': ['off'],
'local-rules/dont-use-process': ['off'],
'local-rules/dont-use-fspath': ['off'],
'local-rules/dont-use-filename': ['off'],
'import/no-restricted-paths': ['off']
}
},
{
files: ['**/*.test.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-restricted-imports': 'off'
}
},
{
files: ['src/test/**/*.ts'],
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-restricted-imports': 'off'
}
},
{
files: ['src/*.d.ts'],
rules: {
// Keep the *.d.ts files clean of any linting suppressions.
// These files will be distributed as is as part of the npm package.
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-vars': 'off'
}
}
],
settings: {
'import/extensions': ['.ts', '.tsx', '.d.ts', '.js', '.jsx'],
'import/external-module-folders': ['node_modules', 'node_modules/@types'],
'import/parsers': {
'@typescript-eslint/parser': ['.ts', '.tsx', '.d.ts']
},
'import/resolver': {
node: {
extensions: ['.ts', '.tsx', '.d.ts', '.js', '.jsx']
}
},
react: {
pragma: 'React',
version: 'detect'
},
propWrapperFunctions: ['forbidExtraProps', 'exact', 'Object.freeze'],
'import/core-modules': [],
'import/ignore': ['node_modules', '\\.(coffee|scss|css|less|hbs|svg|json)$']
}
};