@nx/eslint-plugin 22.6.0 → 22.7.0-beta.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/eslint-plugin",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.7.0-beta.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The eslint-plugin package is an ESLint plugin that contains a collection of recommended ESLint rule configurations which you can extend from in your own ESLint configs, as well as an Nx-specific lint rule called enforce-module-boundaries.",
|
|
6
6
|
"repository": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@nx/devkit": "22.
|
|
38
|
-
"@nx/js": "22.
|
|
37
|
+
"@nx/devkit": "22.7.0-beta.0",
|
|
38
|
+
"@nx/js": "22.7.0-beta.0",
|
|
39
39
|
"@phenomnomnominal/tsquery": "~6.1.4",
|
|
40
40
|
"@typescript-eslint/type-utils": "^8.0.0",
|
|
41
41
|
"@typescript-eslint/utils": "^8.0.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"tslib": "^2.3.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"nx": "22.
|
|
50
|
+
"nx": "22.7.0-beta.0"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enforce-module-boundaries.d.ts","sourceRoot":"","sources":["../../../../../packages/eslint-plugin/src/rules/enforce-module-boundaries.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,WAAW,EAEZ,MAAM,0BAA0B,CAAC;AAiBlC,OAAO,EAGL,aAAa,EAmBd,MAAM,6BAA6B,CAAC;AAGrC,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,YAAY,EAAE,MAAM,EAAE,CAAC;QACvB,cAAc,EAAE,aAAa,EAAE,CAAC;QAChC,6BAA6B,EAAE,OAAO,CAAC;QACvC,2BAA2B,EAAE,OAAO,CAAC;QACrC,2BAA2B,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACrD,kCAAkC,EAAE,MAAM,EAAE,CAAC;QAC7C,yBAAyB,EAAE,OAAO,CAAC;QACnC,0BAA0B,EAAE,OAAO,CAAC;KACrC;CACF,CAAC;AACF,MAAM,MAAM,UAAU,GAClB,4CAA4C,GAC5C,+BAA+B,GAC/B,4BAA4B,GAC5B,wBAAwB,GACxB,iBAAiB,GACjB,gBAAgB,GAChB,iCAAiC,GACjC,gCAAgC,GAChC,0CAA0C,GAC1C,gCAAgC,GAChC,sCAAsC,GACtC,0BAA0B,GAC1B,6BAA6B,GAC7B,kCAAkC,GAClC,4BAA4B,CAAC;AACjC,eAAO,MAAM,SAAS,8BAA8B,CAAC;;AAErD,
|
|
1
|
+
{"version":3,"file":"enforce-module-boundaries.d.ts","sourceRoot":"","sources":["../../../../../packages/eslint-plugin/src/rules/enforce-module-boundaries.ts"],"names":[],"mappings":"AAQA,OAAO,EAEL,WAAW,EAEZ,MAAM,0BAA0B,CAAC;AAiBlC,OAAO,EAGL,aAAa,EAmBd,MAAM,6BAA6B,CAAC;AAGrC,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,KAAK,EAAE,MAAM,EAAE,CAAC;QAChB,YAAY,EAAE,MAAM,EAAE,CAAC;QACvB,cAAc,EAAE,aAAa,EAAE,CAAC;QAChC,6BAA6B,EAAE,OAAO,CAAC;QACvC,2BAA2B,EAAE,OAAO,CAAC;QACrC,2BAA2B,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QACrD,kCAAkC,EAAE,MAAM,EAAE,CAAC;QAC7C,yBAAyB,EAAE,OAAO,CAAC;QACnC,0BAA0B,EAAE,OAAO,CAAC;KACrC;CACF,CAAC;AACF,MAAM,MAAM,UAAU,GAClB,4CAA4C,GAC5C,+BAA+B,GAC/B,4BAA4B,GAC5B,wBAAwB,GACxB,iBAAiB,GACjB,gBAAgB,GAChB,iCAAiC,GACjC,gCAAgC,GAChC,0CAA0C,GAC1C,gCAAgC,GAChC,sCAAsC,GACtC,0BAA0B,GAC1B,6BAA6B,GAC7B,kCAAkC,GAClC,4BAA4B,CAAC;AACjC,eAAO,MAAM,SAAS,8BAA8B,CAAC;;AAErD,wBA0wBG"}
|
|
@@ -147,17 +147,7 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
147
147
|
}
|
|
148
148
|
const workspaceLayout = global.workspaceLayout;
|
|
149
149
|
const expandedIgnoreCircularDependencies = (0, graph_utils_1.expandIgnoredCircularDependencies)(ignoredCircularDependencies, projectGraph);
|
|
150
|
-
function run(node) {
|
|
151
|
-
// Ignoring ExportNamedDeclarations like:
|
|
152
|
-
// export class Foo {}
|
|
153
|
-
if (!node.source) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
// accept only literals because template literals have no value
|
|
157
|
-
if (node.source.type !== utils_1.AST_NODE_TYPES.Literal) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
const imp = node.source.value;
|
|
150
|
+
function run(imp, node) {
|
|
161
151
|
// whitelisted import
|
|
162
152
|
if (allow.some((a) => (0, runtime_lint_utils_1.matchImportWithWildcard)(a, imp))) {
|
|
163
153
|
return;
|
|
@@ -414,7 +404,9 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
414
404
|
}
|
|
415
405
|
}
|
|
416
406
|
// if we import a library using loadChildren, we should not import it using es6imports
|
|
417
|
-
|
|
407
|
+
// this check only applies to ES import/export statements, not require() calls
|
|
408
|
+
if (node.type !== utils_1.AST_NODE_TYPES.CallExpression &&
|
|
409
|
+
!checkDynamicDependenciesExceptions.some((a) => (0, runtime_lint_utils_1.matchImportWithWildcard)(a, imp)) &&
|
|
418
410
|
(0, runtime_lint_utils_1.hasStaticImportOfDynamicResource)(node, projectGraph, sourceProject.name, targetProject.name, imp, sourceFilePath)) {
|
|
419
411
|
const filesWithLazyImports = (0, graph_utils_1.findFilesWithDynamicImports)(projectFileMap, sourceProject.name, targetProject.name);
|
|
420
412
|
context.report({
|
|
@@ -517,18 +509,63 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
517
509
|
}
|
|
518
510
|
}
|
|
519
511
|
}
|
|
512
|
+
function getImportFromSourceNode(node) {
|
|
513
|
+
if (!node.source) {
|
|
514
|
+
return undefined;
|
|
515
|
+
}
|
|
516
|
+
if (node.source.type !== utils_1.AST_NODE_TYPES.Literal) {
|
|
517
|
+
return undefined;
|
|
518
|
+
}
|
|
519
|
+
return node.source.value;
|
|
520
|
+
}
|
|
521
|
+
function getImportFromRequireCall(node) {
|
|
522
|
+
const callee = node.callee;
|
|
523
|
+
const isRequire = callee.type === utils_1.AST_NODE_TYPES.Identifier && callee.name === 'require';
|
|
524
|
+
const isRequireResolve = callee.type === utils_1.AST_NODE_TYPES.MemberExpression &&
|
|
525
|
+
callee.object.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
526
|
+
callee.object.name === 'require' &&
|
|
527
|
+
callee.property.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
528
|
+
callee.property.name === 'resolve';
|
|
529
|
+
if (!isRequire && !isRequireResolve) {
|
|
530
|
+
return undefined;
|
|
531
|
+
}
|
|
532
|
+
const arg = node.arguments[0];
|
|
533
|
+
if (arg?.type === utils_1.AST_NODE_TYPES.Literal &&
|
|
534
|
+
typeof arg.value === 'string') {
|
|
535
|
+
return arg.value;
|
|
536
|
+
}
|
|
537
|
+
return undefined;
|
|
538
|
+
}
|
|
520
539
|
return {
|
|
521
540
|
ImportDeclaration(node) {
|
|
522
|
-
|
|
541
|
+
const imp = getImportFromSourceNode(node);
|
|
542
|
+
if (imp !== undefined) {
|
|
543
|
+
run(imp, node);
|
|
544
|
+
}
|
|
523
545
|
},
|
|
524
546
|
ImportExpression(node) {
|
|
525
|
-
|
|
547
|
+
const imp = getImportFromSourceNode(node);
|
|
548
|
+
if (imp !== undefined) {
|
|
549
|
+
run(imp, node);
|
|
550
|
+
}
|
|
526
551
|
},
|
|
527
552
|
ExportAllDeclaration(node) {
|
|
528
|
-
|
|
553
|
+
const imp = getImportFromSourceNode(node);
|
|
554
|
+
if (imp !== undefined) {
|
|
555
|
+
run(imp, node);
|
|
556
|
+
}
|
|
529
557
|
},
|
|
530
558
|
ExportNamedDeclaration(node) {
|
|
531
|
-
|
|
559
|
+
const imp = getImportFromSourceNode(node);
|
|
560
|
+
if (imp !== undefined) {
|
|
561
|
+
run(imp, node);
|
|
562
|
+
}
|
|
563
|
+
},
|
|
564
|
+
CallExpression(node) {
|
|
565
|
+
const imp = getImportFromRequireCall(node);
|
|
566
|
+
if (imp !== undefined) {
|
|
567
|
+
run(imp, node);
|
|
568
|
+
}
|
|
532
569
|
},
|
|
533
570
|
};
|
|
534
571
|
},
|