@arcgis/eslint-config 5.2.0-next.124 → 5.2.0-next.125

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,172 @@
1
- import markdown from "@eslint/markdown";
1
+ import { d as disabledRules } from "../chunks/disabledRules.js";
2
2
  import jsdocPlugin from "eslint-plugin-jsdoc";
3
3
  import perfectionistPlugin from "eslint-plugin-perfectionist";
4
4
  import reactJsxPlugin from "eslint-plugin-react-jsx";
5
5
  import regexpPlugin from "eslint-plugin-regexp";
6
6
  import unicornPlugin from "eslint-plugin-unicorn";
7
7
  import { join } from "node:path";
8
- import tsEslint from "typescript-eslint";
9
8
  import { corePlugin } from "../plugins/core/index.js";
9
+ const disabledCorePackageJsonRules = [
10
+ // @typescript/native-preview temporarily uses the `beta` tag rather than a semver range.
11
+ "package-json/valid-devDependencies"
12
+ ];
13
+ const disabledCoreDeclarationRules = [
14
+ // We can't enforce names in third-party libraries
15
+ "@typescript-eslint/naming-convention"
16
+ ];
17
+ const disabledCoreOverrides = [
18
+ "@typescript-eslint/adjacent-overload-signatures",
19
+ "@typescript-eslint/array-type",
20
+ "@typescript-eslint/await-thenable",
21
+ "@typescript-eslint/consistent-generic-constructors",
22
+ "@typescript-eslint/consistent-indexed-object-style",
23
+ "@typescript-eslint/consistent-type-assertions",
24
+ "@typescript-eslint/consistent-type-exports",
25
+ "@typescript-eslint/dot-notation",
26
+ "@typescript-eslint/max-params",
27
+ // Core is not yet using strictFunctionTypes so can't use this rule yet
28
+ "@typescript-eslint/method-signature-style",
29
+ "@typescript-eslint/no-confusing-non-null-assertion",
30
+ "@typescript-eslint/no-duplicate-type-constituents",
31
+ "@typescript-eslint/no-dynamic-delete",
32
+ "@typescript-eslint/no-empty-function",
33
+ "@typescript-eslint/no-empty-object-type",
34
+ "@typescript-eslint/no-explicit-any",
35
+ "@typescript-eslint/no-extra-non-null-assertion",
36
+ "@typescript-eslint/no-extraneous-class",
37
+ "@typescript-eslint/no-implied-eval",
38
+ "@typescript-eslint/no-inferrable-types",
39
+ "@typescript-eslint/no-misused-new",
40
+ "@typescript-eslint/no-misused-spread",
41
+ "@typescript-eslint/no-non-null-asserted-nullish-coalescing",
42
+ "@typescript-eslint/no-non-null-asserted-optional-chain",
43
+ "@typescript-eslint/no-redundant-type-constituents",
44
+ "@typescript-eslint/no-unnecessary-boolean-literal-compare",
45
+ "@typescript-eslint/no-unnecessary-condition",
46
+ "@typescript-eslint/no-unnecessary-template-expression",
47
+ "@typescript-eslint/no-unnecessary-type-constraint",
48
+ "@typescript-eslint/no-unnecessary-type-conversion",
49
+ "@typescript-eslint/no-unsafe-argument",
50
+ "@typescript-eslint/no-unsafe-assignment",
51
+ "@typescript-eslint/no-unsafe-call",
52
+ "@typescript-eslint/no-unsafe-function-type",
53
+ "@typescript-eslint/no-unsafe-member-access",
54
+ "@typescript-eslint/no-useless-empty-export",
55
+ "@typescript-eslint/no-wrapper-object-types",
56
+ "@typescript-eslint/non-nullable-type-assertion-style",
57
+ "@typescript-eslint/only-throw-error",
58
+ "@typescript-eslint/prefer-as-const",
59
+ "@typescript-eslint/prefer-function-type",
60
+ "@typescript-eslint/prefer-promise-reject-errors",
61
+ "@typescript-eslint/prefer-reduce-type-parameter",
62
+ "@typescript-eslint/prefer-return-this-type",
63
+ "@typescript-eslint/promise-function-async",
64
+ "@typescript-eslint/related-getter-setter-pairs",
65
+ "@typescript-eslint/require-array-sort-compare",
66
+ "@typescript-eslint/require-await",
67
+ "@typescript-eslint/restrict-plus-operands",
68
+ "@typescript-eslint/restrict-template-expressions",
69
+ "@typescript-eslint/sort-type-constituents",
70
+ "@typescript-eslint/switch-exhaustiveness-check",
71
+ "@typescript-eslint/triple-slash-reference",
72
+ "@typescript-eslint/unified-signatures",
73
+ "array-callback-return",
74
+ "default-case-last",
75
+ "func-names",
76
+ "func-style",
77
+ "grouped-accessor-pairs",
78
+ "id-denylist",
79
+ "lumina/add-missing-jsx-import",
80
+ "lumina/auto-add-type",
81
+ "lumina/component-placement-rules",
82
+ "lumina/consistent-event-naming",
83
+ "lumina/decorators-context",
84
+ "lumina/explicit-setter-type",
85
+ "lumina/member-ordering",
86
+ "lumina/no-create-element-component",
87
+ "lumina/no-ignore-jsdoc-tag",
88
+ "lumina/no-incorrect-dynamic-tag-name",
89
+ "lumina/no-inline-arrow-in-ref",
90
+ "lumina/no-inline-exposure-jsdoc-tag",
91
+ "lumina/no-invalid-directives-prop",
92
+ "lumina/no-jsdoc-xref-links",
93
+ "lumina/no-jsx-spread",
94
+ "lumina/no-listen-in-connected-callback",
95
+ "lumina/no-non-component-exports",
96
+ "lumina/no-property-name-start-with-on",
97
+ "lumina/no-render-false",
98
+ "lumina/no-unnecessary-assertion-on-event",
99
+ "lumina/no-unnecessary-attribute-name",
100
+ "lumina/no-unnecessary-bind-this",
101
+ "lumina/no-unnecessary-key",
102
+ "lumina/tag-name-rules",
103
+ "no-alert",
104
+ "no-constructor-return",
105
+ "no-extend-native",
106
+ "no-extra-bind",
107
+ "no-loss-of-precision",
108
+ "no-multi-assign",
109
+ "no-object-constructor",
110
+ "no-restricted-syntax",
111
+ "no-return-assign",
112
+ "no-script-url",
113
+ "no-self-compare",
114
+ "no-sequences",
115
+ "no-unneeded-ternary",
116
+ "no-unreachable-loop",
117
+ "no-unsafe-negation",
118
+ "no-useless-call",
119
+ "no-useless-concat",
120
+ "no-warning-comments",
121
+ "prefer-arrow-callback",
122
+ "prefer-numeric-literals",
123
+ "prefer-object-has-own",
124
+ "prefer-object-spread",
125
+ "prefer-regex-literals",
126
+ "prefer-rest-params",
127
+ "prefer-spread",
128
+ "prefer-template",
129
+ "require-atomic-updates",
130
+ "require-unicode-regexp",
131
+ "strict",
132
+ "symbol-description",
133
+ "unicode-bom",
134
+ "webgis/no-dts-files",
135
+ "webgis/no-import-outside-src",
136
+ "webgis/require-await-for-async-screenshot-assert",
137
+ "webgis/require-js-in-imports",
138
+ "yoda"
139
+ ];
140
+ const disabledCoreMarkdownOverrides = [
141
+ "markdown/fenced-code-language",
142
+ "markdown/heading-increment",
143
+ "markdown/no-duplicate-definitions",
144
+ "markdown/no-empty-definitions",
145
+ "markdown/no-empty-images",
146
+ "markdown/no-empty-links",
147
+ "markdown/no-invalid-label-refs",
148
+ "markdown/no-missing-atx-heading-space",
149
+ "markdown/no-missing-link-fragments",
150
+ "markdown/no-multiple-h1",
151
+ "markdown/no-reference-like-urls",
152
+ "markdown/no-reversed-media-syntax",
153
+ "markdown/no-space-in-emphasis",
154
+ "markdown/no-unused-definitions",
155
+ "markdown/require-alt-text",
156
+ "markdown/table-column-count"
157
+ ];
158
+ const disabledCoreTypedOverrides = [
159
+ "@typescript-eslint/no-array-delete",
160
+ "@typescript-eslint/no-floating-promises",
161
+ "@typescript-eslint/no-meaningless-void-operator",
162
+ "@typescript-eslint/no-misused-promises",
163
+ "@typescript-eslint/no-unsafe-unary-minus",
164
+ "@typescript-eslint/prefer-find",
165
+ "@typescript-eslint/prefer-includes",
166
+ "@typescript-eslint/prefer-optional-chain",
167
+ "@typescript-eslint/prefer-string-starts-ends-with",
168
+ "@typescript-eslint/return-await"
169
+ ];
10
170
  const noRestrictedSyntax = [
11
171
  "error",
12
172
  "AccessorProperty",
@@ -36,9 +196,6 @@ const noRestrictedSyntax = [
36
196
  message: "Use const objects or static classes instead. See https://devtopia.esri.com/WebGIS/arcgis-js-api/discussions/72194"
37
197
  }
38
198
  ];
39
- const disabledMarkdownRules = Object.fromEntries(
40
- Object.keys(markdown.rules).map((ruleName) => [`markdown/${ruleName}`, "off"])
41
- );
42
199
  const coreTypedRulesIgnoredFiles = [
43
200
  // We didn't run typed rules on these files before
44
201
  "packages/core-packages/core/*.{ts,tsx}",
@@ -46,13 +203,6 @@ const coreTypedRulesIgnoredFiles = [
46
203
  // This folder runs in node, so uses a separate tsconfig.json
47
204
  "packages/core-packages/core/tests/support/vitest/node/**/*.ts"
48
205
  ];
49
- const coreTypeCheckedRuleNames = new Set(Object.keys(tsEslint.configs.disableTypeChecked.rules ?? {})).union(
50
- corePlugin.meta.typeCheckedRules
51
- );
52
- coreTypeCheckedRuleNames.delete("@typescript-eslint/naming-convention");
53
- const disabledCoreTypeCheckedRules = Object.fromEntries(
54
- Array.from(coreTypeCheckedRuleNames, (ruleName) => [ruleName, "off"])
55
- );
56
206
  const eslintConfigCore = [
57
207
  {
58
208
  files: ["packages/core-packages/**/*.{ts,tsx}"],
@@ -186,135 +336,7 @@ const eslintConfigCore = [
186
336
  }
187
337
  },
188
338
  rules: {
189
- //#region Temporary Disable monorepo-exclusive rules
190
- "@typescript-eslint/adjacent-overload-signatures": "off",
191
- "@typescript-eslint/array-type": "off",
192
- "@typescript-eslint/await-thenable": "off",
193
- "@typescript-eslint/consistent-generic-constructors": "off",
194
- "@typescript-eslint/consistent-indexed-object-style": "off",
195
- "@typescript-eslint/consistent-type-assertions": "off",
196
- "@typescript-eslint/consistent-type-exports": "off",
197
- "@typescript-eslint/dot-notation": "off",
198
- "@typescript-eslint/max-params": "off",
199
- "@typescript-eslint/method-signature-style": "off",
200
- "@typescript-eslint/no-confusing-non-null-assertion": "off",
201
- "@typescript-eslint/no-duplicate-type-constituents": "off",
202
- "@typescript-eslint/no-dynamic-delete": "off",
203
- "@typescript-eslint/no-empty-function": "off",
204
- "@typescript-eslint/no-empty-object-type": "off",
205
- "@typescript-eslint/no-explicit-any": "off",
206
- "@typescript-eslint/no-extra-non-null-assertion": "off",
207
- "@typescript-eslint/no-extraneous-class": "off",
208
- "@typescript-eslint/no-implied-eval": "off",
209
- "@typescript-eslint/no-inferrable-types": "off",
210
- "@typescript-eslint/no-misused-new": "off",
211
- "@typescript-eslint/no-misused-spread": "off",
212
- "@typescript-eslint/no-non-null-asserted-nullish-coalescing": "off",
213
- "@typescript-eslint/no-non-null-asserted-optional-chain": "off",
214
- "@typescript-eslint/no-redundant-type-constituents": "off",
215
- "@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
216
- "@typescript-eslint/no-unnecessary-condition": "off",
217
- "@typescript-eslint/no-unnecessary-template-expression": "off",
218
- "@typescript-eslint/no-unnecessary-type-assertion": "off",
219
- "@typescript-eslint/no-unnecessary-type-constraint": "off",
220
- "@typescript-eslint/no-unnecessary-type-conversion": "off",
221
- "@typescript-eslint/no-unsafe-argument": "off",
222
- "@typescript-eslint/no-unsafe-assignment": "off",
223
- "@typescript-eslint/no-unsafe-call": "off",
224
- "@typescript-eslint/no-unsafe-enum-comparison": "off",
225
- "@typescript-eslint/no-unsafe-function-type": "off",
226
- "@typescript-eslint/no-unsafe-member-access": "off",
227
- "@typescript-eslint/no-useless-empty-export": "off",
228
- "@typescript-eslint/no-wrapper-object-types": "off",
229
- "@typescript-eslint/non-nullable-type-assertion-style": "off",
230
- "@typescript-eslint/only-throw-error": "off",
231
- "@typescript-eslint/prefer-as-const": "off",
232
- "@typescript-eslint/prefer-function-type": "off",
233
- "@typescript-eslint/prefer-promise-reject-errors": "off",
234
- "@typescript-eslint/prefer-reduce-type-parameter": "off",
235
- "@typescript-eslint/prefer-return-this-type": "off",
236
- "@typescript-eslint/promise-function-async": "off",
237
- "@typescript-eslint/related-getter-setter-pairs": "off",
238
- "@typescript-eslint/require-array-sort-compare": "off",
239
- "@typescript-eslint/require-await": "off",
240
- "@typescript-eslint/restrict-plus-operands": "off",
241
- "@typescript-eslint/restrict-template-expressions": "off",
242
- "@typescript-eslint/sort-type-constituents": "off",
243
- "@typescript-eslint/switch-exhaustiveness-check": "off",
244
- "@typescript-eslint/triple-slash-reference": "off",
245
- "@typescript-eslint/unified-signatures": "off",
246
- "array-callback-return": "off",
247
- "default-case-last": "off",
248
- "func-names": "off",
249
- "func-style": "off",
250
- "grouped-accessor-pairs": "off",
251
- "id-denylist": "off",
252
- "lumina/add-missing-jsx-import": "off",
253
- "lumina/auto-add-type": "off",
254
- "lumina/component-placement-rules": "off",
255
- "lumina/consistent-event-naming": "off",
256
- "lumina/consistent-nullability": "off",
257
- "lumina/decorators-context": "off",
258
- "lumina/explicit-setter-type": "off",
259
- "lumina/member-ordering": "off",
260
- "lumina/no-create-element-component": "off",
261
- "lumina/no-ignore-jsdoc-tag": "off",
262
- "lumina/no-incorrect-dynamic-tag-name": "off",
263
- "lumina/no-inline-arrow-in-ref": "off",
264
- "lumina/no-inline-exposure-jsdoc-tag": "off",
265
- "lumina/no-invalid-directives-prop": "off",
266
- "lumina/no-jsdoc-xref-links": "off",
267
- "lumina/no-jsx-spread": "off",
268
- "lumina/no-listen-in-connected-callback": "off",
269
- "lumina/no-non-component-exports": "off",
270
- "lumina/no-property-name-start-with-on": "off",
271
- "lumina/no-render-false": "off",
272
- "lumina/no-unnecessary-assertion-on-event": "off",
273
- "lumina/no-unnecessary-attribute-name": "off",
274
- "lumina/no-unnecessary-bind-this": "off",
275
- "lumina/no-unnecessary-key": "off",
276
- "lumina/tag-name-rules": "off",
277
- "no-alert": "off",
278
- "no-await-in-loop": "off",
279
- "no-constructor-return": "off",
280
- "no-extend-native": "off",
281
- "no-extra-bind": "off",
282
- "no-loss-of-precision": "off",
283
- "no-multi-assign": "off",
284
- "no-object-constructor": "off",
285
- "no-restricted-syntax": "off",
286
- "no-return-assign": "off",
287
- "no-script-url": "off",
288
- "no-self-compare": "off",
289
- "no-sequences": "off",
290
- "no-unneeded-ternary": "off",
291
- "no-unreachable-loop": "off",
292
- "no-unsafe-negation": "off",
293
- "no-useless-call": "off",
294
- "no-useless-concat": "off",
295
- "no-warning-comments": "off",
296
- "prefer-arrow-callback": "off",
297
- "prefer-numeric-literals": "off",
298
- "prefer-object-has-own": "off",
299
- "prefer-object-spread": "off",
300
- "prefer-regex-literals": "off",
301
- "prefer-rest-params": "off",
302
- "prefer-spread": "off",
303
- "prefer-template": "off",
304
- "require-atomic-updates": "off",
305
- "require-unicode-regexp": "off",
306
- "strict": "off",
307
- "symbol-description": "off",
308
- "unicode-bom": "off",
309
- "unicorn/number-literal-case": "off",
310
- "webgis/consistent-logging": "off",
311
- "webgis/no-dts-files": "off",
312
- "webgis/no-import-outside-src": "off",
313
- "webgis/require-await-for-async-screenshot-assert": "off",
314
- "webgis/require-js-in-imports": "off",
315
- "yoda": "off",
316
- //#endregion
317
- //#region Temporary enable core-exclusive rules
339
+ ...disabledRules(disabledCoreOverrides),
318
340
  "@typescript-eslint/ban-ts-comment": ["error", { "ts-expect-error": false, "ts-nocheck": false }],
319
341
  "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
320
342
  "@typescript-eslint/explicit-function-return-type": ["error", { allowExpressions: true }],
@@ -348,8 +370,6 @@ const eslintConfigCore = [
348
370
  ],
349
371
  "@typescript-eslint/no-array-constructor": "error",
350
372
  "@typescript-eslint/no-import-type-side-effects": "error",
351
- "@typescript-eslint/no-redeclare": "off",
352
- // turn on when this doesn't error on mixins
353
373
  "@typescript-eslint/no-require-imports": "error",
354
374
  "@typescript-eslint/no-restricted-imports": [
355
375
  "error",
@@ -455,21 +475,26 @@ const eslintConfigCore = [
455
475
  ]
456
476
  }
457
477
  ],
478
+ // Catch redundant import path segments
458
479
  "import-x/no-useless-path-segments": "error",
480
+ // Forbid unknown JSDoc tags and catch typos. Adopt in AWC now that we are using API Extractor
459
481
  "jsdoc/check-tag-names": [
460
482
  "error",
461
483
  { definedTags: ["tstype", "ignoreNilOnly", "noautocast", "collectionItemType"] }
462
484
  ],
485
+ // TODO: drop because we don't specify types in JSDoc anymore
463
486
  "jsdoc/check-types": "error",
487
+ // Forbid value after JSDoc tags that don't expect a value.
464
488
  // Ensure @readonly and @public is used without any content
465
489
  "jsdoc/empty-tags": "error",
466
- // Avoid /**\n ** something */
490
+ // Avoid /**\n ** something */ - likely typo
467
491
  "jsdoc/no-multi-asterisks": ["error", { allowWhitespace: true }],
468
492
  // Enforce each JSDoc line starts with *
469
493
  "jsdoc/require-asterisk-prefix": "error",
470
494
  // Enforce @param has param name
495
+ // TODO: consider dropping. This rule requires ... for rest params -
496
+ // that data should come from the AST, not JSDoc
471
497
  "jsdoc/require-param-name": "error",
472
- "no-array-constructor": "off",
473
498
  "no-async-promise-executor": "error",
474
499
  "no-caller": "error",
475
500
  "no-case-declarations": "error",
@@ -486,15 +511,12 @@ const eslintConfigCore = [
486
511
  "no-labels": ["error", { allowLoop: true, allowSwitch: true }],
487
512
  "no-new-func": "error",
488
513
  "no-new-wrappers": "error",
489
- "no-redeclare": "off",
490
514
  "no-regex-spaces": "error",
491
515
  "no-restricted-globals": ["error", "event", "name", "origin"],
492
516
  "no-shadow-restricted-names": "error",
493
517
  "no-throw-literal": "error",
494
518
  "no-unsafe-finally": "error",
495
519
  "no-unsafe-optional-chaining": "error",
496
- "no-unused-expressions": "off",
497
- "no-unused-vars": "off",
498
520
  "no-useless-escape": "error",
499
521
  "no-useless-rename": "error",
500
522
  "no-var": "error",
@@ -503,102 +525,177 @@ const eslintConfigCore = [
503
525
  "prefer-const": ["error", { destructuring: "all" }],
504
526
  "prefer-exponentiation-operator": "error",
505
527
  "radix": "error",
528
+ // Improve readability for \n and \t usages in regexes. Note this adds 0.5s to lint time
506
529
  "regexp/control-character-escape": "error",
530
+ // Catch redundant regex syntax
507
531
  "regexp/no-dupe-characters-character-class": "error",
532
+ // Catch redundant regex syntax
508
533
  "regexp/no-dupe-disjunctions": "error",
534
+ // Catch potential typos in regexes
509
535
  "regexp/no-empty-alternative": "error",
536
+ // Catch redundant regex syntax
510
537
  "regexp/no-empty-capturing-group": "error",
538
+ // Catch redundant regex syntax
511
539
  "regexp/no-empty-character-class": "error",
540
+ // Catch redundant regex syntax
512
541
  "regexp/no-empty-group": "error",
542
+ // Catch redundant regex syntax
513
543
  "regexp/no-empty-lookarounds-assertion": "error",
544
+ // Avoid confusion between \b and [\b]
514
545
  "regexp/no-escape-backspace": "error",
546
+ // Catch redundant regex syntax
515
547
  "regexp/no-extra-lookaround-assertions": "error",
548
+ // Detect regex syntax errors before it causes a runtime error
516
549
  "regexp/no-invalid-regexp": "error",
550
+ // Prefer escape codes over invisible characters for readability
517
551
  "regexp/no-invisible-character": "error",
552
+ // Catch redundant regex syntax
518
553
  "regexp/no-lazy-ends": "error",
554
+ // Catch unicode regexes that never match
519
555
  "regexp/no-misleading-unicode-character": "error",
556
+ // Detect when .matchAll() regex is missing /g in a way that catches runtime error
520
557
  "regexp/no-missing-g-flag": "error",
558
+ // Catch misleading usages of - in regex
521
559
  "regexp/no-obscure-range": "error",
560
+ // Catch redundant regex syntax
522
561
  "regexp/no-optional-assertion": "error",
562
+ // Catch redundant regex syntax
523
563
  "regexp/no-trivially-nested-assertion": "error",
564
+ // Catch redundant regex syntax
524
565
  "regexp/no-trivially-nested-quantifier": "error",
566
+ // Catch redundant regex syntax
525
567
  "regexp/no-useless-assertions": "error",
568
+ // Catch redundant regex syntax
526
569
  "regexp/no-useless-backreference": "error",
570
+ // Catch redundant regex syntax
527
571
  "regexp/no-useless-character-class": "error",
572
+ // Catch redundant regex syntax
528
573
  "regexp/no-useless-dollar-replacements": "error",
574
+ // Adds auto-fix and additional checks compared to `no-useless-escape`
529
575
  "regexp/no-useless-escape": "error",
530
- // adds auto-fix and additional checks compared to `no-useless-escape`
576
+ // Catch redundant regex syntax
531
577
  "regexp/no-useless-lazy": "error",
578
+ // Catch redundant regex syntax
532
579
  "regexp/no-useless-quantifier": "error",
580
+ // Catch redundant regex syntax
533
581
  "regexp/no-useless-range": "error",
582
+ // Catch redundant regex syntax
534
583
  "regexp/no-useless-set-operand": "error",
584
+ // Catch redundant regex syntax
535
585
  "regexp/no-useless-string-literal": "error",
586
+ // Catch redundant regex syntax
536
587
  "regexp/no-useless-two-nums-quantifier": "error",
588
+ // Catch redundant regex syntax
537
589
  "regexp/optimal-quantifier-concatenation": "error",
590
+ // Catch redundant regex syntax
538
591
  "regexp/prefer-predefined-assertion": "error",
592
+ // Catch redundant regex syntax
539
593
  "regexp/prefer-range": "error",
594
+ // Encourage usage of modern regex features
540
595
  "regexp/prefer-set-operation": "error",
596
+ // Catch redundant date cloning syntax
541
597
  "unicorn/consistent-date-clone": "error",
598
+ // Use [] over '' when spreading in arrays (readability only - no runtime difference)
542
599
  "unicorn/consistent-empty-array-spread": "error",
600
+ // If need to disable ESLint, encourage disabling a single rule rather than all
543
601
  "unicorn/no-abusive-eslint-disable": "error",
602
+ // Detect getter accessing itself - causes a runtime loop
544
603
  "unicorn/no-accessor-recursion": "error",
604
+ // Detect Promise.all([await a]) when await Promise.all([a]) was meant
545
605
  "unicorn/no-await-in-promise-methods": "error",
606
+ // Forbid unsafe usage of instanceof
546
607
  "unicorn/no-instanceof-builtins": "error",
608
+ // Catch .removeEventListener usages that don't work
547
609
  "unicorn/no-invalid-remove-event-listener": "error",
610
+ // Detect !a==b when a!=b was meant.
611
+ // TODO: drop because TypeScript detects this. And it misses
612
+ // cases that @typescript-eslint/no-confusing-non-null-assertion detects
548
613
  "unicorn/no-negation-in-equality-check": "error",
614
+ // Catch redundant promise syntax
549
615
  "unicorn/no-single-promise-in-promise-methods": "error",
616
+ // Prefer === undefined over typeof bar === 'undefined'
550
617
  "unicorn/no-typeof-undefined": "error",
618
+ // Prefer .flat() over .flat(1)
551
619
  "unicorn/no-unnecessary-array-flat-depth": "error",
620
+ // Prefer .splice(1) over .splice(1, string.length);
552
621
  "unicorn/no-unnecessary-array-splice-count": "error",
622
+ // Catch redundant .slice() syntax
553
623
  "unicorn/no-unnecessary-slice-end": "error",
624
+ // Catch redundant spread syntax
554
625
  "unicorn/no-useless-fallback-in-spread": "error",
626
+ // Replace .some() with .every() or the opposite when it simplifies the code
555
627
  "unicorn/no-useless-length-check": "error",
628
+ // Catch redundant promise syntax
556
629
  "unicorn/no-useless-promise-resolve-reject": "error",
630
+ // Catch redundant spread syntax usage
557
631
  "unicorn/no-useless-spread": "error",
632
+ // Do not initialize variables with =undefined as that is the default
558
633
  "unicorn/no-useless-undefined": ["error", { checkArguments: false, checkArrowFunctionBody: false }],
634
+ // Prefer .find() over .filter()[0]
559
635
  "unicorn/prefer-array-find": "error",
636
+ // Use .flat() over older workaround syntaxes
560
637
  "unicorn/prefer-array-flat": "error",
638
+ // Prefer .flatMap() over .map().flat()
561
639
  "unicorn/prefer-array-flat-map": "error",
640
+ // Prefer .indexOf() over .findIndex() where possible
562
641
  "unicorn/prefer-array-index-of": "error",
642
+ // Use .some() over .filter().length>0
563
643
  "unicorn/prefer-array-some": "error",
644
+ // Use newer methods when working with blobs
564
645
  "unicorn/prefer-blob-reading-methods": "error",
646
+ // Prefer Date.now() over older longer but equivalent variants
565
647
  "unicorn/prefer-date-now": "error",
648
+ // Catch legacy default-values syntax
566
649
  "unicorn/prefer-default-parameters": "error",
650
+ // Use .includes() over .indexOf() where possible for readability
567
651
  "unicorn/prefer-includes": "error",
652
+ // Prefer `a ?? b` over `a ? a : b`
568
653
  "unicorn/prefer-logical-operator-over-ternary": "error",
654
+ // Prefer simpler syntax for .slice() from the end
569
655
  "unicorn/prefer-negative-index": "error",
656
+ // Require `node:` in node.js imports. Improves compatibility with non-node engines
570
657
  "unicorn/prefer-node-protocol": "error",
658
+ // TODO: consider dropping - string.match(regex) is more readable
571
659
  "unicorn/prefer-regexp-test": "error",
660
+ // Prefer sets over arrays when using the array only for .includes() check
572
661
  "unicorn/prefer-set-has": "error",
662
+ // Simplify code when set .size is needed
573
663
  "unicorn/prefer-set-size": "error",
664
+ // Use .replaceAll() over .replace() when replaceAll was meant. Readability.
574
665
  "unicorn/prefer-string-replace-all": "error",
666
+ // Use .slice() over legacy .substring() and .substr()
575
667
  "unicorn/prefer-string-slice": "error",
668
+ // Prefer .startsWith() over regex when they are equivalent for readability
576
669
  "unicorn/prefer-string-starts-ends-with": "error",
670
+ // Require `new Error` over `Error`.
671
+ // TODO: dro because they are equivalent and `new ` adds bytes (not minified by esbuild)
577
672
  "unicorn/throw-new-error": "error",
673
+ // See https://devtopia.esri.com/WebGIS/webgis-sdk/pull/15335#discussion_r1683898
578
674
  "webgis/consistent-constructor-arguments": "error",
579
675
  "webgis/consistent-mixin-syntax": "error",
580
676
  "webgis/no-empty-catch": "error",
677
+ // Use JSX props over attributes because TypeScript does not type check attributes
581
678
  "webgis/no-kebab-case-props": "error",
679
+ // Require type="" parameter on buttons to avoid unexpected button behavior inside forms
582
680
  "webgis/require-button-type": "error"
583
- //#endregion
584
681
  }
585
682
  },
586
683
  {
587
684
  files: ["packages/core-packages/**/*.md"],
588
- rules: disabledMarkdownRules
685
+ rules: {
686
+ ...disabledRules(disabledCoreMarkdownOverrides)
687
+ }
589
688
  },
590
689
  {
591
690
  files: ["packages/core-packages/core/package.json"],
592
691
  rules: {
593
- // @typescript/native-preview temporarily uses the `beta` tag rather than a semver range.
594
- "package-json/valid-devDependencies": "off"
692
+ ...disabledRules(disabledCorePackageJsonRules)
595
693
  }
596
694
  },
597
695
  {
598
696
  files: ["packages/core-packages/**/*.d.ts"],
599
697
  rules: {
600
- "@typescript-eslint/naming-convention": "off"
601
- // we can't enforce names in libraries
698
+ ...disabledRules(disabledCoreDeclarationRules)
602
699
  }
603
700
  },
604
701
  {
@@ -606,8 +703,6 @@ const eslintConfigCore = [
606
703
  files: ["packages/core-packages/**/*.{ts,tsx}"],
607
704
  ignores: [...coreTypedRulesIgnoredFiles],
608
705
  rules: {
609
- // Disabled until https://github.com/typescript-eslint/typescript-eslint/pull/11267 is available.
610
- "@typescript-eslint/await-thenable": "off",
611
706
  "@typescript-eslint/no-array-delete": "error",
612
707
  "@typescript-eslint/no-floating-promises": "error",
613
708
  "@typescript-eslint/no-for-in-array": "error",
@@ -631,7 +726,9 @@ const eslintConfigCore = [
631
726
  projectService: false
632
727
  }
633
728
  },
634
- rules: disabledCoreTypeCheckedRules
729
+ rules: {
730
+ ...disabledRules(disabledCoreTypedOverrides)
731
+ }
635
732
  },
636
733
  {
637
734
  files: ["packages/core-packages/**/*.tsx"],
@@ -640,6 +737,7 @@ const eslintConfigCore = [
640
737
  "react-jsx": reactJsxPlugin
641
738
  },
642
739
  rules: {
740
+ // Sort JSX props consistently. Improves readability for large JSX blocks
643
741
  "perfectionist/sort-jsx-props": [
644
742
  "error",
645
743
  {
@@ -647,8 +745,14 @@ const eslintConfigCore = [
647
745
  customGroups: [{ groupName: "callback", elementNamePattern: "^on.+" }]
648
746
  }
649
747
  ],
748
+ // Require passing JSX children as content rather than as children={} prop
650
749
  "react-jsx/no-children-prop": "error",
750
+ // Catch JSX comment syntax error
651
751
  "react-jsx/no-comment-textnodes": "error",
752
+ // Report needless <>
753
+ // TODO: consider dropping this rule rule because this has no runtime cost
754
+ // in Lumina, and it is not always autofixable. This rule also errors for
755
+ // return <></>; which is sometimes needed in astro
652
756
  "react-jsx/no-useless-fragment": "error"
653
757
  }
654
758
  },
@@ -675,7 +779,6 @@ const eslintConfigCore = [
675
779
  {
676
780
  files: ["packages/core-packages/core/tests/**/*.{ts,tsx}"],
677
781
  rules: {
678
- "webgis/no-instanceof": "off",
679
782
  "@typescript-eslint/no-restricted-imports": [
680
783
  "error",
681
784
  {
@@ -711,6 +814,7 @@ const eslintConfigCore = [
711
814
  message: "Avoid adding has flags manually. Instead use the suite/test-level options to set has flags."
712
815
  }
713
816
  ],
817
+ // Require awaiting assert.screenshot() in tests
714
818
  "webgis/require-await-for-async-screenshot-assert": "error"
715
819
  }
716
820
  }
@@ -2,19 +2,10 @@ const config = [
2
2
  {
3
3
  files: ["**/*.ts", "**/*.tsx"],
4
4
  rules: {
5
- // See https://devtopia.esri.com/WebGIS/webgis-sdk/discussions/446#discussioncomment-3166
6
- "@typescript-eslint/no-unsafe-return": "warn",
7
- /*
8
- * Lot's of false positives on pure functions that don't use
9
- * "this". For example:
10
- * const { whenOnce } = await importCoreReactiveUtils();
11
- */
12
- "@typescript-eslint/unbound-method": "warn",
13
5
  /*
14
6
  * This rule can have many positives (i.e abstract methods), or fire on code
15
7
  * that you can't refactor without breaking changes
16
8
  */
17
- "class-methods-use-this": "off",
18
9
  "@typescript-eslint/class-methods-use-this": [
19
10
  "warn",
20
11
  {
@@ -22,11 +13,19 @@ const config = [
22
13
  ignoreClassesThatImplementAnInterface: "public-fields"
23
14
  }
24
15
  ],
16
+ // See https://devtopia.esri.com/WebGIS/webgis-sdk/discussions/446#discussioncomment-3166
17
+ "@typescript-eslint/no-unsafe-return": "warn",
25
18
  /**
26
19
  * False positive when constructor exists to improve typing/narrow down the
27
20
  * type
28
21
  */
29
- "@typescript-eslint/no-useless-constructor": "warn"
22
+ "@typescript-eslint/no-useless-constructor": "warn",
23
+ /*
24
+ * Lot's of false positives on pure functions that don't use
25
+ * "this". For example:
26
+ * const { whenOnce } = await importCoreReactiveUtils();
27
+ */
28
+ "@typescript-eslint/unbound-method": "warn"
30
29
  }
31
30
  }
32
31
  ];