-
Notifications
You must be signed in to change notification settings - Fork 405
/
Copy path.eslintrc
377 lines (364 loc) · 13.6 KB
/
.eslintrc
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
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"project": true
},
"plugins": ["jest", "@lwc/lwc-internal", "@typescript-eslint", "import", "header", "jsdoc"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended-type-checked",
"plugin:jsdoc/recommended-typescript"
],
"env": {
"es6": true
},
"reportUnusedDisableDirectives": true,
"rules": {
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"block-scoped-var": "error",
"no-alert": "error",
"no-buffer-constructor": "error",
"no-console": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-iterator": "error",
"no-lone-blocks": "error",
"no-proto": "error",
"no-new-require": "error",
"no-restricted-properties": [
"error",
{
"object": "arguments",
"property": "callee",
"message": "arguments.callee is deprecated"
},
{
"object": "global",
"property": "isFinite",
"message": "Please use Number.isFinite instead"
},
{
"object": "self",
"property": "isFinite",
"message": "Please use Number.isFinite instead"
},
{
"object": "window",
"property": "isFinite",
"message": "Please use Number.isFinite instead"
},
{
"object": "global",
"property": "isNaN",
"message": "Please use Number.isNaN instead"
},
{
"object": "self",
"property": "isNaN",
"message": "Please use Number.isNaN instead"
},
{
"object": "window",
"property": "isNaN",
"message": "Please use Number.isNaN instead"
},
{
"property": "__defineGetter__",
"message": "Please use Object.defineProperty instead."
},
{
"property": "__defineSetter__",
"message": "Please use Object.defineProperty instead."
},
{
"object": "Math",
"property": "pow",
"message": "Use the exponentiation operator (**) instead."
},
{
"object": "globalThis",
"property": "lwcRuntimeFlags",
"message": "Use the bare global lwcRuntimeFlags instead."
}
],
"no-self-compare": "error",
"no-undef-init": "error",
"no-useless-computed-key": "error",
"no-useless-return": "error",
"prefer-const": [
"error",
{
"destructuring": "any",
"ignoreReadBeforeAssign": true
}
],
"template-curly-spacing": "error",
"yoda": "error",
"@lwc/lwc-internal/no-invalid-todo": "error",
"import/order": [
"error",
{
"groups": [
"builtin",
"external",
"internal",
"parent",
"index",
"sibling",
"object",
"type"
]
}
],
"no-restricted-imports": [
"error",
{
"name": "@lwc/features",
"importNames": ["lwcRuntimeFlags", "runtimeFlags", "default"],
"message": "Do not directly import runtime flags from @lwc/features. Use the global lwcRuntimeFlags variable instead."
}
],
"header/header": [
2,
"block",
[
"",
{
"pattern": "^ \\* Copyright \\(c\\) \\d{4}, ([sS]alesforce.com, inc|Salesforce, Inc)\\.$",
// This copyright text should match the text used in the rollup config
"template": " * Copyright (c) 2024, Salesforce, Inc."
},
" * All rights reserved.",
" * SPDX-License-Identifier: MIT",
" * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT",
" "
]
],
/*
* TODO: Address violations and re-enable these rules
*/
// Enums are a pain to deal with...
"@typescript-eslint/no-unsafe-enum-comparison": "off",
// We might just want to leave this one disabled
"@typescript-eslint/unbound-method": "off",
// We use objects in template strings (e.g. `${vm}`) a lot - that's not that helpful for
// the user because it all just becomes "[object Object]"
"@typescript-eslint/no-base-to-string": "off",
"@typescript-eslint/restrict-template-expressions": "off",
// The following all derive from our liberal use of `any`
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-redundant-type-constituents": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off",
"@typescript-eslint/no-unsafe-assignment": "off",
"@typescript-eslint/no-unsafe-return": "off",
"@typescript-eslint/no-unsafe-argument": "off",
// This rule returns false positives with ! assertions, even with strictNullChecks(https://github.com/typescript-eslint/typescript-eslint/issues/1618) on it was complaining
"@typescript-eslint/no-unnecessary-type-assertion": "off",
"jsdoc/require-jsdoc": ["warn", { "publicOnly": true }],
"jsdoc/check-indentation": "error",
"jsdoc/check-syntax": "error",
"jsdoc/informative-docs": "error",
"jsdoc/no-bad-blocks": [
"error",
{ "ignore": ["__PURE__", "__PURE__@", "ts-expect-error", "ts-ignore"] }
],
"jsdoc/no-blank-blocks": "error",
"jsdoc/no-defaults": "error",
"jsdoc/no-types": "error",
"jsdoc/require-description": "error",
"jsdoc/require-example": "error",
"jsdoc/require-hyphen-before-param-description": ["error", "never"],
"jsdoc/require-throws": "error",
"jsdoc/sort-tags": "error"
},
"overrides": [
{
"files": [
"**/__tests__/**",
"packages/@lwc/*/scripts/**",
// Just a weird edge case of a file...
"packages/@lwc/synthetic-shadow/index.js"
],
"parserOptions": {
"project": "./tsconfig.eslint.json"
}
},
{
// Not covered by any tsconfig, so typed rules won't work, but we don't need them anyway
"files": ["jest.config.js"],
"extends": ["plugin:@typescript-eslint/disable-type-checked"]
},
{
// Some tooling still uses require...
"files": [
"**/scripts/**",
"jest.config.js",
"packages/@lwc/integration-tests/src/components/**/*.spec.js"
],
"rules": {
"@typescript-eslint/no-var-requires": "off"
}
},
{
"files": ["packages/lwc/**"],
"rules": {
"no-restricted-imports": "off"
}
},
{
"files": [
"packages/@lwc/engine-core/**",
"packages/@lwc/engine-dom/**",
"packages/@lwc/synthetic-shadow/**"
],
"rules": {
"@lwc/lwc-internal/no-global-node": "error",
"prefer-rest-params": "off",
"prefer-spread": "off"
}
},
{
"files": ["**/__tests__/**", "**/__mocks__/**", "packages/@lwc/integration-karma/**"],
"env": {
"jest": true,
"es2021": true
},
"rules": {
"jest/no-focused-tests": "error",
"jest/valid-expect": "error",
"jest/valid-expect-in-promise": "error"
}
},
{
"files": ["packages/@lwc/integration-tests/**"],
"globals": {
"$": true,
"browser": true
}
},
{
"files": ["./*.js", "**/scripts/**", "jest.config.js"],
"env": {
"node": true,
"jest": true
},
"rules": {
"no-console": "off"
}
},
{
"files": ["packages/@lwc/perf-benchmarks/**"],
"globals": {
"after": true,
"before": true,
"benchmark": true,
"run": true
}
},
{
"files": [
"packages/@lwc/integration-tests/src/**/!(*.spec.js)",
"packages/@lwc/integration-karma/test/**",
"packages/@lwc/integration-karma/test-hydration/**"
],
"rules": {
"header/header": "off"
}
},
{
// Don't complain about 3rd party JSDoc
"files": ["packages/@lwc/synthetic-shadow/src/3rdparty/**"],
"rules": {
"jsdoc/check-alignment": "off",
"jsdoc/check-indentation": "off",
"jsdoc/check-syntax": "off",
"jsdoc/check-values": "off",
"jsdoc/informative-docs": "off",
"jsdoc/no-bad-blocks": "off",
"jsdoc/no-blank-blocks": "off",
"jsdoc/no-defaults": "off",
"jsdoc/no-types": "off",
"jsdoc/require-description": "off",
"jsdoc/require-hyphen-before-param-description": "off",
"jsdoc/require-jsdoc": "off",
"jsdoc/require-param": "off",
"jsdoc/require-throws": "off",
"jsdoc/sort-tags": "off"
}
},
{
"files": [
// Private packages - documentation isn't required (but should still be good, if present)
"packages/@lwc/integration-karma/**",
"packages/@lwc/integration-tests/**",
"packages/@lwc/perf-benchmarks-components/**",
"packages/@lwc/perf-benchmarks/**",
// TODO [W-13278716]: All top-level exports should have JSDOC enforced
"packages/@lwc/engine-core/**",
// "packages/@lwc/engine-server/**",
// Package-level exports are documented, but not all file-level exports are, so we
// should keep these disabled for now
"packages/@lwc/babel-plugin-component/**",
"packages/@lwc/engine-dom/**",
"packages/@lwc/engine-server/**",
"packages/@lwc/module-resolver/**",
"packages/@lwc/shared/**",
"packages/@lwc/style-compiler/**",
"packages/@lwc/synthetic-shadow/**",
"packages/@lwc/template-compiler/**"
],
"rules": {
"jsdoc/require-jsdoc": "off",
// TODO [W-13278716]: All JSDoc should fully describe functions
"jsdoc/require-description": "off",
"jsdoc/require-example": "off",
"jsdoc/require-param-description": "off",
"jsdoc/require-returns": "off",
"jsdoc/require-throws": "off"
}
},
// TODO [W-13278716]: Not everything *needs* an example, so I'll probably disable the rule
// when the ticket is complete, but for now I want to enable by default and disable as I go.
{
"files": [
"packages/@lwc/babel-plugin-component/**",
"packages/@lwc/compiler/**",
"packages/@lwc/errors/**",
"packages/@lwc/engine-dom/**",
"packages/@lwc/rollup-plugin/**",
"packages/@lwc/wire-service/**"
],
"rules": {
"jsdoc/require-example": "off"
}
},
{
// These files aren't JS files, but are directives used to selectively run test fixtures.
// We use eslint to break CI if they are accidentally committed. Note that lint-staged
// uses a different config to prevent them from being committed.
"files": ["**/.only"],
"extends": ["plugin:@typescript-eslint/disable-type-checked"],
"rules": {
"header/header": "off",
"@lwc/lwc-internal/forbidden-filename": "error"
}
},
{
// These files aren't JS files, but are directives used to skip specific test fixtures.
// We want to know if they've been accidentally committed, but not break CI, as we may
// legitimately want to skip certain tests. Note that lint-staged uses a different config
// to prevent them from being committed.
"files": ["**/.skip"],
"extends": ["plugin:@typescript-eslint/disable-type-checked"],
"rules": {
"header/header": "off",
"@lwc/lwc-internal/forbidden-filename": "off"
}
}
]
}