@arcgis/eslint-config 5.2.0-next.12 → 5.2.0-next.121

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,720 @@
1
+ import markdown from "@eslint/markdown";
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 tsEslint from "typescript-eslint";
9
+ import { corePlugin } from "../plugins/core/index.js";
10
+ const noRestrictedSyntax = [
11
+ "error",
12
+ "AccessorProperty",
13
+ "PrivateIdentifier",
14
+ {
15
+ selector: "CallExpression[callee.property.name='concat'][arguments.length=0]",
16
+ message: "Use slice() instead of concat()."
17
+ },
18
+ {
19
+ selector: "CallExpression[callee.property.name='slice'][arguments.length=1] > .arguments[value=0]",
20
+ message: "Use slice() instead of slice(0)."
21
+ },
22
+ {
23
+ selector: "TSAbstractPropertyDefinition[decorators.length>0]",
24
+ message: "Decorators are not supported on abstract properties."
25
+ },
26
+ {
27
+ selector: "TSEnumDeclaration:not([const=true])",
28
+ 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"
29
+ },
30
+ {
31
+ selector: "VariableDeclarator > CallExpression > MemberExpression[property.name='getLogger']",
32
+ message: "Get a logger as needed instead of assigning it for future use."
33
+ },
34
+ {
35
+ selector: "TSModuleDeclaration[id.type='Identifier']",
36
+ message: "Use const objects or static classes instead. See https://devtopia.esri.com/WebGIS/arcgis-js-api/discussions/72194"
37
+ }
38
+ ];
39
+ const disabledMarkdownRules = Object.fromEntries(
40
+ Object.keys(markdown.rules).map((ruleName) => [`markdown/${ruleName}`, "off"])
41
+ );
42
+ const coreTypedRulesIgnoredFiles = [
43
+ // We didn't run typed rules on these files before
44
+ "packages/core-packages/core/*.{ts,tsx}",
45
+ "packages/core-packages/core/{.github,build,scripts,tasks,test-apps,typings}/**/*.{ts,tsx}",
46
+ // This folder runs in node, so uses a separate tsconfig.json
47
+ "packages/core-packages/core/tests/support/vitest/node/**/*.ts"
48
+ ];
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
+ const eslintConfigCore = [
57
+ {
58
+ files: ["packages/core-packages/**/*.{ts,tsx}"],
59
+ linterOptions: {
60
+ reportUnusedDisableDirectives: "off"
61
+ },
62
+ plugins: {
63
+ core: corePlugin,
64
+ jsdoc: jsdocPlugin,
65
+ regexp: regexpPlugin,
66
+ unicorn: unicornPlugin
67
+ },
68
+ settings: {
69
+ jsdoc: {
70
+ tagNamePreference: {
71
+ // Our tags
72
+ "public": "public",
73
+ "internal": "internal",
74
+ "copyDoc": "copyDoc",
75
+ // Flags
76
+ "beta": "beta",
77
+ "experimental": "experimental",
78
+ "knipIgnore": "knipIgnore",
79
+ "readonly": "readonly",
80
+ // Metadata
81
+ "deprecated": "deprecated",
82
+ "default": "default",
83
+ "since": "since",
84
+ "param": "param",
85
+ "returns": "returns",
86
+ "see": "see",
87
+ "esriCompatibilityName": "esriCompatibilityName",
88
+ // Not yet officially supported, but not forbidden
89
+ "throws": "throws",
90
+ // Long descriptions
91
+ "example": "example",
92
+ "privateRemarks": "privateRemarks",
93
+ // Legacy replacements
94
+ "const": "readonly",
95
+ "constant": "readonly",
96
+ "defaultvalue": "default",
97
+ "return": "returns",
98
+ // Forbid JSDoc tags that are redundant with TypeScript or not used by the docs ui
99
+ // eslint-plugin-jsdoc allows all these by default, so we need to explicitly disable them
100
+ "abstract": false,
101
+ "access": false,
102
+ "alias": false,
103
+ "arg": false,
104
+ "argument": false,
105
+ "async": false,
106
+ "augments": false,
107
+ "author": false,
108
+ "borrows": false,
109
+ "callback": false,
110
+ "class": false,
111
+ "classdesc": false,
112
+ "collectionItemType": false,
113
+ "constructor": false,
114
+ "constructs": false,
115
+ "copyright": false,
116
+ "deprecatedParameters": false,
117
+ "deprecatedProperties": false,
118
+ "desc": false,
119
+ "description": false,
120
+ "emits": false,
121
+ "enum": false,
122
+ "esmimport": false,
123
+ "event": false,
124
+ "exception": false,
125
+ "exports": false,
126
+ "extends": false,
127
+ "external": false,
128
+ "file": false,
129
+ "fileoverview": false,
130
+ "fires": false,
131
+ "func": false,
132
+ "function": false,
133
+ "generator": false,
134
+ "global": false,
135
+ "hideconstructor": false,
136
+ "host": false,
137
+ "ignore": false,
138
+ "implements": false,
139
+ "inheritDoc": false,
140
+ "inheritdoc": false,
141
+ "inner": false,
142
+ "instance": false,
143
+ "interface": false,
144
+ "kind": false,
145
+ "lends": false,
146
+ "license": false,
147
+ "listens": false,
148
+ "member": false,
149
+ "memberof!": false,
150
+ "memberof": false,
151
+ "method": false,
152
+ "mixes": false,
153
+ "mixin": false,
154
+ "modifies": false,
155
+ "module": false,
156
+ "moduletype": false,
157
+ "name": false,
158
+ "namespace": false,
159
+ "override": false,
160
+ "overview": false,
161
+ "package": false,
162
+ "private": false,
163
+ "prop": false,
164
+ "property": false,
165
+ "protected": false,
166
+ "requires": false,
167
+ "static": false,
168
+ "summary": false,
169
+ "tag constructor": false,
170
+ "this": false,
171
+ "tstype": false,
172
+ "tutorial": false,
173
+ "type": false,
174
+ "typedef": false,
175
+ "var": false,
176
+ "variation": false,
177
+ "version": false,
178
+ "virtual": false,
179
+ "yield": false,
180
+ "yields": false,
181
+ "import": false,
182
+ "overload": false,
183
+ "satisfies": false,
184
+ "template": false
185
+ }
186
+ }
187
+ },
188
+ 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
318
+ "@typescript-eslint/ban-ts-comment": ["error", { "ts-expect-error": false, "ts-nocheck": false }],
319
+ "@typescript-eslint/consistent-type-definitions": ["error", "interface"],
320
+ "@typescript-eslint/explicit-function-return-type": ["error", { allowExpressions: true }],
321
+ "@typescript-eslint/explicit-member-accessibility": ["error", { accessibility: "no-public" }],
322
+ "@typescript-eslint/naming-convention": [
323
+ "error",
324
+ { selector: ["typeLike"], format: ["PascalCase"] },
325
+ {
326
+ selector: ["function", "classMethod", "classProperty", "typeMethod"],
327
+ format: ["camelCase"],
328
+ leadingUnderscore: "allow"
329
+ },
330
+ {
331
+ selector: ["memberLike", "classProperty"],
332
+ modifiers: ["private"],
333
+ format: ["camelCase"],
334
+ leadingUnderscore: "require"
335
+ },
336
+ {
337
+ selector: ["classProperty"],
338
+ modifiers: ["static"],
339
+ format: ["UPPER_CASE", "PascalCase", "camelCase"],
340
+ leadingUnderscore: "allow"
341
+ },
342
+ {
343
+ selector: ["classProperty"],
344
+ modifiers: ["private", "static"],
345
+ format: ["UPPER_CASE", "PascalCase", "camelCase"],
346
+ leadingUnderscore: "allow"
347
+ }
348
+ ],
349
+ "@typescript-eslint/no-array-constructor": "error",
350
+ "@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
+ "@typescript-eslint/no-require-imports": "error",
354
+ "@typescript-eslint/no-restricted-imports": [
355
+ "error",
356
+ {
357
+ paths: [
358
+ { name: "esri/identity/IdentityManager", message: "Use `esri/kernel.id` or the `authMode` option." },
359
+ {
360
+ name: "esri/layers/support/rasterFunctionUtils",
361
+ message: "Import raster function creators directly instead."
362
+ },
363
+ {
364
+ name: "esri/TimeExtent",
365
+ message: "Use `esri/time/TimeExtent` instead. See https://devtopia.esri.com/WebGIS/arcgis-js-api/issues/49223."
366
+ },
367
+ {
368
+ name: "esri/TimeInterval",
369
+ message: "Use `esri/time/TimeInterval` instead. See https://devtopia.esri.com/WebGIS/arcgis-js-api/issues/49223."
370
+ },
371
+ { name: "esri/rest/geometryService", message: "Import geometry services directly instead" },
372
+ { name: "esri/rest/geoprocessor", message: "Import geoprocessor exports directly instead" },
373
+ { name: "esri/rest/locator", message: "Import locator exports directly instead" },
374
+ { name: "esri/rest/query", message: "use individual files instead" }
375
+ ],
376
+ patterns: [
377
+ {
378
+ group: ["@esri/calcite-components/dist/components/*"],
379
+ message: "Pass a dynamic import to `loadCalciteComponents` inside `loadDependencies` instead.",
380
+ allowTypeImports: true
381
+ }
382
+ ]
383
+ }
384
+ ],
385
+ "@typescript-eslint/no-unnecessary-parameter-property-assignment": "error",
386
+ "@typescript-eslint/no-unused-expressions": ["error", { allowShortCircuit: true, allowTernary: true }],
387
+ "@typescript-eslint/no-unused-vars": [
388
+ "error",
389
+ {
390
+ args: "all",
391
+ argsIgnorePattern: "^_",
392
+ caughtErrors: "none",
393
+ destructuredArrayIgnorePattern: "^_",
394
+ varsIgnorePattern: "^_|^tsx",
395
+ ignoreRestSiblings: true,
396
+ enableAutofixRemoval: { imports: true }
397
+ }
398
+ ],
399
+ "@typescript-eslint/prefer-namespace-keyword": "error",
400
+ "arrow-body-style": "error",
401
+ "core/glsl-whitespace": "error",
402
+ "core/imports-format": "error",
403
+ "core/no-duplicate-import-comments": "error",
404
+ "core/no-empty-jsdoc-todo": "error",
405
+ "core/no-redundant-checked-in-files": "error",
406
+ "core/prefer-relative-imports": "error",
407
+ "core/require-calcite-import": "error",
408
+ "curly": "error",
409
+ "eqeqeq": ["error", "smart"],
410
+ "import-x/no-duplicates": "error",
411
+ "import-x/no-dynamic-require": ["error", { esmodule: true }],
412
+ "import-x/no-restricted-paths": [
413
+ "error",
414
+ {
415
+ // This is temporary. Once most of this config is merged with the
416
+ // root @arcgis/eslint-config, the core-specific rules can be moved
417
+ // into @webgis/monorepo-config
418
+ basePath: join(import.meta.dirname, "../../../../core-packages/core"),
419
+ zones: [
420
+ {
421
+ target: "src",
422
+ from: "src/identity/IdentityManager.ts",
423
+ message: "Use `kernel.id` or the `authMode` request option."
424
+ },
425
+ {
426
+ target: "src",
427
+ from: "src/layers/support/rasterFunctionUtils.ts",
428
+ message: "Import raster function creators directly instead."
429
+ },
430
+ {
431
+ target: "src",
432
+ from: "src/rest/geometryService.ts",
433
+ message: "Import the `geometryService` exports directly instead."
434
+ },
435
+ {
436
+ target: "src",
437
+ from: "src/rest/geoprocessor.ts",
438
+ message: "Import the geoprocessor exports directly instead."
439
+ },
440
+ {
441
+ target: "src",
442
+ from: "src/rest/locator.ts",
443
+ message: "Import the locator exports directly instead."
444
+ },
445
+ {
446
+ target: "src",
447
+ from: "src/rest/query.ts",
448
+ message: "Import the query exports directly instead"
449
+ },
450
+ {
451
+ target: "src",
452
+ from: "tests",
453
+ message: "Modules in /src should not import modules in /tests."
454
+ }
455
+ ]
456
+ }
457
+ ],
458
+ "import-x/no-useless-path-segments": "error",
459
+ "jsdoc/check-tag-names": [
460
+ "error",
461
+ { definedTags: ["tstype", "ignoreNilOnly", "noautocast", "collectionItemType"] }
462
+ ],
463
+ "jsdoc/check-types": "error",
464
+ // Ensure @readonly and @public is used without any content
465
+ "jsdoc/empty-tags": "error",
466
+ // Avoid /**\n ** something */
467
+ "jsdoc/no-multi-asterisks": ["error", { allowWhitespace: true }],
468
+ // Enforce each JSDoc line starts with *
469
+ "jsdoc/require-asterisk-prefix": "error",
470
+ // Enforce @param has param name
471
+ "jsdoc/require-param-name": "error",
472
+ "no-array-constructor": "off",
473
+ "no-async-promise-executor": "error",
474
+ "no-caller": "error",
475
+ "no-case-declarations": "error",
476
+ "no-cond-assign": "error",
477
+ "no-constant-binary-expression": "error",
478
+ "no-control-regex": "error",
479
+ "no-debugger": "error",
480
+ "no-duplicate-case": "error",
481
+ "no-else-return": "error",
482
+ "no-eval": "error",
483
+ "no-fallthrough": ["error", { reportUnusedFallthroughComment: false }],
484
+ "no-implied-eval": "error",
485
+ "no-inner-declarations": "error",
486
+ "no-labels": ["error", { allowLoop: true, allowSwitch: true }],
487
+ "no-new-func": "error",
488
+ "no-new-wrappers": "error",
489
+ "no-redeclare": "off",
490
+ "no-regex-spaces": "error",
491
+ "no-restricted-globals": ["error", "event", "name", "origin"],
492
+ "no-shadow-restricted-names": "error",
493
+ "no-throw-literal": "error",
494
+ "no-unsafe-finally": "error",
495
+ "no-unsafe-optional-chaining": "error",
496
+ "no-unused-expressions": "off",
497
+ "no-unused-vars": "off",
498
+ "no-useless-escape": "error",
499
+ "no-useless-rename": "error",
500
+ "no-var": "error",
501
+ "object-shorthand": "error",
502
+ "one-var": ["error", { initialized: "never" }],
503
+ "prefer-const": ["error", { destructuring: "all" }],
504
+ "prefer-exponentiation-operator": "error",
505
+ "radix": "error",
506
+ "regexp/control-character-escape": "error",
507
+ "regexp/no-dupe-characters-character-class": "error",
508
+ "regexp/no-dupe-disjunctions": "error",
509
+ "regexp/no-empty-alternative": "error",
510
+ "regexp/no-empty-capturing-group": "error",
511
+ "regexp/no-empty-character-class": "error",
512
+ "regexp/no-empty-group": "error",
513
+ "regexp/no-empty-lookarounds-assertion": "error",
514
+ "regexp/no-escape-backspace": "error",
515
+ "regexp/no-extra-lookaround-assertions": "error",
516
+ "regexp/no-invalid-regexp": "error",
517
+ "regexp/no-invisible-character": "error",
518
+ "regexp/no-lazy-ends": "error",
519
+ "regexp/no-misleading-unicode-character": "error",
520
+ "regexp/no-missing-g-flag": "error",
521
+ "regexp/no-obscure-range": "error",
522
+ "regexp/no-optional-assertion": "error",
523
+ "regexp/no-trivially-nested-assertion": "error",
524
+ "regexp/no-trivially-nested-quantifier": "error",
525
+ "regexp/no-useless-assertions": "error",
526
+ "regexp/no-useless-backreference": "error",
527
+ "regexp/no-useless-character-class": "error",
528
+ "regexp/no-useless-dollar-replacements": "error",
529
+ "regexp/no-useless-escape": "error",
530
+ // adds auto-fix and additional checks compared to `no-useless-escape`
531
+ "regexp/no-useless-lazy": "error",
532
+ "regexp/no-useless-quantifier": "error",
533
+ "regexp/no-useless-range": "error",
534
+ "regexp/no-useless-set-operand": "error",
535
+ "regexp/no-useless-string-literal": "error",
536
+ "regexp/no-useless-two-nums-quantifier": "error",
537
+ "regexp/optimal-quantifier-concatenation": "error",
538
+ "regexp/prefer-predefined-assertion": "error",
539
+ "regexp/prefer-range": "error",
540
+ "regexp/prefer-set-operation": "error",
541
+ "unicorn/consistent-date-clone": "error",
542
+ "unicorn/consistent-empty-array-spread": "error",
543
+ "unicorn/no-abusive-eslint-disable": "error",
544
+ "unicorn/no-accessor-recursion": "error",
545
+ "unicorn/no-await-in-promise-methods": "error",
546
+ "unicorn/no-instanceof-builtins": "error",
547
+ "unicorn/no-invalid-remove-event-listener": "error",
548
+ "unicorn/no-negation-in-equality-check": "error",
549
+ "unicorn/no-single-promise-in-promise-methods": "error",
550
+ "unicorn/no-typeof-undefined": "error",
551
+ "unicorn/no-unnecessary-array-flat-depth": "error",
552
+ "unicorn/no-unnecessary-array-splice-count": "error",
553
+ "unicorn/no-unnecessary-slice-end": "error",
554
+ "unicorn/no-useless-fallback-in-spread": "error",
555
+ "unicorn/no-useless-length-check": "error",
556
+ "unicorn/no-useless-promise-resolve-reject": "error",
557
+ "unicorn/no-useless-spread": "error",
558
+ "unicorn/no-useless-undefined": ["error", { checkArguments: false, checkArrowFunctionBody: false }],
559
+ "unicorn/prefer-array-find": "error",
560
+ "unicorn/prefer-array-flat": "error",
561
+ "unicorn/prefer-array-flat-map": "error",
562
+ "unicorn/prefer-array-index-of": "error",
563
+ "unicorn/prefer-array-some": "error",
564
+ "unicorn/prefer-blob-reading-methods": "error",
565
+ "unicorn/prefer-date-now": "error",
566
+ "unicorn/prefer-default-parameters": "error",
567
+ "unicorn/prefer-includes": "error",
568
+ "unicorn/prefer-logical-operator-over-ternary": "error",
569
+ "unicorn/prefer-negative-index": "error",
570
+ "unicorn/prefer-node-protocol": "error",
571
+ "unicorn/prefer-regexp-test": "error",
572
+ "unicorn/prefer-set-has": "error",
573
+ "unicorn/prefer-set-size": "error",
574
+ "unicorn/prefer-string-replace-all": "error",
575
+ "unicorn/prefer-string-slice": "error",
576
+ "unicorn/prefer-string-starts-ends-with": "error",
577
+ "unicorn/throw-new-error": "error",
578
+ "webgis/consistent-constructor-arguments": "error",
579
+ "webgis/consistent-mixin-syntax": "error",
580
+ "webgis/no-empty-catch": "error",
581
+ "webgis/no-kebab-case-props": "error",
582
+ "webgis/require-button-type": "error"
583
+ //#endregion
584
+ }
585
+ },
586
+ {
587
+ files: ["packages/core-packages/**/*.md"],
588
+ rules: disabledMarkdownRules
589
+ },
590
+ {
591
+ files: ["packages/core-packages/core/package.json"],
592
+ rules: {
593
+ // @typescript/native-preview temporarily uses the `beta` tag rather than a semver range.
594
+ "package-json/valid-devDependencies": "off"
595
+ }
596
+ },
597
+ {
598
+ files: ["packages/core-packages/**/*.d.ts"],
599
+ rules: {
600
+ "@typescript-eslint/naming-convention": "off"
601
+ // we can't enforce names in libraries
602
+ }
603
+ },
604
+ {
605
+ // Type-aware rules
606
+ files: ["packages/core-packages/**/*.{ts,tsx}"],
607
+ ignores: [...coreTypedRulesIgnoredFiles],
608
+ rules: {
609
+ // Disabled until https://github.com/typescript-eslint/typescript-eslint/pull/11267 is available.
610
+ "@typescript-eslint/await-thenable": "off",
611
+ "@typescript-eslint/no-array-delete": "error",
612
+ "@typescript-eslint/no-floating-promises": "error",
613
+ "@typescript-eslint/no-for-in-array": "error",
614
+ "@typescript-eslint/no-meaningless-void-operator": "error",
615
+ "@typescript-eslint/no-misused-promises": ["error", { checksVoidReturn: false }],
616
+ "@typescript-eslint/no-unsafe-unary-minus": "error",
617
+ "@typescript-eslint/prefer-find": "error",
618
+ "@typescript-eslint/prefer-includes": "error",
619
+ "@typescript-eslint/prefer-optional-chain": ["error", { requireNullish: true }],
620
+ "@typescript-eslint/prefer-string-starts-ends-with": "error",
621
+ "@typescript-eslint/return-await": ["error", "error-handling-correctness-only"]
622
+ }
623
+ },
624
+ {
625
+ // The base config enables typed rules for all .ts files.
626
+ // Core has .ts files that are not typed rules ready.
627
+ // Disable the typed rules for those.
628
+ files: [...coreTypedRulesIgnoredFiles],
629
+ languageOptions: {
630
+ parserOptions: {
631
+ projectService: false
632
+ }
633
+ },
634
+ rules: disabledCoreTypeCheckedRules
635
+ },
636
+ {
637
+ files: ["packages/core-packages/**/*.tsx"],
638
+ plugins: {
639
+ "perfectionist": perfectionistPlugin,
640
+ "react-jsx": reactJsxPlugin
641
+ },
642
+ rules: {
643
+ "perfectionist/sort-jsx-props": [
644
+ "error",
645
+ {
646
+ groups: ["unknown", "callback"],
647
+ customGroups: [{ groupName: "callback", elementNamePattern: "^on.+" }]
648
+ }
649
+ ],
650
+ "react-jsx/no-children-prop": "error",
651
+ "react-jsx/no-comment-textnodes": "error",
652
+ "react-jsx/no-useless-fragment": "error"
653
+ }
654
+ },
655
+ {
656
+ files: ["packages/core-packages/core/src/**/*.{ts,tsx}"],
657
+ rules: {
658
+ "core/no-invalid-declared-class": "error"
659
+ }
660
+ },
661
+ {
662
+ files: ["packages/core-packages/core/src/**/*.{ts,tsx}"],
663
+ ignores: ["packages/core-packages/core/src/**/*.d.ts"],
664
+ rules: {
665
+ "no-restricted-syntax": noRestrictedSyntax
666
+ }
667
+ },
668
+ {
669
+ files: ["packages/core-packages/core/src/**/*.{ts,tsx}"],
670
+ ignores: ["packages/core-packages/core/src/arcade/**", "packages/core-packages/core/src/widgets/**"],
671
+ rules: {
672
+ "webgis/no-instanceof": "error"
673
+ }
674
+ },
675
+ {
676
+ files: ["packages/core-packages/core/tests/**/*.{ts,tsx}"],
677
+ rules: {
678
+ "webgis/no-instanceof": "off",
679
+ "@typescript-eslint/no-restricted-imports": [
680
+ "error",
681
+ {
682
+ patterns: [
683
+ {
684
+ group: ["*.spec", "*.spec.*", "**/*.spec", "**/*.spec.*"],
685
+ message: "Do not import test suites (.spec) from other tests. Move shared helpers to tests/support (use the test-support/* alias)."
686
+ }
687
+ ]
688
+ }
689
+ ],
690
+ "core/spec-suite-filename": "error",
691
+ "no-restricted-syntax": [
692
+ ...noRestrictedSyntax,
693
+ {
694
+ message: "The { only: true } test option may be used during local testing, but can not be committed.",
695
+ selector: "CallExpression ObjectExpression Property[key.name='only'][value.value='true']"
696
+ },
697
+ {
698
+ message: "test.only may be used during local testing, but can not be committed.",
699
+ selector: "CallExpression[callee.type='MemberExpression'][callee.object.name='test'] > MemberExpression.callee > Identifier.property[name='only']"
700
+ },
701
+ {
702
+ message: "The { repeatUntilFailure: true } test option may be used during local testing, but can not be committed.",
703
+ selector: "CallExpression ObjectExpression Property[key.name='repeatUntilFailure'][value.value='true']"
704
+ },
705
+ {
706
+ message: "test.repeatUntilFailure may be used during local testing, but can not be committed.",
707
+ selector: "CallExpression[callee.type='MemberExpression'][callee.object.name='test'] > MemberExpression.callee > Identifier.property[name='repeatUntilFailure']"
708
+ },
709
+ {
710
+ selector: "CallExpression MemberExpression[object.name='has'][property.name='add']",
711
+ message: "Avoid adding has flags manually. Instead use the suite/test-level options to set has flags."
712
+ }
713
+ ],
714
+ "webgis/require-await-for-async-screenshot-assert": "error"
715
+ }
716
+ }
717
+ ];
718
+ export {
719
+ eslintConfigCore as default
720
+ };