@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.
- package/LICENSE.md +4 -2
- package/README.md +2 -2
- package/dist/config/applications.js +0 -2
- package/dist/config/core.js +720 -0
- package/dist/config/extra.js +1 -1
- package/dist/config/index.js +35 -12
- package/dist/{estree-CDc-die8.js → estree-Ern7-L05.js} +8 -6
- package/dist/{makePlugin-B_8WcydL.js → makePlugin-CkrvQfdh.js} +6 -2
- package/dist/plugins/core/index.js +75 -33
- package/dist/plugins/lumina/index.js +63 -32
- package/dist/plugins/utils/makePlugin.d.ts +17 -0
- package/dist/plugins/webgis/index.js +171 -31
- package/dist/utils/disableRules.d.ts +3 -2
- package/dist/utils/disableRules.js +1 -1
- package/package.json +15 -9
package/dist/config/extra.js
CHANGED
|
@@ -2,7 +2,7 @@ const config = [
|
|
|
2
2
|
{
|
|
3
3
|
files: ["**/*.ts", "**/*.tsx"],
|
|
4
4
|
rules: {
|
|
5
|
-
// See https://devtopia.esri.com/WebGIS/
|
|
5
|
+
// See https://devtopia.esri.com/WebGIS/webgis-sdk/discussions/446#discussioncomment-3166
|
|
6
6
|
"@typescript-eslint/no-unsafe-return": "warn",
|
|
7
7
|
/*
|
|
8
8
|
* Lot's of false positives on pure functions that don't use
|
package/dist/config/index.js
CHANGED
|
@@ -7,9 +7,12 @@ import { globalIgnores } from "eslint/config";
|
|
|
7
7
|
import markdown from "@eslint/markdown";
|
|
8
8
|
import packageJson from "eslint-plugin-package-json";
|
|
9
9
|
import { importX } from "eslint-plugin-import-x";
|
|
10
|
+
import { createTypeScriptImportResolver } from "eslint-import-resolver-typescript";
|
|
10
11
|
const packageJsonSortableCollections = packageJson.rules["sort-collections"].meta.defaultOptions[0].filter(
|
|
11
12
|
(collection) => !["scripts", "exports"].includes(collection)
|
|
12
13
|
) ?? [];
|
|
14
|
+
const importXTypeScriptSettings = { ...importX.flatConfigs.typescript.settings };
|
|
15
|
+
delete importXTypeScriptSettings["import-x/resolver"];
|
|
13
16
|
const config = [
|
|
14
17
|
globalIgnores(["**/www", "**/dist", "**/assets", "**/coverage", "**/.docs"]),
|
|
15
18
|
{
|
|
@@ -24,7 +27,13 @@ const config = [
|
|
|
24
27
|
...webgisPlugin.configs.recommended,
|
|
25
28
|
files: ["**/*.ts", "**/*.tsx"]
|
|
26
29
|
},
|
|
27
|
-
|
|
30
|
+
{
|
|
31
|
+
...importX.flatConfigs.typescript,
|
|
32
|
+
settings: {
|
|
33
|
+
...importXTypeScriptSettings,
|
|
34
|
+
"import-x/resolver-next": [createTypeScriptImportResolver()]
|
|
35
|
+
}
|
|
36
|
+
},
|
|
28
37
|
{
|
|
29
38
|
files: ["**/*.ts", "**/*.tsx"],
|
|
30
39
|
linterOptions: {
|
|
@@ -123,7 +132,7 @@ const config = [
|
|
|
123
132
|
* performance issues.
|
|
124
133
|
*
|
|
125
134
|
*/
|
|
126
|
-
// Disabled as per https://devtopia.esri.com/WebGIS/
|
|
135
|
+
// Disabled as per https://devtopia.esri.com/WebGIS/webgis-sdk/discussions/446#discussioncomment-3166
|
|
127
136
|
"@typescript-eslint/no-unsafe-return": "off",
|
|
128
137
|
/*
|
|
129
138
|
* Lot's of false positives on pure functions that don't use
|
|
@@ -145,8 +154,10 @@ const config = [
|
|
|
145
154
|
* consider refactoring to less confusing syntax instead
|
|
146
155
|
*
|
|
147
156
|
*/
|
|
148
|
-
//
|
|
149
|
-
|
|
157
|
+
// Too many false positives. Some cases require sequential execution of
|
|
158
|
+
// async code for correctness, cleaner output, or to avoid performance
|
|
159
|
+
// constraints
|
|
160
|
+
"no-await-in-loop": "off",
|
|
150
161
|
"no-constructor-return": "warn",
|
|
151
162
|
"no-fallthrough": ["error", { reportUnusedFallthroughComment: true }],
|
|
152
163
|
// This mis-fires for anonymous functions when not wrapped in {}
|
|
@@ -165,7 +176,8 @@ const config = [
|
|
|
165
176
|
// Not an error as some external APIs require calling "new" even if we don't
|
|
166
177
|
// care about the retune time. Controllers also use this pattern
|
|
167
178
|
"no-new": "off",
|
|
168
|
-
|
|
179
|
+
// See https://devtopia.esri.com/WebGIS/webgis-sdk/pull/14943#discussion_r1661089
|
|
180
|
+
"no-useless-computed-key": "off",
|
|
169
181
|
"no-useless-concat": "error",
|
|
170
182
|
"no-unneeded-ternary": "warn",
|
|
171
183
|
"no-useless-call": "error",
|
|
@@ -269,7 +281,7 @@ const config = [
|
|
|
269
281
|
"@typescript-eslint/no-for-in-array": "off",
|
|
270
282
|
"no-alert": "error",
|
|
271
283
|
"no-caller": "error",
|
|
272
|
-
// TODO: re-enable once https://devtopia.esri.com/WebGIS/
|
|
284
|
+
// TODO: re-enable once https://devtopia.esri.com/WebGIS/webgis-sdk/issues/1519 is fixed
|
|
273
285
|
// "no-console": 'error',
|
|
274
286
|
"no-eval": "error",
|
|
275
287
|
"no-extend-native": "error",
|
|
@@ -336,7 +348,7 @@ const config = [
|
|
|
336
348
|
"curly": ["warn", "all"],
|
|
337
349
|
"eqeqeq": ["error", "always", { null: "ignore" }],
|
|
338
350
|
"func-names": ["warn", "as-needed"],
|
|
339
|
-
// Rationale: https://devtopia.esri.com/WebGIS/
|
|
351
|
+
// Rationale: https://devtopia.esri.com/WebGIS/webgis-sdk/issues/289
|
|
340
352
|
// TODO: replace with unicorn/prevent-abbreviations
|
|
341
353
|
"id-denylist": ["error", "elt", "elem", "evt", "ev", "cb"],
|
|
342
354
|
// Leave it to developer to decide when it is time to refactor-out
|
|
@@ -420,6 +432,15 @@ const config = [
|
|
|
420
432
|
objectLiteralTypeAssertions: "allow-as-parameter"
|
|
421
433
|
}
|
|
422
434
|
],
|
|
435
|
+
"@typescript-eslint/consistent-type-imports": [
|
|
436
|
+
"warn",
|
|
437
|
+
{
|
|
438
|
+
prefer: "type-imports",
|
|
439
|
+
fixStyle: "inline-type-imports",
|
|
440
|
+
// Type imports are necessary in namespaces and global augmentations
|
|
441
|
+
disallowTypeAnnotations: false
|
|
442
|
+
}
|
|
443
|
+
],
|
|
423
444
|
"@typescript-eslint/consistent-type-exports": ["warn", { fixMixedExportsWithInlineTypeSpecifier: true }],
|
|
424
445
|
"@typescript-eslint/no-import-type-side-effects": "error",
|
|
425
446
|
"default-param-last": "off",
|
|
@@ -464,7 +485,10 @@ const config = [
|
|
|
464
485
|
// rule - give it more time to catch the bug cases. Also, this rule
|
|
465
486
|
// changes runtime behavior, and may lead to breaking changes.
|
|
466
487
|
"@typescript-eslint/no-useless-default-assignment": "off",
|
|
467
|
-
|
|
488
|
+
// Since https://devtopia.esri.com/WebGIS/webgis-sdk/pull/17821,
|
|
489
|
+
// this rule has more true positives, but also many more false positives.
|
|
490
|
+
// The autofix often causes TypeScript errors, and new ESLint errors
|
|
491
|
+
"@typescript-eslint/no-unnecessary-type-assertion": "off",
|
|
468
492
|
"@typescript-eslint/prefer-includes": ["warn"],
|
|
469
493
|
"@typescript-eslint/prefer-reduce-type-parameter": ["warn"],
|
|
470
494
|
"@typescript-eslint/prefer-return-this-type": ["warn"],
|
|
@@ -549,10 +573,9 @@ const config = [
|
|
|
549
573
|
// cases it often does not matter.
|
|
550
574
|
// See alsohttps://www.youtube.com/watch?v=zM9UPcIyyhQ
|
|
551
575
|
"@typescript-eslint/consistent-type-definitions": ["off", "type"],
|
|
552
|
-
//
|
|
553
|
-
//
|
|
554
|
-
|
|
555
|
-
"@typescript-eslint/no-deprecated": "warn",
|
|
576
|
+
// Many false positives.
|
|
577
|
+
// See https://devtopia.esri.com/WebGIS/webgis-sdk/issues/10624
|
|
578
|
+
"@typescript-eslint/no-deprecated": "off",
|
|
556
579
|
// For can be useful in support packages and hot paths
|
|
557
580
|
"@typescript-eslint/prefer-for-of": "off",
|
|
558
581
|
// Enums are generally discouraged. Not much harm in this particular issue though
|
|
@@ -73,6 +73,8 @@ function isGetterWithoutSetter(node) {
|
|
|
73
73
|
function getName(node) {
|
|
74
74
|
if (node.key.type === AST_NODE_TYPES.Identifier) {
|
|
75
75
|
return node.key.name;
|
|
76
|
+
} else if (node.key.type === AST_NODE_TYPES.PrivateIdentifier) {
|
|
77
|
+
return `#${node.key.name}`;
|
|
76
78
|
} else if (node.key.type === AST_NODE_TYPES.Literal && typeof node.key.value === "string") {
|
|
77
79
|
return node.key.value;
|
|
78
80
|
} else {
|
|
@@ -107,15 +109,15 @@ function isBindThisCallee(callee) {
|
|
|
107
109
|
export {
|
|
108
110
|
luminaEntrypointName as a,
|
|
109
111
|
luminaTestEntrypointName as b,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
+
isCreateEvent as c,
|
|
113
|
+
getName as d,
|
|
112
114
|
extractDeclareElementsInterface as e,
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
checkForLuminaJsx as f,
|
|
116
|
+
getProperty as g,
|
|
115
117
|
hasDecorator as h,
|
|
116
118
|
isGetterWithoutSetter as i,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
isBindThisCallee as j,
|
|
120
|
+
getComponentDeclaration as k,
|
|
119
121
|
luminaJsxExportName as l,
|
|
120
122
|
parsePropertyDecorator as p,
|
|
121
123
|
sourceCodeDeclaresComponent as s,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ESLintUtils } from "@typescript-eslint/utils";
|
|
2
|
-
const version = "
|
|
2
|
+
const version = "1.0.0-0";
|
|
3
3
|
const packageJson = {
|
|
4
4
|
version
|
|
5
5
|
};
|
|
6
6
|
function makeEslintPlugin(pluginName, urlCreator) {
|
|
7
7
|
const rules = [];
|
|
8
|
+
const typeCheckedRules = /* @__PURE__ */ new Set();
|
|
8
9
|
const creator = ESLintUtils.RuleCreator(urlCreator);
|
|
9
10
|
return {
|
|
10
11
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
@@ -13,6 +14,9 @@ function makeEslintPlugin(pluginName, urlCreator) {
|
|
|
13
14
|
const docs = { ...meta.docs, name };
|
|
14
15
|
const ruleModule = creator({ ...rest, meta: { ...meta, docs }, name });
|
|
15
16
|
rules.push(ruleModule);
|
|
17
|
+
if (meta.docs.isTypeChecked) {
|
|
18
|
+
typeCheckedRules.add(`${pluginName}/${name}`);
|
|
19
|
+
}
|
|
16
20
|
return ruleModule;
|
|
17
21
|
},
|
|
18
22
|
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
@@ -23,7 +27,7 @@ function makeEslintPlugin(pluginName, urlCreator) {
|
|
|
23
27
|
)
|
|
24
28
|
};
|
|
25
29
|
const plugin = {
|
|
26
|
-
meta: { name: `@arcgis/eslint-plugin-${pluginName}`, version: packageJson.version },
|
|
30
|
+
meta: { name: `@arcgis/eslint-plugin-${pluginName}`, version: packageJson.version, typeCheckedRules },
|
|
27
31
|
configs: {
|
|
28
32
|
recommended: config
|
|
29
33
|
},
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
import { m as makeEslintPlugin } from "../../makePlugin-
|
|
2
|
-
import { AST_NODE_TYPES, AST_TOKEN_TYPES } from "@typescript-eslint/utils";
|
|
1
|
+
import { m as makeEslintPlugin } from "../../makePlugin-CkrvQfdh.js";
|
|
3
2
|
import { generateDifferences, showInvisibles } from "prettier-linter-helpers";
|
|
3
|
+
import { AST_NODE_TYPES, AST_TOKEN_TYPES } from "@typescript-eslint/utils";
|
|
4
4
|
import path, { relative, win32, posix, normalize } from "path";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import { existsSync } from "node:fs";
|
|
5
7
|
import { execSync } from "child_process";
|
|
6
8
|
const plugin = makeEslintPlugin(
|
|
7
9
|
"core",
|
|
8
|
-
(rule) => `https://devtopia.esri.com/WebGIS/
|
|
10
|
+
(rule) => `https://devtopia.esri.com/WebGIS/webgis-sdk/tree/main/packages/support-packages/eslint-config/src/plugins/core/rules/${rule}.ts`
|
|
9
11
|
);
|
|
10
12
|
plugin.createRule({
|
|
11
13
|
name: "glsl-whitespace",
|
|
12
14
|
meta: {
|
|
13
15
|
docs: {
|
|
14
16
|
description: "Checks that glsl tagged template strings don't have extra whitespace.",
|
|
15
|
-
defaultLevel: "error"
|
|
17
|
+
defaultLevel: "error",
|
|
18
|
+
isTypeChecked: false
|
|
16
19
|
},
|
|
17
20
|
messages: {
|
|
18
21
|
delete: "Delete `{{ deleteText }}`",
|
|
@@ -93,20 +96,26 @@ function removeLeadingBlankLines(text) {
|
|
|
93
96
|
function removeTrailingBlankLines(text) {
|
|
94
97
|
return text.replace(/(\r?\n)(\r?\n)*([ \t]*)`$/gu, "$1$3`");
|
|
95
98
|
}
|
|
99
|
+
const projectMarker = "/src/";
|
|
100
|
+
let projectRoot = void 0;
|
|
96
101
|
function findProjectRoot(filename) {
|
|
97
102
|
const normalized = filename.replaceAll("\\", "/");
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
const isProjectFile = normalized.includes(projectMarker);
|
|
104
|
+
if (isProjectFile && projectRoot) {
|
|
105
|
+
return projectRoot;
|
|
106
|
+
}
|
|
107
|
+
const fileToFind = "package.json";
|
|
108
|
+
for (let root = dirname(filename), previousRoot = filename; root !== previousRoot; previousRoot = root, root = dirname(root)) {
|
|
109
|
+
const filepath = join(root, fileToFind);
|
|
110
|
+
if (existsSync(filepath)) {
|
|
111
|
+
if (isProjectFile) {
|
|
112
|
+
projectRoot = root;
|
|
113
|
+
}
|
|
114
|
+
return root;
|
|
105
115
|
}
|
|
106
116
|
}
|
|
107
|
-
return
|
|
117
|
+
return;
|
|
108
118
|
}
|
|
109
|
-
const slashCharCode = 47;
|
|
110
119
|
const isWindows = process.platform === "win32";
|
|
111
120
|
const collator = new Intl.Collator("en-US");
|
|
112
121
|
plugin.createRule({
|
|
@@ -114,7 +123,8 @@ plugin.createRule({
|
|
|
114
123
|
meta: {
|
|
115
124
|
docs: {
|
|
116
125
|
description: "Checks that imports are sorted and grouped",
|
|
117
|
-
defaultLevel: "error"
|
|
126
|
+
defaultLevel: "error",
|
|
127
|
+
isTypeChecked: false
|
|
118
128
|
},
|
|
119
129
|
messages: {
|
|
120
130
|
importFormat: "Imports are incorrectly sorted and/or grouped",
|
|
@@ -226,7 +236,7 @@ function groupImportsByPath(imports, absImportPath, basePath) {
|
|
|
226
236
|
});
|
|
227
237
|
}
|
|
228
238
|
function importStatementPathName(importStatement, absImportPath, basePath) {
|
|
229
|
-
return importPathName(importStatementPathString(importStatement), absImportPath, basePath);
|
|
239
|
+
return normalizeImportPath(importPathName(importStatementPathString(importStatement), absImportPath, basePath));
|
|
230
240
|
}
|
|
231
241
|
function importStatementPathString(importStatement) {
|
|
232
242
|
return importStatement.source.value;
|
|
@@ -248,10 +258,25 @@ function importPathName(importPath, absImportPath, basePath) {
|
|
|
248
258
|
return path.dirname(relative(basePath, importPath));
|
|
249
259
|
}
|
|
250
260
|
function formatGroupedImports(sourceCode, groupedImports, newLine) {
|
|
251
|
-
const importHeader = `// ${groupedImports.path
|
|
261
|
+
const importHeader = `// ${formatImportHeaderPath(groupedImports.path)}`;
|
|
252
262
|
const imports = groupedImports.imports.map((importDeclaration) => sourceCode.getText(importDeclaration).trim()).join(newLine).trim();
|
|
253
263
|
return `${importHeader}${newLine}${imports}`;
|
|
254
264
|
}
|
|
265
|
+
function formatImportHeaderPath(importPath) {
|
|
266
|
+
return normalizeImportPath(importPath).replace(/[\\/]/gu, ".");
|
|
267
|
+
}
|
|
268
|
+
function normalizeImportPath(importPath) {
|
|
269
|
+
const parts = importPath.split(/[\\/]/gu);
|
|
270
|
+
if (parts[0] === "src") {
|
|
271
|
+
parts[0] = "esri";
|
|
272
|
+
} else if (parts[0] === "tests") {
|
|
273
|
+
const srcPart = parts.indexOf("src");
|
|
274
|
+
if (srcPart !== -1) {
|
|
275
|
+
parts[srcPart] = "esri";
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return parts.join(path.sep);
|
|
279
|
+
}
|
|
255
280
|
function getAttachedCommentStart(sourceCode, statement) {
|
|
256
281
|
const comments = sourceCode.getCommentsBefore(statement);
|
|
257
282
|
let start = statement.range[0];
|
|
@@ -326,7 +351,8 @@ plugin.createRule({
|
|
|
326
351
|
meta: {
|
|
327
352
|
docs: {
|
|
328
353
|
description: "Checks for duplicate comments before the first import declaration.",
|
|
329
|
-
defaultLevel: "error"
|
|
354
|
+
defaultLevel: "error",
|
|
355
|
+
isTypeChecked: false
|
|
330
356
|
},
|
|
331
357
|
messages: { duplicate: "Delete duplicate comment" },
|
|
332
358
|
schema: [],
|
|
@@ -368,7 +394,8 @@ plugin.createRule({
|
|
|
368
394
|
meta: {
|
|
369
395
|
docs: {
|
|
370
396
|
description: "Checks for `todo` JSDoc tags with missing descriptions.",
|
|
371
|
-
defaultLevel: "error"
|
|
397
|
+
defaultLevel: "error",
|
|
398
|
+
isTypeChecked: false
|
|
372
399
|
},
|
|
373
400
|
messages: { empty: "JSDoc `todo` tag description required" },
|
|
374
401
|
schema: [],
|
|
@@ -393,7 +420,8 @@ plugin.createRule({
|
|
|
393
420
|
meta: {
|
|
394
421
|
docs: {
|
|
395
422
|
description: "Enforces the declared class name passed to the @subclass() decorator",
|
|
396
|
-
defaultLevel: "error"
|
|
423
|
+
defaultLevel: "error",
|
|
424
|
+
isTypeChecked: false
|
|
397
425
|
},
|
|
398
426
|
messages: {
|
|
399
427
|
invalidPath: "Invalid path passed to @subclass(). It should be a string literal matching the file path, without the extension and with path separators replaced with `.`"
|
|
@@ -452,7 +480,7 @@ function getDeclaredClass(filename) {
|
|
|
452
480
|
if (!root) {
|
|
453
481
|
return;
|
|
454
482
|
}
|
|
455
|
-
const relativePath = relative(root, filename).replaceAll(win32.sep, ".").replaceAll(posix.sep, ".").replace(/\.[^/.]+$/u, "");
|
|
483
|
+
const relativePath = relative(root, filename).replaceAll(win32.sep, ".").replaceAll(posix.sep, ".").replace(/^src\./u, "esri.").replace(/\.[^/.]+$/u, "");
|
|
456
484
|
return relativePath;
|
|
457
485
|
}
|
|
458
486
|
const tsRe = /\.tsx?$/u;
|
|
@@ -476,7 +504,8 @@ plugin.createRule({
|
|
|
476
504
|
meta: {
|
|
477
505
|
docs: {
|
|
478
506
|
description: "Checks that files redundant to TypeScript implementation files are not checked in.",
|
|
479
|
-
defaultLevel: "error"
|
|
507
|
+
defaultLevel: "error",
|
|
508
|
+
isTypeChecked: false
|
|
480
509
|
},
|
|
481
510
|
messages: {
|
|
482
511
|
js: "Redundant JavaScript file detected. Please `git rm -f {{file}}`",
|
|
@@ -492,16 +521,16 @@ plugin.createRule({
|
|
|
492
521
|
return {
|
|
493
522
|
Program(node) {
|
|
494
523
|
if (!filePath.endsWith(".d.ts") && tsRe.test(filePath)) {
|
|
495
|
-
const
|
|
496
|
-
if (!
|
|
524
|
+
const projectRoot2 = findProjectRoot(filePath);
|
|
525
|
+
if (!projectRoot2) {
|
|
497
526
|
context.report({ node, messageId: "missingProjectRoot" });
|
|
498
527
|
return;
|
|
499
528
|
}
|
|
500
|
-
const gitIndexFiles2 = getGitIndexFiles(
|
|
529
|
+
const gitIndexFiles2 = getGitIndexFiles(projectRoot2);
|
|
501
530
|
if (!gitIndexFiles2) {
|
|
502
531
|
return;
|
|
503
532
|
}
|
|
504
|
-
filePath = relative(
|
|
533
|
+
filePath = relative(projectRoot2, filePath);
|
|
505
534
|
const jsFilename = filePath.replace(tsRe, ".js");
|
|
506
535
|
if (gitIndexFiles2.has(jsFilename)) {
|
|
507
536
|
context.report({ node, messageId: "js", data: { file: jsFilename } });
|
|
@@ -519,8 +548,9 @@ plugin.createRule({
|
|
|
519
548
|
name: "prefer-relative-imports",
|
|
520
549
|
meta: {
|
|
521
550
|
docs: {
|
|
522
|
-
description: "Checks that whenever possible import and export paths are relative instead of absolute.",
|
|
523
|
-
defaultLevel: "error"
|
|
551
|
+
description: "Checks that whenever possible, import and export paths are relative instead of absolute.",
|
|
552
|
+
defaultLevel: "error",
|
|
553
|
+
isTypeChecked: false
|
|
524
554
|
},
|
|
525
555
|
messages: {
|
|
526
556
|
importFormat: 'Prefer relative ("{{relPath}}") over absolute path',
|
|
@@ -562,14 +592,24 @@ plugin.createRule({
|
|
|
562
592
|
}
|
|
563
593
|
});
|
|
564
594
|
function pathRoot(p) {
|
|
565
|
-
const
|
|
566
|
-
|
|
595
|
+
const pathImplementation = win32.isAbsolute(p) && !posix.isAbsolute(p) ? win32 : path;
|
|
596
|
+
let root = p;
|
|
597
|
+
while (true) {
|
|
598
|
+
const parent = pathImplementation.dirname(root);
|
|
599
|
+
if (parent === "." || parent === root) {
|
|
600
|
+
return root;
|
|
601
|
+
}
|
|
602
|
+
root = parent;
|
|
603
|
+
}
|
|
567
604
|
}
|
|
568
605
|
function verifyRelativeImport(context, node, absImportPath, basePath, importRoot) {
|
|
569
|
-
|
|
606
|
+
let modulePath = node.value;
|
|
570
607
|
if (modulePath.startsWith(".")) {
|
|
571
608
|
return;
|
|
572
609
|
}
|
|
610
|
+
if (modulePath.startsWith("esri/")) {
|
|
611
|
+
modulePath = modulePath.replace("esri/", "src/");
|
|
612
|
+
}
|
|
573
613
|
if (pathRoot(modulePath) === importRoot) {
|
|
574
614
|
let relPath = path.relative(path.join(basePath, absImportPath), path.join(basePath, modulePath));
|
|
575
615
|
if (!relPath.startsWith(".")) {
|
|
@@ -591,7 +631,8 @@ plugin.createRule({
|
|
|
591
631
|
meta: {
|
|
592
632
|
docs: {
|
|
593
633
|
description: "Checks that the corresponding calcite component import exists for each calcite component tag used. It also checks that there are no extra unnecessary imports.",
|
|
594
|
-
defaultLevel: "error"
|
|
634
|
+
defaultLevel: "error",
|
|
635
|
+
isTypeChecked: false
|
|
595
636
|
},
|
|
596
637
|
messages: {
|
|
597
638
|
missingImport: 'Import missing: import("@esri/calcite-components/dist/components/{{tag}}")',
|
|
@@ -640,7 +681,8 @@ plugin.createRule({
|
|
|
640
681
|
meta: {
|
|
641
682
|
docs: {
|
|
642
683
|
description: "Enforce filenames to be part of spec (test) top-level suites.",
|
|
643
|
-
defaultLevel: "error"
|
|
684
|
+
defaultLevel: "error",
|
|
685
|
+
isTypeChecked: false
|
|
644
686
|
},
|
|
645
687
|
messages: {
|
|
646
688
|
name: "Suite name must be the name of the spec file",
|
|
@@ -694,7 +736,7 @@ function getToplevelSuiteName(filename) {
|
|
|
694
736
|
return;
|
|
695
737
|
}
|
|
696
738
|
const relativePath = relative(root, filename).replaceAll(win32.sep, posix.sep);
|
|
697
|
-
return relativePath.replace(/^tests\/(.*)\.spec\.ts/u, "$1");
|
|
739
|
+
return relativePath.replace(/^tests\/(.*)\.spec\.ts/u, "$1").replace("src/", "esri/");
|
|
698
740
|
}
|
|
699
741
|
const corePlugin = plugin.finalize();
|
|
700
742
|
export {
|