@arcgis/eslint-config 4.33.0-next.99 → 4.34.0-next.1
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.
- package/dist/config/applications.d.ts +5 -0
- package/dist/config/applications.js +40 -0
- package/dist/config/index.d.ts +1 -1
- package/dist/config/index.js +45 -95
- package/dist/config/lumina.js +0 -6
- package/dist/{makePlugin-DjYsAJ7j.js → makePlugin-DiZ5PMHq.js} +1 -1
- package/dist/plugins/lumina/index.js +91 -10
- package/dist/plugins/lumina/rules/consistent-nullability.d.ts +2 -0
- package/dist/plugins/webgis/index.js +2 -2
- package/package.json +9 -10
- package/dist/plugins/utils/tests.d.ts +0 -28
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
declare const _default: (TSESLint.FlatConfig.Config | import("eslint").Linter.Config<import("eslint").Linter.RulesRecord> | {
|
|
3
|
+
readonly rules: Readonly<import("eslint").Linter.RulesRecord>;
|
|
4
|
+
})[];
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import defaultConfig from "./index.js";
|
|
2
|
+
const applications = [
|
|
3
|
+
...defaultConfig,
|
|
4
|
+
{
|
|
5
|
+
rules: {
|
|
6
|
+
// Not autofixable. Can be annoying
|
|
7
|
+
"@typescript-eslint/ban-ts-comment": "off",
|
|
8
|
+
// Less important in apps than in libraries
|
|
9
|
+
// Though, explicit return type improve TypeScript performance
|
|
10
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
11
|
+
// Less important for non-public APIs.
|
|
12
|
+
// And can be tedious to refactor existing code.
|
|
13
|
+
"@typescript-eslint/max-params": "off",
|
|
14
|
+
// No big harm in letting people do this if they want to
|
|
15
|
+
"@typescript-eslint/no-extraneous-class": "off",
|
|
16
|
+
// A convenient lazy variant, but less safe
|
|
17
|
+
"@typescript-eslint/no-unsafe-function-type": "off",
|
|
18
|
+
// Non-customer-facing code can handle Errors in what way is most convenient
|
|
19
|
+
"@typescript-eslint/only-throw-error": "off",
|
|
20
|
+
// Non-customer-facing code can handle Errors in what way is most convenient
|
|
21
|
+
"@typescript-eslint/prefer-promise-reject-errors": "off",
|
|
22
|
+
// A trade off between developer convenience and code quality
|
|
23
|
+
"@typescript-eslint/no-floating-promises": "off",
|
|
24
|
+
// A trade off between developer convenience and code quality
|
|
25
|
+
"@typescript-eslint/promise-function-async": "off",
|
|
26
|
+
// Let developer decide to add or omit it. If not present, creates
|
|
27
|
+
// worse exception messages.
|
|
28
|
+
"func-names": "off",
|
|
29
|
+
// This rule is for consistency between library developers - less important for monolith apps.
|
|
30
|
+
"id-denylist": "off",
|
|
31
|
+
// Some cases actually require sequential async loops
|
|
32
|
+
"no-await-in-loop": "off",
|
|
33
|
+
// More important for library-exposed symbols than apps
|
|
34
|
+
"symbol-description": "off"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
export {
|
|
39
|
+
applications as default
|
|
40
|
+
};
|
package/dist/config/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
-
declare const _default: (TSESLint.FlatConfig.Config | {
|
|
2
|
+
declare const _default: (TSESLint.FlatConfig.Config | import("eslint").Linter.Config<import("eslint").Linter.RulesRecord> | {
|
|
3
3
|
readonly rules: Readonly<import("eslint").Linter.RulesRecord>;
|
|
4
4
|
})[];
|
|
5
5
|
export default _default;
|
package/dist/config/index.js
CHANGED
|
@@ -3,10 +3,9 @@ import tsEslint from "typescript-eslint";
|
|
|
3
3
|
import restrictedGlobals from "confusing-browser-globals";
|
|
4
4
|
import globals from "globals";
|
|
5
5
|
import { webgisPlugin } from "../plugins/webgis/index.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
},
|
|
6
|
+
import { globalIgnores } from "eslint/config";
|
|
7
|
+
const defaultConfig = [
|
|
8
|
+
globalIgnores(["**/www", "**/dist", "**/assets", "**/coverage", "**/.docs"]),
|
|
10
9
|
eslint.configs.recommended,
|
|
11
10
|
...tsEslint.configs.strictTypeChecked,
|
|
12
11
|
...tsEslint.configs.stylisticTypeChecked,
|
|
@@ -17,7 +16,8 @@ const index = [
|
|
|
17
16
|
{
|
|
18
17
|
files: ["**/*.ts", "**/*.tsx"],
|
|
19
18
|
linterOptions: {
|
|
20
|
-
reportUnusedDisableDirectives: "error"
|
|
19
|
+
reportUnusedDisableDirectives: "error",
|
|
20
|
+
reportUnusedInlineConfigs: "error"
|
|
21
21
|
},
|
|
22
22
|
languageOptions: {
|
|
23
23
|
globals: {
|
|
@@ -74,6 +74,13 @@ const index = [
|
|
|
74
74
|
"valid-typeof": "off",
|
|
75
75
|
// TypeScript reports this
|
|
76
76
|
"@typescript-eslint/prefer-namespace-keyword": "off",
|
|
77
|
+
// TypeScript should catch most cases where this can cause issues
|
|
78
|
+
"@typescript-eslint/no-confusing-void-expression": "off",
|
|
79
|
+
// Many exceptions. Error causes caught by TypeScript. Non-error cases
|
|
80
|
+
// create minor code naming inconsistency only.
|
|
81
|
+
"new-cap": "off",
|
|
82
|
+
// TypeScript reports this
|
|
83
|
+
"no-unreachable": "off",
|
|
77
84
|
//#endregion
|
|
78
85
|
//#region Disable rules Redundant with Prettier
|
|
79
86
|
/**
|
|
@@ -145,8 +152,8 @@ const index = [
|
|
|
145
152
|
"no-extra-bind": "warn",
|
|
146
153
|
"no-multi-assign": "error",
|
|
147
154
|
// Not an error as some external APIs require calling "new" even if we don't
|
|
148
|
-
// care about the retune time
|
|
149
|
-
"no-new": "
|
|
155
|
+
// care about the retune time. Controllers also use this pattern
|
|
156
|
+
"no-new": "off",
|
|
150
157
|
"no-useless-computed-key": ["warn", { enforceForClassMembers: true }],
|
|
151
158
|
"no-useless-concat": "error",
|
|
152
159
|
"no-unneeded-ternary": "warn",
|
|
@@ -161,14 +168,18 @@ const index = [
|
|
|
161
168
|
"error",
|
|
162
169
|
"i",
|
|
163
170
|
"index",
|
|
164
|
-
{
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
{
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
171
|
+
{
|
|
172
|
+
name: "isNaN",
|
|
173
|
+
message: "Use Number.isNaN instead as it has more predictable behavior. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN#description"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
name: "isFinite",
|
|
177
|
+
message: "Use Number.isFinite instead as it has more predictable behavior. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN#description (same applies to isFinite)"
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: "parseInt",
|
|
181
|
+
message: "Use Number.parseInt instead for more predicable parsing behavior. Also, radix=10 is the default for Number.parseInt, so you can omit it."
|
|
182
|
+
},
|
|
172
183
|
...restrictedGlobals
|
|
173
184
|
],
|
|
174
185
|
"@typescript-eslint/no-useless-empty-export": "warn",
|
|
@@ -252,16 +263,7 @@ const index = [
|
|
|
252
263
|
"prefer-object-has-own": "warn",
|
|
253
264
|
// Lots of false positives
|
|
254
265
|
"@typescript-eslint/no-base-to-string": "off",
|
|
255
|
-
"@typescript-eslint/no-
|
|
256
|
-
"error",
|
|
257
|
-
{
|
|
258
|
-
ignoreArrowShorthand: true,
|
|
259
|
-
ignoreVoidOperator: true
|
|
260
|
-
}
|
|
261
|
-
],
|
|
262
|
-
// Conflicts with @typescript-eslint/no-confusing-void-expression
|
|
263
|
-
// See https://github.com/typescript-eslint/typescript-eslint/issues/4507
|
|
264
|
-
"@typescript-eslint/no-meaningless-void-operator": "off",
|
|
266
|
+
"@typescript-eslint/no-meaningless-void-operator": "warn",
|
|
265
267
|
"@typescript-eslint/no-empty-function": [
|
|
266
268
|
// There can be use cases for this (when providing a callback is required
|
|
267
269
|
// but you don't want to do anything)
|
|
@@ -292,6 +294,9 @@ const index = [
|
|
|
292
294
|
}
|
|
293
295
|
}
|
|
294
296
|
],
|
|
297
|
+
// Generally this should be avoided, but some patterns require it
|
|
298
|
+
// (type-only getters/setters, or mixins)
|
|
299
|
+
"@typescript-eslint/no-unsafe-declaration-merging": "off",
|
|
295
300
|
//#endregion
|
|
296
301
|
//#region Report consistency issues
|
|
297
302
|
// TODO: make these more or less strict as needed
|
|
@@ -311,26 +316,8 @@ const index = [
|
|
|
311
316
|
// Rationale: https://devtopia.esri.com/WebGIS/arcgis-web-components/issues/289
|
|
312
317
|
// TODO: replace with unicorn/prevent-abbreviations
|
|
313
318
|
"id-denylist": ["error", "elt", "elem", "evt", "ev", "cb"],
|
|
314
|
-
|
|
315
|
-
"
|
|
316
|
-
"warn",
|
|
317
|
-
{
|
|
318
|
-
capIsNewExceptions: [
|
|
319
|
-
// Exclude Stencil decorators
|
|
320
|
-
"Component",
|
|
321
|
-
"Element",
|
|
322
|
-
"Event",
|
|
323
|
-
"AttachInternals",
|
|
324
|
-
"Listen",
|
|
325
|
-
"Method",
|
|
326
|
-
"Prop",
|
|
327
|
-
"State",
|
|
328
|
-
"Watch",
|
|
329
|
-
// Exclude Angular decorator
|
|
330
|
-
"NgModule"
|
|
331
|
-
]
|
|
332
|
-
}
|
|
333
|
-
],
|
|
319
|
+
// Leave it to developer to decide when it is time to refactor-out
|
|
320
|
+
"complexity": "off",
|
|
334
321
|
// TODO: discuss (this avoids longer lines, improves readability)
|
|
335
322
|
// "no-inline-comments": "error",
|
|
336
323
|
// TODO: discuss (similar to the rule above, might be redundant).
|
|
@@ -344,48 +331,6 @@ const index = [
|
|
|
344
331
|
* ```
|
|
345
332
|
*/
|
|
346
333
|
"@typescript-eslint/no-this-alias": "off",
|
|
347
|
-
// ENUM values like "1<<0" ... "1<<9" are very useful
|
|
348
|
-
"@typescript-eslint/prefer-literal-enum-member": "off",
|
|
349
|
-
"no-magic-numbers": "off",
|
|
350
|
-
"@typescript-eslint/no-magic-numbers": [
|
|
351
|
-
// Error on code like:
|
|
352
|
-
// switch (code) { case 9: // '\t' ...
|
|
353
|
-
// refactor to:
|
|
354
|
-
// export const charCodes = { tab: 9 };
|
|
355
|
-
// switch (code) { case charCodes.tab: ...
|
|
356
|
-
//
|
|
357
|
-
// Benefits:
|
|
358
|
-
// - charCodes can be exported and reused in the codebase
|
|
359
|
-
// - no need for '\t' comment anymore
|
|
360
|
-
// - comment can be wrong or get out of data
|
|
361
|
-
// - easy to find all usages of charCodes.tab (harder to search for usages
|
|
362
|
-
// of 9)
|
|
363
|
-
//
|
|
364
|
-
// Similarly, you can define a dictionary of all HTTP status codes and
|
|
365
|
-
// other special numbers. Example:
|
|
366
|
-
// https://github.com/specify/specify7/blob/xml-editor/specifyweb/frontend/js_src/lib/utils/ajax/definitions.ts
|
|
367
|
-
// And now it's trivial to see all the places in the code that handle a
|
|
368
|
-
// particular http status code.
|
|
369
|
-
// Similarly, in that file further down you can see how by using
|
|
370
|
-
// [Http.Conflict] rather than 409:, the code is more self-documenting
|
|
371
|
-
"warn",
|
|
372
|
-
{
|
|
373
|
-
ignore: [
|
|
374
|
-
// Don't know why these aren't ignored by default
|
|
375
|
-
-1,
|
|
376
|
-
0,
|
|
377
|
-
1,
|
|
378
|
-
2
|
|
379
|
-
],
|
|
380
|
-
ignoreDefaultValues: true,
|
|
381
|
-
ignoreClassFieldInitialValues: true,
|
|
382
|
-
detectObjects: false,
|
|
383
|
-
ignoreEnums: true,
|
|
384
|
-
ignoreNumericLiteralTypes: true,
|
|
385
|
-
ignoreReadonlyClassProperties: true,
|
|
386
|
-
ignoreTypeIndexes: true
|
|
387
|
-
}
|
|
388
|
-
],
|
|
389
334
|
"no-warning-comments": [
|
|
390
335
|
// TODO: consider forbidding TODO in favor of BUG, HACK, REFACTOR, FEATURE,
|
|
391
336
|
// LOW, TEST, PERF. Then can configure IDE to assign different colors to
|
|
@@ -572,12 +517,6 @@ const index = [
|
|
|
572
517
|
// TODO: replace with perfectionist/sort-intersection-types and perfectionist/sort-union-types rules.
|
|
573
518
|
// Autofixable, so only a warning to be less disruptive
|
|
574
519
|
"@typescript-eslint/sort-type-constituents": "warn",
|
|
575
|
-
"@typescript-eslint/prefer-nullish-coalescing": [
|
|
576
|
-
"warn",
|
|
577
|
-
{
|
|
578
|
-
ignorePrimitives: { string: true }
|
|
579
|
-
}
|
|
580
|
-
],
|
|
581
520
|
// The string.match() is more intuitive than the RegExp.exec()
|
|
582
521
|
"@typescript-eslint/prefer-regexp-exec": "off",
|
|
583
522
|
// Both types and interfaces have uses in the edge cases. In the common
|
|
@@ -589,7 +528,18 @@ const index = [
|
|
|
589
528
|
// deprecated.
|
|
590
529
|
"@typescript-eslint/no-deprecated": "warn",
|
|
591
530
|
// For can be useful in support packages and hot paths
|
|
592
|
-
"@typescript-eslint/prefer-for-of": "off"
|
|
531
|
+
"@typescript-eslint/prefer-for-of": "off",
|
|
532
|
+
// Enums are generally discouraged. Not much harm in this particular issue though
|
|
533
|
+
"@typescript-eslint/no-mixed-enums": "off",
|
|
534
|
+
// ENUM values like "1<<0" ... "1<<9" are very useful
|
|
535
|
+
"@typescript-eslint/prefer-literal-enum-member": "off",
|
|
536
|
+
// We discourage enums, so little added value in this check
|
|
537
|
+
"@typescript-eslint/no-duplicate-enum-values": "off",
|
|
538
|
+
// We discourage enums, so little added value in this check
|
|
539
|
+
"@typescript-eslint/no-unsafe-enum-comparison": "off",
|
|
540
|
+
// Developer may actually mean to use ||
|
|
541
|
+
// Also, refactoring this out may break things
|
|
542
|
+
"@typescript-eslint/prefer-nullish-coalescing": "off"
|
|
593
543
|
//#endregion
|
|
594
544
|
// TODO: go over https://typescript-eslint.io/linting/troubleshooting/performance-troubleshooting
|
|
595
545
|
}
|
|
@@ -601,5 +551,5 @@ const index = [
|
|
|
601
551
|
}
|
|
602
552
|
];
|
|
603
553
|
export {
|
|
604
|
-
|
|
554
|
+
defaultConfig as default
|
|
605
555
|
};
|
package/dist/config/lumina.js
CHANGED
|
@@ -58,12 +58,6 @@ const lumina = [
|
|
|
58
58
|
"@typescript-eslint/require-await": "off",
|
|
59
59
|
// Too many offenders for now to report this as an error. Assigned issues to tackle this.
|
|
60
60
|
"lumina/no-create-element-component": "warn",
|
|
61
|
-
/*
|
|
62
|
-
* This rule emits false warnings when using Controllers due to
|
|
63
|
-
* limitations of TypeScript when it comes to expressing the type of a
|
|
64
|
-
* property that changes during lifecycle (from non-null to eventual null)
|
|
65
|
-
*/
|
|
66
|
-
"@typescript-eslint/no-confusing-void-expression": "off",
|
|
67
61
|
"@typescript-eslint/no-restricted-imports": [
|
|
68
62
|
"error",
|
|
69
63
|
{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as makeEslintPlugin } from "../../makePlugin-
|
|
1
|
+
import { m as makeEslintPlugin } from "../../makePlugin-DiZ5PMHq.js";
|
|
2
2
|
import { AST_NODE_TYPES, ESLintUtils, AST_TOKEN_TYPES } from "@typescript-eslint/utils";
|
|
3
3
|
import ts from "typescript";
|
|
4
4
|
import { camelToKebab } from "@arcgis/components-utils";
|
|
@@ -95,16 +95,16 @@ function isBindThisCallee(callee) {
|
|
|
95
95
|
callee.object.object.type === AST_NODE_TYPES.ThisExpression;
|
|
96
96
|
}
|
|
97
97
|
const importDeclaration = `import { ${luminaJsxExportName} } from "${luminaEntrypointName}";`;
|
|
98
|
-
const description$
|
|
98
|
+
const description$k = `To use Lumina's JSX, you need to ${importDeclaration}`;
|
|
99
99
|
plugin.createRule({
|
|
100
100
|
name: "add-missing-jsx-import",
|
|
101
101
|
meta: {
|
|
102
102
|
docs: {
|
|
103
|
-
description: description$
|
|
103
|
+
description: description$k,
|
|
104
104
|
defaultLevel: "error"
|
|
105
105
|
},
|
|
106
106
|
messages: {
|
|
107
|
-
addMissingJsxImport: description$
|
|
107
|
+
addMissingJsxImport: description$k
|
|
108
108
|
},
|
|
109
109
|
type: "problem",
|
|
110
110
|
schema: [],
|
|
@@ -161,12 +161,12 @@ plugin.createRule({
|
|
|
161
161
|
};
|
|
162
162
|
}
|
|
163
163
|
});
|
|
164
|
-
const description$
|
|
164
|
+
const description$j = "Auto add { type: Boolean } or { type: Number } where necessary";
|
|
165
165
|
plugin.createRule({
|
|
166
166
|
name: "auto-add-type",
|
|
167
167
|
meta: {
|
|
168
168
|
docs: {
|
|
169
|
-
description: description$
|
|
169
|
+
description: description$j,
|
|
170
170
|
defaultLevel: "warn"
|
|
171
171
|
},
|
|
172
172
|
messages: {
|
|
@@ -402,12 +402,12 @@ plugin.createRule({
|
|
|
402
402
|
};
|
|
403
403
|
}
|
|
404
404
|
});
|
|
405
|
-
const description$
|
|
405
|
+
const description$i = `Lumina component must be declared in a TSX file with a matching folder name located inside of src/components folder.`;
|
|
406
406
|
plugin.createRule({
|
|
407
407
|
name: "component-placement-rules",
|
|
408
408
|
meta: {
|
|
409
409
|
docs: {
|
|
410
|
-
description: description$
|
|
410
|
+
description: description$i,
|
|
411
411
|
defaultLevel: "error"
|
|
412
412
|
},
|
|
413
413
|
messages: {
|
|
@@ -446,7 +446,7 @@ plugin.createRule({
|
|
|
446
446
|
};
|
|
447
447
|
}
|
|
448
448
|
});
|
|
449
|
-
const description$
|
|
449
|
+
const description$h = `Enforce consistent event naming.`;
|
|
450
450
|
const defaultOptions$1 = [
|
|
451
451
|
{
|
|
452
452
|
eventNamespaces: ["arcgis"],
|
|
@@ -457,7 +457,7 @@ plugin.createRule({
|
|
|
457
457
|
name: "consistent-event-naming",
|
|
458
458
|
meta: {
|
|
459
459
|
docs: {
|
|
460
|
-
description: description$
|
|
460
|
+
description: description$h,
|
|
461
461
|
defaultLevel: "warn"
|
|
462
462
|
},
|
|
463
463
|
messages: {
|
|
@@ -558,6 +558,87 @@ Discussion: https://devtopia.esri.com/WebGIS/arcgis-web-components/discussions/3
|
|
|
558
558
|
}
|
|
559
559
|
});
|
|
560
560
|
const capitalAfterLower = /(?<=[a-z\d])[A-Z]/u;
|
|
561
|
+
const description$g = `Enforce consistent usage of ? for marking property as nullable, rather than |null, |undefined or |Nil.`;
|
|
562
|
+
plugin.createRule({
|
|
563
|
+
name: "consistent-nullability",
|
|
564
|
+
meta: {
|
|
565
|
+
docs: {
|
|
566
|
+
description: description$g,
|
|
567
|
+
// TODO: enable this by default
|
|
568
|
+
defaultLevel: "off"
|
|
569
|
+
},
|
|
570
|
+
messages: {
|
|
571
|
+
consistentNullabilityError: `For consistency, use {{propertyName}}?:{{newType}} to denote property as optional, rather than {{propertyName}}:{{oldType}}.`,
|
|
572
|
+
removeNeedlessDefault: `This default value is likely unnecessary. Remove it to reduce bundle size.`
|
|
573
|
+
},
|
|
574
|
+
schema: [],
|
|
575
|
+
fixable: "code",
|
|
576
|
+
type: "suggestion"
|
|
577
|
+
},
|
|
578
|
+
defaultOptions: [],
|
|
579
|
+
create(context) {
|
|
580
|
+
return {
|
|
581
|
+
PropertyDefinition(node) {
|
|
582
|
+
const isProperty = hasDecorator(node, "property");
|
|
583
|
+
if (!isProperty) {
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
const comments = context.sourceCode.getCommentsBefore(node);
|
|
587
|
+
const isDeprecated = comments.some((comment) => comment.value.includes("@deprecated"));
|
|
588
|
+
if (isDeprecated) {
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
const defaultValue = node.value;
|
|
592
|
+
if (defaultValue?.type === AST_NODE_TYPES.Literal && defaultValue.value === null || defaultValue?.type === AST_NODE_TYPES.Identifier && defaultValue.name === "undefined") {
|
|
593
|
+
context.report({
|
|
594
|
+
node: defaultValue,
|
|
595
|
+
messageId: "removeNeedlessDefault",
|
|
596
|
+
fix(fixer) {
|
|
597
|
+
const tokenBeforeDefaultValue = context.sourceCode.getTokenBefore(defaultValue);
|
|
598
|
+
const isEqualsSign = tokenBeforeDefaultValue && tokenBeforeDefaultValue.value === "=";
|
|
599
|
+
return isEqualsSign ? fixer.removeRange([tokenBeforeDefaultValue.range[0], defaultValue.range[1]]) : fixer.remove(defaultValue);
|
|
600
|
+
}
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
const typeAnnotation = node.typeAnnotation?.typeAnnotation;
|
|
604
|
+
if (typeAnnotation === void 0) {
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
const isUnionType = typeAnnotation.type === AST_NODE_TYPES.TSUnionType;
|
|
608
|
+
if (!isUnionType) {
|
|
609
|
+
return;
|
|
610
|
+
}
|
|
611
|
+
const withoutNillTypes = typeAnnotation.types.filter(
|
|
612
|
+
(type) => type.type !== AST_NODE_TYPES.TSUndefinedKeyword && type.type !== AST_NODE_TYPES.TSNullKeyword && (type.type !== AST_NODE_TYPES.TSTypeReference || type.typeName.type !== AST_NODE_TYPES.Identifier || type.typeName.name !== "Nil" && type.typeName.name !== "nil" && type.typeName.name !== "nullish")
|
|
613
|
+
);
|
|
614
|
+
const isSameCount = typeAnnotation.types.length === withoutNillTypes.length;
|
|
615
|
+
if (isSameCount || withoutNillTypes.length === 0) {
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
const hasQuestionMark = node.optional;
|
|
619
|
+
const newType = withoutNillTypes.map((type) => context.sourceCode.getText(type)).join(" | ");
|
|
620
|
+
context.report({
|
|
621
|
+
node: typeAnnotation,
|
|
622
|
+
messageId: "consistentNullabilityError",
|
|
623
|
+
data: {
|
|
624
|
+
propertyName: context.sourceCode.getText(node.key),
|
|
625
|
+
newType,
|
|
626
|
+
oldType: context.sourceCode.getText(typeAnnotation)
|
|
627
|
+
},
|
|
628
|
+
fix(fixer) {
|
|
629
|
+
const tokenAfterKey = context.sourceCode.getTokenAfter(node.key);
|
|
630
|
+
const hasExclamationMark = tokenAfterKey !== null && tokenAfterKey.value === "!";
|
|
631
|
+
return [
|
|
632
|
+
...hasExclamationMark ? [fixer.remove(tokenAfterKey)] : [],
|
|
633
|
+
...hasQuestionMark ? [] : [fixer.insertTextAfter(node.key, "?")],
|
|
634
|
+
fixer.replaceText(typeAnnotation, newType)
|
|
635
|
+
];
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
});
|
|
561
642
|
const description$f = `Enforce that @property(), @method() and createEvent() members are used in the correct context.`;
|
|
562
643
|
plugin.createRule({
|
|
563
644
|
name: "decorators-context",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as makeEslintPlugin } from "../../makePlugin-
|
|
1
|
+
import { m as makeEslintPlugin } from "../../makePlugin-DiZ5PMHq.js";
|
|
2
2
|
import { resolve } from "node:path/posix";
|
|
3
3
|
import { AST_NODE_TYPES } from "@typescript-eslint/utils";
|
|
4
4
|
const plugin = makeEslintPlugin(
|
|
@@ -136,7 +136,7 @@ plugin.createRule({
|
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
const description = "Using .d.ts files is discouraged. Prefer .ts files instead, as they are type-checked and not in global scope.";
|
|
139
|
-
const allowedNames = /* @__PURE__ */ new Set(["vite-env.d.ts", "
|
|
139
|
+
const allowedNames = /* @__PURE__ */ new Set(["vite-env.d.ts", "components.d.ts"]);
|
|
140
140
|
plugin.createRule({
|
|
141
141
|
name: "no-dts-files",
|
|
142
142
|
meta: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/eslint-config",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.34.0-next.1",
|
|
4
4
|
"description": "ESLint configuration for arcgis-web-components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": "./dist/config/index.js",
|
|
11
|
+
"./application": "./dist/config/applications.js",
|
|
11
12
|
"./extra": "./dist/config/extra.js",
|
|
12
13
|
"./lumina": "./dist/config/lumina.js",
|
|
13
14
|
"./plugins/webgis": "./dist/plugins/webgis/index.js",
|
|
@@ -19,19 +20,17 @@
|
|
|
19
20
|
],
|
|
20
21
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"@arcgis/components-utils": "4.
|
|
23
|
-
"@eslint/js": "^9.
|
|
23
|
+
"@arcgis/components-utils": "4.34.0-next.1",
|
|
24
|
+
"@eslint/js": "^9.23.0",
|
|
24
25
|
"@types/confusing-browser-globals": "^1.0.3",
|
|
25
26
|
"confusing-browser-globals": "^1.0.11",
|
|
26
|
-
"eslint-plugin-
|
|
27
|
-
"eslint-plugin-storybook": "^0.11.1",
|
|
27
|
+
"eslint-plugin-storybook": "^0.12.0",
|
|
28
28
|
"globals": "^15.12.0",
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"typescript": "
|
|
32
|
-
"typescript-eslint": "^8.18.1"
|
|
29
|
+
"tslib": "^2.8.1",
|
|
30
|
+
"typescript": "~5.8.3",
|
|
31
|
+
"typescript-eslint": "^8.28.0"
|
|
33
32
|
},
|
|
34
33
|
"peerDependencies": {
|
|
35
|
-
"eslint": "^9.
|
|
34
|
+
"eslint": "^9.23.0"
|
|
36
35
|
}
|
|
37
36
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ESLintUtils, TSUtils } from '@typescript-eslint/utils';
|
|
2
|
-
import { CommonDocs } from './makePlugin';
|
|
3
|
-
import { RunTests } from '@typescript-eslint/rule-tester';
|
|
4
|
-
export declare function testUntypedRule<MessageIds extends string, Options extends readonly unknown[]>(rule: ESLintUtils.RuleModule<MessageIds, Options, CommonDocs>, test: RunTests<TSUtils.NoInfer<MessageIds>, TSUtils.NoInfer<Options>>): void;
|
|
5
|
-
export declare function testTypedRule<MessageIds extends string, Options extends readonly unknown[]>(rule: ESLintUtils.RuleModule<MessageIds, Options, CommonDocs>, test: RunTests<TSUtils.NoInfer<MessageIds>, TSUtils.NoInfer<Options>>): void;
|
|
6
|
-
/**
|
|
7
|
-
* A helper for authoring before/after autofix diff in a way that makes it easy
|
|
8
|
-
* to see what part of the code changed, and avoids duplication.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* {
|
|
13
|
-
* ...diff`console.${["warn", "error"]}("test");`;
|
|
14
|
-
* errors: [{ messageId: "messageId" }],
|
|
15
|
-
* },
|
|
16
|
-
* // equivalent to:
|
|
17
|
-
* {
|
|
18
|
-
* code: "console.warn(\"test\");",
|
|
19
|
-
* output: "console.error(\"test\");",
|
|
20
|
-
* errors: [{ messageId: "messageId" }],
|
|
21
|
-
* },
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
export declare function diff(parts: readonly string[], ...parameters: readonly (readonly [before: string, after: string])[]): {
|
|
26
|
-
code: string;
|
|
27
|
-
output: string;
|
|
28
|
-
};
|