@arcgis/eslint-config 5.2.0-next.16 → 5.2.0-next.160

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.
@@ -0,0 +1,824 @@
1
+ import { d as disabledRules } from "../chunks/disabledRules.js";
2
+ import jsdocPlugin from "eslint-plugin-jsdoc";
3
+ import perfectionistPlugin from "eslint-plugin-perfectionist";
4
+ import reactJsxPlugin from "eslint-plugin-react-jsx";
5
+ import regexpPlugin from "eslint-plugin-regexp";
6
+ import unicornPlugin from "eslint-plugin-unicorn";
7
+ import { join } from "node:path";
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
+ ];
170
+ const noRestrictedSyntax = [
171
+ "error",
172
+ "AccessorProperty",
173
+ "PrivateIdentifier",
174
+ {
175
+ selector: "CallExpression[callee.property.name='concat'][arguments.length=0]",
176
+ message: "Use slice() instead of concat()."
177
+ },
178
+ {
179
+ selector: "CallExpression[callee.property.name='slice'][arguments.length=1] > .arguments[value=0]",
180
+ message: "Use slice() instead of slice(0)."
181
+ },
182
+ {
183
+ selector: "TSAbstractPropertyDefinition[decorators.length>0]",
184
+ message: "Decorators are not supported on abstract properties."
185
+ },
186
+ {
187
+ selector: "TSEnumDeclaration:not([const=true])",
188
+ message: "Don't declare non-const enums. Use `const enum` instead, or an object with `as const`. See https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums"
189
+ },
190
+ {
191
+ selector: "VariableDeclarator > CallExpression > MemberExpression[property.name='getLogger']",
192
+ message: "Get a logger as needed instead of assigning it for future use."
193
+ },
194
+ {
195
+ selector: "TSModuleDeclaration[id.type='Identifier']",
196
+ message: "Use const objects or static classes instead. See https://devtopia.esri.com/WebGIS/arcgis-js-api/discussions/72194"
197
+ }
198
+ ];
199
+ const coreTypedRulesIgnoredFiles = [
200
+ // We didn't run typed rules on these files before
201
+ "packages/core-packages/core/*.{ts,tsx}",
202
+ "packages/core-packages/core/{.github,build,scripts,tasks,test-apps,typings}/**/*.{ts,tsx}",
203
+ // This folder runs in node, so uses a separate tsconfig.json
204
+ "packages/core-packages/core/tests/support/vitest/node/**/*.ts"
205
+ ];
206
+ const eslintConfigCore = [
207
+ {
208
+ files: ["packages/core-packages/**/*.{ts,tsx}"],
209
+ linterOptions: {
210
+ reportUnusedDisableDirectives: "off"
211
+ },
212
+ plugins: {
213
+ core: corePlugin,
214
+ jsdoc: jsdocPlugin,
215
+ regexp: regexpPlugin,
216
+ unicorn: unicornPlugin
217
+ },
218
+ settings: {
219
+ jsdoc: {
220
+ tagNamePreference: {
221
+ // Our tags
222
+ "public": "public",
223
+ "internal": "internal",
224
+ "copyDoc": "copyDoc",
225
+ // Flags
226
+ "beta": "beta",
227
+ "experimental": "experimental",
228
+ "knipIgnore": "knipIgnore",
229
+ "readonly": "readonly",
230
+ // Metadata
231
+ "deprecated": "deprecated",
232
+ "default": "default",
233
+ "since": "since",
234
+ "param": "param",
235
+ "returns": "returns",
236
+ "see": "see",
237
+ "esriCompatibilityName": "esriCompatibilityName",
238
+ // Not yet officially supported, but not forbidden
239
+ "throws": "throws",
240
+ // Long descriptions
241
+ "example": "example",
242
+ "privateRemarks": "privateRemarks",
243
+ // Legacy replacements
244
+ "const": "readonly",
245
+ "constant": "readonly",
246
+ "defaultvalue": "default",
247
+ "return": "returns",
248
+ // Forbid JSDoc tags that are redundant with TypeScript or not used by the docs ui
249
+ // eslint-plugin-jsdoc allows all these by default, so we need to explicitly disable them
250
+ "abstract": false,
251
+ "access": false,
252
+ "alias": false,
253
+ "arg": false,
254
+ "argument": false,
255
+ "async": false,
256
+ "augments": false,
257
+ "author": false,
258
+ "borrows": false,
259
+ "callback": false,
260
+ "class": false,
261
+ "classdesc": false,
262
+ "collectionItemType": false,
263
+ "constructor": false,
264
+ "constructs": false,
265
+ "copyright": false,
266
+ "deprecatedParameters": false,
267
+ "deprecatedProperties": false,
268
+ "desc": false,
269
+ "description": false,
270
+ "emits": false,
271
+ "enum": false,
272
+ "esmimport": false,
273
+ "event": false,
274
+ "exception": false,
275
+ "exports": false,
276
+ "extends": false,
277
+ "external": false,
278
+ "file": false,
279
+ "fileoverview": false,
280
+ "fires": false,
281
+ "func": false,
282
+ "function": false,
283
+ "generator": false,
284
+ "global": false,
285
+ "hideconstructor": false,
286
+ "host": false,
287
+ "ignore": false,
288
+ "implements": false,
289
+ "inheritDoc": false,
290
+ "inheritdoc": false,
291
+ "inner": false,
292
+ "instance": false,
293
+ "interface": false,
294
+ "kind": false,
295
+ "lends": false,
296
+ "license": false,
297
+ "listens": false,
298
+ "member": false,
299
+ "memberof!": false,
300
+ "memberof": false,
301
+ "method": false,
302
+ "mixes": false,
303
+ "mixin": false,
304
+ "modifies": false,
305
+ "module": false,
306
+ "moduletype": false,
307
+ "name": false,
308
+ "namespace": false,
309
+ "override": false,
310
+ "overview": false,
311
+ "package": false,
312
+ "private": false,
313
+ "prop": false,
314
+ "property": false,
315
+ "protected": false,
316
+ "requires": false,
317
+ "static": false,
318
+ "summary": false,
319
+ "tag constructor": false,
320
+ "this": false,
321
+ "tstype": false,
322
+ "tutorial": false,
323
+ "type": false,
324
+ "typedef": false,
325
+ "var": false,
326
+ "variation": false,
327
+ "version": false,
328
+ "virtual": false,
329
+ "yield": false,
330
+ "yields": false,
331
+ "import": false,
332
+ "overload": false,
333
+ "satisfies": false,
334
+ "template": false
335
+ }
336
+ }
337
+ },
338
+ rules: {
339
+ ...disabledRules(disabledCoreOverrides),
340
+ "@typescript-eslint/ban-ts-comment": ["error", { "ts-expect-error": false, "ts-nocheck": false }],
341
+ "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
342
+ "@typescript-eslint/explicit-function-return-type": ["error", { allowExpressions: true }],
343
+ "@typescript-eslint/explicit-member-accessibility": ["error", { accessibility: "no-public" }],
344
+ "@typescript-eslint/naming-convention": [
345
+ "error",
346
+ { selector: ["typeLike"], format: ["PascalCase"] },
347
+ {
348
+ selector: ["function", "classMethod", "classProperty", "typeMethod"],
349
+ format: ["camelCase"],
350
+ leadingUnderscore: "allow"
351
+ },
352
+ {
353
+ selector: ["memberLike", "classProperty"],
354
+ modifiers: ["private"],
355
+ format: ["camelCase"],
356
+ leadingUnderscore: "require"
357
+ },
358
+ {
359
+ selector: ["classProperty"],
360
+ modifiers: ["static"],
361
+ format: ["UPPER_CASE", "PascalCase", "camelCase"],
362
+ leadingUnderscore: "allow"
363
+ },
364
+ {
365
+ selector: ["classProperty"],
366
+ modifiers: ["private", "static"],
367
+ format: ["UPPER_CASE", "PascalCase", "camelCase"],
368
+ leadingUnderscore: "allow"
369
+ }
370
+ ],
371
+ "@typescript-eslint/no-array-constructor": "error",
372
+ "@typescript-eslint/no-import-type-side-effects": "error",
373
+ "@typescript-eslint/no-require-imports": "error",
374
+ "@typescript-eslint/no-restricted-imports": [
375
+ "error",
376
+ {
377
+ paths: [
378
+ { name: "esri/identity/IdentityManager", message: "Use `esri/kernel.id` or the `authMode` option." },
379
+ {
380
+ name: "esri/layers/support/rasterFunctionUtils",
381
+ message: "Import raster function creators directly instead."
382
+ },
383
+ {
384
+ name: "esri/TimeExtent",
385
+ message: "Use `esri/time/TimeExtent` instead. See https://devtopia.esri.com/WebGIS/arcgis-js-api/issues/49223."
386
+ },
387
+ {
388
+ name: "esri/TimeInterval",
389
+ message: "Use `esri/time/TimeInterval` instead. See https://devtopia.esri.com/WebGIS/arcgis-js-api/issues/49223."
390
+ },
391
+ { name: "esri/rest/geometryService", message: "Import geometry services directly instead" },
392
+ { name: "esri/rest/geoprocessor", message: "Import geoprocessor exports directly instead" },
393
+ { name: "esri/rest/locator", message: "Import locator exports directly instead" },
394
+ { name: "esri/rest/query", message: "use individual files instead" }
395
+ ],
396
+ patterns: [
397
+ {
398
+ group: ["@esri/calcite-components/dist/components/*"],
399
+ message: "Pass a dynamic import to `loadCalciteComponents` inside `loadDependencies` instead.",
400
+ allowTypeImports: true
401
+ }
402
+ ]
403
+ }
404
+ ],
405
+ "@typescript-eslint/no-unnecessary-parameter-property-assignment": "error",
406
+ "@typescript-eslint/no-unused-expressions": ["error", { allowShortCircuit: true, allowTernary: true }],
407
+ "@typescript-eslint/no-unused-vars": [
408
+ "error",
409
+ {
410
+ args: "all",
411
+ argsIgnorePattern: "^_",
412
+ caughtErrors: "none",
413
+ destructuredArrayIgnorePattern: "^_",
414
+ varsIgnorePattern: "^_|^tsx",
415
+ ignoreRestSiblings: true,
416
+ enableAutofixRemoval: { imports: true }
417
+ }
418
+ ],
419
+ "@typescript-eslint/prefer-namespace-keyword": "error",
420
+ "arrow-body-style": "error",
421
+ "core/glsl-whitespace": "error",
422
+ "core/imports-format": "error",
423
+ "core/no-duplicate-import-comments": "error",
424
+ "core/no-empty-jsdoc-todo": "error",
425
+ "core/no-redundant-checked-in-files": "error",
426
+ "core/prefer-relative-imports": "error",
427
+ "core/require-calcite-import": "error",
428
+ "curly": "error",
429
+ "eqeqeq": ["error", "smart"],
430
+ "import-x/no-duplicates": "error",
431
+ "import-x/no-dynamic-require": ["error", { esmodule: true }],
432
+ "import-x/no-restricted-paths": [
433
+ "error",
434
+ {
435
+ // This is temporary. Once most of this config is merged with the
436
+ // root @arcgis/eslint-config, the core-specific rules can be moved
437
+ // into @webgis/monorepo-config
438
+ basePath: join(import.meta.dirname, "../../../../core-packages/core"),
439
+ zones: [
440
+ {
441
+ target: "src",
442
+ from: "src/identity/IdentityManager.ts",
443
+ message: "Use `kernel.id` or the `authMode` request option."
444
+ },
445
+ {
446
+ target: "src",
447
+ from: "src/layers/support/rasterFunctionUtils.ts",
448
+ message: "Import raster function creators directly instead."
449
+ },
450
+ {
451
+ target: "src",
452
+ from: "src/rest/geometryService.ts",
453
+ message: "Import the `geometryService` exports directly instead."
454
+ },
455
+ {
456
+ target: "src",
457
+ from: "src/rest/geoprocessor.ts",
458
+ message: "Import the geoprocessor exports directly instead."
459
+ },
460
+ {
461
+ target: "src",
462
+ from: "src/rest/locator.ts",
463
+ message: "Import the locator exports directly instead."
464
+ },
465
+ {
466
+ target: "src",
467
+ from: "src/rest/query.ts",
468
+ message: "Import the query exports directly instead"
469
+ },
470
+ {
471
+ target: "src",
472
+ from: "tests",
473
+ message: "Modules in /src should not import modules in /tests."
474
+ }
475
+ ]
476
+ }
477
+ ],
478
+ // Catch redundant import path segments
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
481
+ "jsdoc/check-tag-names": [
482
+ "error",
483
+ { definedTags: ["tstype", "ignoreNilOnly", "noautocast", "collectionItemType"] }
484
+ ],
485
+ // TODO: drop because we don't specify types in JSDoc anymore
486
+ "jsdoc/check-types": "error",
487
+ // Forbid value after JSDoc tags that don't expect a value.
488
+ // Ensure @readonly and @public is used without any content
489
+ "jsdoc/empty-tags": "error",
490
+ // Avoid /**\n ** something */ - likely typo
491
+ "jsdoc/no-multi-asterisks": ["error", { allowWhitespace: true }],
492
+ // Enforce each JSDoc line starts with *
493
+ "jsdoc/require-asterisk-prefix": "error",
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
497
+ "jsdoc/require-param-name": "error",
498
+ "no-async-promise-executor": "error",
499
+ "no-caller": "error",
500
+ "no-case-declarations": "error",
501
+ "no-cond-assign": "error",
502
+ "no-constant-binary-expression": "error",
503
+ "no-control-regex": "error",
504
+ "no-debugger": "error",
505
+ "no-duplicate-case": "error",
506
+ "no-else-return": "error",
507
+ "no-eval": "error",
508
+ "no-fallthrough": ["error", { reportUnusedFallthroughComment: false }],
509
+ "no-implied-eval": "error",
510
+ "no-inner-declarations": "error",
511
+ "no-labels": ["error", { allowLoop: true, allowSwitch: true }],
512
+ "no-new-func": "error",
513
+ "no-new-wrappers": "error",
514
+ "no-regex-spaces": "error",
515
+ "no-restricted-globals": ["error", "event", "name", "origin"],
516
+ "no-shadow-restricted-names": "error",
517
+ "no-throw-literal": "error",
518
+ "no-unsafe-finally": "error",
519
+ "no-unsafe-optional-chaining": "error",
520
+ "no-useless-escape": "error",
521
+ "no-useless-rename": "error",
522
+ "no-var": "error",
523
+ "object-shorthand": "error",
524
+ "one-var": ["error", { initialized: "never" }],
525
+ "prefer-const": ["error", { destructuring: "all" }],
526
+ "prefer-exponentiation-operator": "error",
527
+ "radix": "error",
528
+ // Improve readability for \n and \t usages in regexes. Note this adds 0.5s to lint time
529
+ "regexp/control-character-escape": "error",
530
+ // Catch redundant regex syntax
531
+ "regexp/no-dupe-characters-character-class": "error",
532
+ // Catch redundant regex syntax
533
+ "regexp/no-dupe-disjunctions": "error",
534
+ // Catch potential typos in regexes
535
+ "regexp/no-empty-alternative": "error",
536
+ // Catch redundant regex syntax
537
+ "regexp/no-empty-capturing-group": "error",
538
+ // Catch redundant regex syntax
539
+ "regexp/no-empty-character-class": "error",
540
+ // Catch redundant regex syntax
541
+ "regexp/no-empty-group": "error",
542
+ // Catch redundant regex syntax
543
+ "regexp/no-empty-lookarounds-assertion": "error",
544
+ // Avoid confusion between \b and [\b]
545
+ "regexp/no-escape-backspace": "error",
546
+ // Catch redundant regex syntax
547
+ "regexp/no-extra-lookaround-assertions": "error",
548
+ // Detect regex syntax errors before it causes a runtime error
549
+ "regexp/no-invalid-regexp": "error",
550
+ // Prefer escape codes over invisible characters for readability
551
+ "regexp/no-invisible-character": "error",
552
+ // Catch redundant regex syntax
553
+ "regexp/no-lazy-ends": "error",
554
+ // Catch unicode regexes that never match
555
+ "regexp/no-misleading-unicode-character": "error",
556
+ // Detect when .matchAll() regex is missing /g in a way that catches runtime error
557
+ "regexp/no-missing-g-flag": "error",
558
+ // Catch misleading usages of - in regex
559
+ "regexp/no-obscure-range": "error",
560
+ // Catch redundant regex syntax
561
+ "regexp/no-optional-assertion": "error",
562
+ // Catch redundant regex syntax
563
+ "regexp/no-trivially-nested-assertion": "error",
564
+ // Catch redundant regex syntax
565
+ "regexp/no-trivially-nested-quantifier": "error",
566
+ // Catch redundant regex syntax
567
+ "regexp/no-useless-assertions": "error",
568
+ // Catch redundant regex syntax
569
+ "regexp/no-useless-backreference": "error",
570
+ // Catch redundant regex syntax
571
+ "regexp/no-useless-character-class": "error",
572
+ // Catch redundant regex syntax
573
+ "regexp/no-useless-dollar-replacements": "error",
574
+ // Adds auto-fix and additional checks compared to `no-useless-escape`
575
+ "regexp/no-useless-escape": "error",
576
+ // Catch redundant regex syntax
577
+ "regexp/no-useless-lazy": "error",
578
+ // Catch redundant regex syntax
579
+ "regexp/no-useless-quantifier": "error",
580
+ // Catch redundant regex syntax
581
+ "regexp/no-useless-range": "error",
582
+ // Catch redundant regex syntax
583
+ "regexp/no-useless-set-operand": "error",
584
+ // Catch redundant regex syntax
585
+ "regexp/no-useless-string-literal": "error",
586
+ // Catch redundant regex syntax
587
+ "regexp/no-useless-two-nums-quantifier": "error",
588
+ // Catch redundant regex syntax
589
+ "regexp/optimal-quantifier-concatenation": "error",
590
+ // Catch redundant regex syntax
591
+ "regexp/prefer-predefined-assertion": "error",
592
+ // Catch redundant regex syntax
593
+ "regexp/prefer-range": "error",
594
+ // Encourage usage of modern regex features
595
+ "regexp/prefer-set-operation": "error",
596
+ // Catch redundant date cloning syntax
597
+ "unicorn/consistent-date-clone": "error",
598
+ // Use [] over '' when spreading in arrays (readability only - no runtime difference)
599
+ "unicorn/consistent-empty-array-spread": "error",
600
+ // If need to disable ESLint, encourage disabling a single rule rather than all
601
+ "unicorn/no-abusive-eslint-disable": "error",
602
+ // Detect getter accessing itself - causes a runtime loop
603
+ "unicorn/no-accessor-recursion": "error",
604
+ // Detect Promise.all([await a]) when await Promise.all([a]) was meant
605
+ "unicorn/no-await-in-promise-methods": "error",
606
+ // Forbid unsafe usage of instanceof
607
+ "unicorn/no-instanceof-builtins": "error",
608
+ // Catch .removeEventListener usages that don't work
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
613
+ "unicorn/no-negation-in-equality-check": "error",
614
+ // Catch redundant promise syntax
615
+ "unicorn/no-single-promise-in-promise-methods": "error",
616
+ // Prefer === undefined over typeof bar === 'undefined'
617
+ "unicorn/no-typeof-undefined": "error",
618
+ // Prefer .flat() over .flat(1)
619
+ "unicorn/no-unnecessary-array-flat-depth": "error",
620
+ // Prefer .splice(1) over .splice(1, string.length);
621
+ "unicorn/no-unnecessary-array-splice-count": "error",
622
+ // Catch redundant .slice() syntax
623
+ "unicorn/no-unnecessary-slice-end": "error",
624
+ // Catch redundant spread syntax
625
+ "unicorn/no-useless-fallback-in-spread": "error",
626
+ // Replace .some() with .every() or the opposite when it simplifies the code
627
+ "unicorn/no-useless-length-check": "error",
628
+ // Catch redundant promise syntax
629
+ "unicorn/no-useless-promise-resolve-reject": "error",
630
+ // Catch redundant spread syntax usage
631
+ "unicorn/no-useless-spread": "error",
632
+ // Do not initialize variables with =undefined as that is the default
633
+ "unicorn/no-useless-undefined": ["error", { checkArguments: false, checkArrowFunctionBody: false }],
634
+ // Prefer .find() over .filter()[0]
635
+ "unicorn/prefer-array-find": "error",
636
+ // Use .flat() over older workaround syntaxes
637
+ "unicorn/prefer-array-flat": "error",
638
+ // Prefer .flatMap() over .map().flat()
639
+ "unicorn/prefer-array-flat-map": "error",
640
+ // Prefer .indexOf() over .findIndex() where possible
641
+ "unicorn/prefer-array-index-of": "error",
642
+ // Use .some() over .filter().length>0
643
+ "unicorn/prefer-array-some": "error",
644
+ // Use newer methods when working with blobs
645
+ "unicorn/prefer-blob-reading-methods": "error",
646
+ // Prefer Date.now() over older longer but equivalent variants
647
+ "unicorn/prefer-date-now": "error",
648
+ // Catch legacy default-values syntax
649
+ "unicorn/prefer-default-parameters": "error",
650
+ // Use .includes() over .indexOf() where possible for readability
651
+ "unicorn/prefer-includes": "error",
652
+ // Prefer `a ?? b` over `a ? a : b`
653
+ "unicorn/prefer-logical-operator-over-ternary": "error",
654
+ // Prefer simpler syntax for .slice() from the end
655
+ "unicorn/prefer-negative-index": "error",
656
+ // Require `node:` in node.js imports. Improves compatibility with non-node engines
657
+ "unicorn/prefer-node-protocol": "error",
658
+ // TODO: consider dropping - string.match(regex) is more readable
659
+ "unicorn/prefer-regexp-test": "error",
660
+ // Prefer sets over arrays when using the array only for .includes() check
661
+ "unicorn/prefer-set-has": "error",
662
+ // Simplify code when set .size is needed
663
+ "unicorn/prefer-set-size": "error",
664
+ // Use .replaceAll() over .replace() when replaceAll was meant. Readability.
665
+ "unicorn/prefer-string-replace-all": "error",
666
+ // Use .slice() over legacy .substring() and .substr()
667
+ "unicorn/prefer-string-slice": "error",
668
+ // Prefer .startsWith() over regex when they are equivalent for readability
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)
672
+ "unicorn/throw-new-error": "error",
673
+ // See https://devtopia.esri.com/WebGIS/webgis-sdk/pull/15335#discussion_r1683898
674
+ "webgis/consistent-constructor-arguments": "error",
675
+ "webgis/consistent-mixin-syntax": "error",
676
+ "webgis/no-empty-catch": "error",
677
+ // Use JSX props over attributes because TypeScript does not type check attributes
678
+ "webgis/no-kebab-case-props": "error",
679
+ // Require type="" parameter on buttons to avoid unexpected button behavior inside forms
680
+ "webgis/require-button-type": "error"
681
+ }
682
+ },
683
+ {
684
+ files: ["packages/core-packages/**/*.md"],
685
+ rules: {
686
+ ...disabledRules(disabledCoreMarkdownOverrides)
687
+ }
688
+ },
689
+ {
690
+ files: ["packages/core-packages/core/package.json"],
691
+ rules: {
692
+ ...disabledRules(disabledCorePackageJsonRules)
693
+ }
694
+ },
695
+ {
696
+ files: ["packages/core-packages/**/*.d.ts"],
697
+ rules: {
698
+ ...disabledRules(disabledCoreDeclarationRules)
699
+ }
700
+ },
701
+ {
702
+ // Type-aware rules
703
+ files: ["packages/core-packages/**/*.{ts,tsx}"],
704
+ ignores: [...coreTypedRulesIgnoredFiles],
705
+ rules: {
706
+ "@typescript-eslint/no-array-delete": "error",
707
+ "@typescript-eslint/no-floating-promises": "error",
708
+ "@typescript-eslint/no-for-in-array": "error",
709
+ "@typescript-eslint/no-meaningless-void-operator": "error",
710
+ "@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
711
+ "@typescript-eslint/no-unsafe-unary-minus": "error",
712
+ "@typescript-eslint/prefer-find": "error",
713
+ "@typescript-eslint/prefer-includes": "error",
714
+ "@typescript-eslint/prefer-optional-chain": ["error", { requireNullish: true }],
715
+ "@typescript-eslint/prefer-string-starts-ends-with": "error",
716
+ "@typescript-eslint/return-await": ["error", "error-handling-correctness-only"]
717
+ }
718
+ },
719
+ {
720
+ // The base config enables typed rules for all .ts files.
721
+ // Core has .ts files that are not typed rules ready.
722
+ // Disable the typed rules for those.
723
+ files: [...coreTypedRulesIgnoredFiles],
724
+ languageOptions: {
725
+ parserOptions: {
726
+ projectService: false
727
+ }
728
+ },
729
+ rules: {
730
+ ...disabledRules(disabledCoreTypedOverrides)
731
+ }
732
+ },
733
+ {
734
+ files: ["packages/core-packages/**/*.tsx"],
735
+ plugins: {
736
+ "perfectionist": perfectionistPlugin,
737
+ "react-jsx": reactJsxPlugin
738
+ },
739
+ rules: {
740
+ // Sort JSX props consistently. Improves readability for large JSX blocks
741
+ "perfectionist/sort-jsx-props": [
742
+ "error",
743
+ {
744
+ groups: ["unknown", "callback"],
745
+ customGroups: [{ groupName: "callback", elementNamePattern: "^on.+" }]
746
+ }
747
+ ],
748
+ // Require passing JSX children as content rather than as children={} prop
749
+ "react-jsx/no-children-prop": "error",
750
+ // Catch JSX comment syntax error
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
756
+ "react-jsx/no-useless-fragment": "error"
757
+ }
758
+ },
759
+ {
760
+ files: ["packages/core-packages/core/src/**/*.{ts,tsx}"],
761
+ rules: {
762
+ "core/no-invalid-declared-class": "error"
763
+ }
764
+ },
765
+ {
766
+ files: ["packages/core-packages/core/src/**/*.{ts,tsx}"],
767
+ ignores: ["packages/core-packages/core/src/**/*.d.ts"],
768
+ rules: {
769
+ "no-restricted-syntax": noRestrictedSyntax
770
+ }
771
+ },
772
+ {
773
+ files: ["packages/core-packages/core/src/**/*.{ts,tsx}"],
774
+ ignores: ["packages/core-packages/core/src/arcade/**", "packages/core-packages/core/src/widgets/**"],
775
+ rules: {
776
+ "webgis/no-instanceof": "error"
777
+ }
778
+ },
779
+ {
780
+ files: ["packages/core-packages/core/tests/**/*.{ts,tsx}"],
781
+ rules: {
782
+ "@typescript-eslint/no-restricted-imports": [
783
+ "error",
784
+ {
785
+ patterns: [
786
+ {
787
+ group: ["*.spec", "*.spec.*", "**/*.spec", "**/*.spec.*"],
788
+ message: "Do not import test suites (.spec) from other tests. Move shared helpers to tests/support (use the test-support/* alias)."
789
+ }
790
+ ]
791
+ }
792
+ ],
793
+ "core/spec-suite-filename": "error",
794
+ "no-restricted-syntax": [
795
+ ...noRestrictedSyntax,
796
+ {
797
+ message: "The { only: true } test option may be used during local testing, but can not be committed.",
798
+ selector: "CallExpression ObjectExpression Property[key.name='only'][value.value='true']"
799
+ },
800
+ {
801
+ message: "test.only may be used during local testing, but can not be committed.",
802
+ selector: "CallExpression[callee.type='MemberExpression'][callee.object.name='test'] > MemberExpression.callee > Identifier.property[name='only']"
803
+ },
804
+ {
805
+ message: "The { repeatUntilFailure: true } test option may be used during local testing, but can not be committed.",
806
+ selector: "CallExpression ObjectExpression Property[key.name='repeatUntilFailure'][value.value='true']"
807
+ },
808
+ {
809
+ message: "test.repeatUntilFailure may be used during local testing, but can not be committed.",
810
+ selector: "CallExpression[callee.type='MemberExpression'][callee.object.name='test'] > MemberExpression.callee > Identifier.property[name='repeatUntilFailure']"
811
+ },
812
+ {
813
+ selector: "CallExpression MemberExpression[object.name='has'][property.name='add']",
814
+ message: "Avoid adding has flags manually. Instead use the suite/test-level options to set has flags."
815
+ }
816
+ ],
817
+ // Require awaiting assert.screenshot() in tests
818
+ "webgis/require-await-for-async-screenshot-assert": "error"
819
+ }
820
+ }
821
+ ];
822
+ export {
823
+ eslintConfigCore as default
824
+ };