@nx/eslint-plugin 23.1.0 → 23.1.2
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/nx.d.ts +3 -12
- package/dist/nx.js +1 -0
- package/dist/src/index.d.ts +3 -22
- package/dist/src/index.js +1 -0
- package/dist/src/rules/enforce-module-boundaries.js +4 -5
- package/dist/src/rules/nx-plugin-checks.d.ts +8 -1
- package/dist/src/rules/nx-plugin-checks.js +40 -0
- package/dist/src/utils/graph-utils.js +7 -7
- package/dist/src/utils/package-json-utils.d.ts +1 -1
- package/dist/src/utils/project-graph-utils.d.ts +1 -1
- package/dist/src/utils/project-graph-utils.js +8 -9
- package/dist/src/utils/runtime-lint-utils.d.ts +1 -1
- package/dist/src/utils/runtime-lint-utils.js +7 -8
- package/package.json +5 -5
package/dist/nx.d.ts
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
1
2
|
declare const plugin: {
|
|
2
|
-
configs:
|
|
3
|
-
rules:
|
|
4
|
-
"enforce-module-boundaries": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./src/rules/enforce-module-boundaries").MessageIds, import("./src/rules/enforce-module-boundaries").Options, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
5
|
-
name: string;
|
|
6
|
-
};
|
|
7
|
-
"nx-plugin-checks": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./src/rules/nx-plugin-checks").MessageIds, import("./src/rules/nx-plugin-checks").Options, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
8
|
-
name: string;
|
|
9
|
-
};
|
|
10
|
-
"dependency-checks": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./src/rules/dependency-checks").MessageIds, import("./src/rules/dependency-checks").Options, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
11
|
-
name: string;
|
|
12
|
-
};
|
|
13
|
-
};
|
|
3
|
+
configs: Record<string, unknown>;
|
|
4
|
+
rules: Record<string, TSESLint.RuleModule<string, unknown[]>>;
|
|
14
5
|
};
|
|
15
6
|
export default plugin;
|
package/dist/nx.js
CHANGED
|
@@ -5,6 +5,7 @@ const resolve_workspace_rules_1 = require("./src/resolve-workspace-rules");
|
|
|
5
5
|
const dependency_checks_1 = tslib_1.__importStar(require("./src/rules/dependency-checks"));
|
|
6
6
|
const enforce_module_boundaries_1 = tslib_1.__importStar(require("./src/rules/enforce-module-boundaries"));
|
|
7
7
|
const nx_plugin_checks_1 = tslib_1.__importStar(require("./src/rules/nx-plugin-checks"));
|
|
8
|
+
// Keep the annotation: the inferred type names RuleModule via a pnpm store path (TS2883).
|
|
8
9
|
const plugin = {
|
|
9
10
|
configs: {},
|
|
10
11
|
rules: {
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
1
2
|
import { loadWorkspaceRules } from './resolve-workspace-rules';
|
|
2
3
|
declare const configs: {
|
|
3
4
|
typescript: {
|
|
@@ -272,17 +273,7 @@ declare const configs: {
|
|
|
272
273
|
readonly "flat/angular": typeof import('./flat-configs/angular').default;
|
|
273
274
|
readonly "flat/angular-template": typeof import('./flat-configs/angular-template').default;
|
|
274
275
|
};
|
|
275
|
-
declare const rules:
|
|
276
|
-
"enforce-module-boundaries": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/enforce-module-boundaries").MessageIds, import("./rules/enforce-module-boundaries").Options, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
277
|
-
name: string;
|
|
278
|
-
};
|
|
279
|
-
"nx-plugin-checks": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/nx-plugin-checks").MessageIds, import("./rules/nx-plugin-checks").Options, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
280
|
-
name: string;
|
|
281
|
-
};
|
|
282
|
-
"dependency-checks": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/dependency-checks").MessageIds, import("./rules/dependency-checks").Options, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
283
|
-
name: string;
|
|
284
|
-
};
|
|
285
|
-
};
|
|
276
|
+
declare const rules: Record<string, TSESLint.RuleModule<string, unknown[]>>;
|
|
286
277
|
declare const _default: {
|
|
287
278
|
configs: {
|
|
288
279
|
typescript: {
|
|
@@ -557,17 +548,7 @@ declare const _default: {
|
|
|
557
548
|
readonly "flat/angular": typeof import('./flat-configs/angular').default;
|
|
558
549
|
readonly "flat/angular-template": typeof import('./flat-configs/angular-template').default;
|
|
559
550
|
};
|
|
560
|
-
rules:
|
|
561
|
-
"enforce-module-boundaries": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/enforce-module-boundaries").MessageIds, import("./rules/enforce-module-boundaries").Options, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
562
|
-
name: string;
|
|
563
|
-
};
|
|
564
|
-
"nx-plugin-checks": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/nx-plugin-checks").MessageIds, import("./rules/nx-plugin-checks").Options, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
565
|
-
name: string;
|
|
566
|
-
};
|
|
567
|
-
"dependency-checks": import("@typescript-eslint/utils/ts-eslint").RuleModule<import("./rules/dependency-checks").MessageIds, import("./rules/dependency-checks").Options, unknown, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
568
|
-
name: string;
|
|
569
|
-
};
|
|
570
|
-
};
|
|
551
|
+
rules: Record<string, TSESLint.RuleModule<string, unknown[], unknown, TSESLint.RuleListener>>;
|
|
571
552
|
};
|
|
572
553
|
export default _default;
|
|
573
554
|
export { configs, rules, loadWorkspaceRules };
|
package/dist/src/index.js
CHANGED
|
@@ -56,6 +56,7 @@ const configs = {
|
|
|
56
56
|
},
|
|
57
57
|
};
|
|
58
58
|
exports.configs = configs;
|
|
59
|
+
// Keep the annotation: the inferred type names RuleModule via a pnpm store path (TS2883).
|
|
59
60
|
const rules = {
|
|
60
61
|
[enforce_module_boundaries_1.RULE_NAME]: enforce_module_boundaries_1.default,
|
|
61
62
|
[nx_plugin_checks_1.RULE_NAME]: nx_plugin_checks_1.default,
|
|
@@ -4,13 +4,12 @@ exports.RULE_NAME = void 0;
|
|
|
4
4
|
const devkit_1 = require("@nx/devkit");
|
|
5
5
|
const utils_1 = require("@typescript-eslint/utils");
|
|
6
6
|
const internal_1 = require("@nx/js/internal");
|
|
7
|
-
const fileutils_1 = require("nx/src/utils/fileutils");
|
|
8
7
|
const path_1 = require("path");
|
|
9
8
|
const ast_utils_1 = require("../utils/ast-utils");
|
|
10
9
|
const graph_utils_1 = require("../utils/graph-utils");
|
|
11
10
|
const project_graph_utils_1 = require("../utils/project-graph-utils");
|
|
12
11
|
const runtime_lint_utils_1 = require("../utils/runtime-lint-utils");
|
|
13
|
-
const
|
|
12
|
+
const internal_2 = require("@nx/devkit/internal");
|
|
14
13
|
exports.RULE_NAME = 'enforce-module-boundaries';
|
|
15
14
|
exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl/nx/blob/${devkit_1.NX_VERSION}/docs/generated/packages/eslint-plugin/documents/enforce-module-boundaries.md`)({
|
|
16
15
|
name: exports.RULE_NAME,
|
|
@@ -236,7 +235,7 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
236
235
|
(0, runtime_lint_utils_1.findProjectUsingImport)(projectGraph, targetProjectLocator, sourceFilePath, imp);
|
|
237
236
|
if (!targetProject) {
|
|
238
237
|
// non-project imports cannot use relative or absolute paths
|
|
239
|
-
if ((0,
|
|
238
|
+
if ((0, internal_2.isRelativePath)(imp) || imp.startsWith('/')) {
|
|
240
239
|
context.report({
|
|
241
240
|
node,
|
|
242
241
|
messageId: 'noRelativeOrAbsoluteExternals',
|
|
@@ -264,7 +263,7 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
264
263
|
if (sourceProject === targetProject &&
|
|
265
264
|
!(0, graph_utils_1.circularPathHasPair)([sourceProject, targetProject], expandedIgnoreCircularDependencies)) {
|
|
266
265
|
if (!allowCircularSelfDependency &&
|
|
267
|
-
!(0,
|
|
266
|
+
!(0, internal_2.isRelativePath)(imp) &&
|
|
268
267
|
!(0, runtime_lint_utils_1.belongsToDifferentEntryPoint)(imp, sourceFilePath, sourceProject.data.root)) {
|
|
269
268
|
context.report({
|
|
270
269
|
node,
|
|
@@ -343,7 +342,7 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
|
|
|
343
342
|
}
|
|
344
343
|
return;
|
|
345
344
|
}
|
|
346
|
-
if (!(0,
|
|
345
|
+
if (!(0, internal_2.isProjectGraphProjectNode)(targetProject)) {
|
|
347
346
|
return;
|
|
348
347
|
}
|
|
349
348
|
targetProject = targetProject;
|
|
@@ -11,7 +11,7 @@ export type Options = [
|
|
|
11
11
|
tsConfig?: string;
|
|
12
12
|
}
|
|
13
13
|
];
|
|
14
|
-
export type MessageIds = 'missingRequiredSchema' | 'invalidSchemaPath' | 'missingImplementation' | 'invalidImplementationPath' | 'invalidImplementationModule' | 'unableToReadImplementationExports' | 'invalidPromptPath' | 'invalidVersion' | 'missingVersion' | 'noGeneratorsOrSchematicsFound' | 'noExecutorsOrBuildersFound' | 'valueShouldBeObject';
|
|
14
|
+
export type MessageIds = 'missingRequiredSchema' | 'invalidSchemaPath' | 'missingImplementation' | 'invalidImplementationPath' | 'invalidImplementationModule' | 'unableToReadImplementationExports' | 'invalidPromptPath' | 'invalidVersion' | 'missingVersion' | 'noGeneratorsOrSchematicsFound' | 'noExecutorsOrBuildersFound' | 'valueShouldBeObject' | 'duplicateKey';
|
|
15
15
|
export declare const RULE_NAME = "nx-plugin-checks";
|
|
16
16
|
declare const _default: TSESLint.RuleModule<MessageIds, Options, unknown, TSESLint.RuleListener> & {
|
|
17
17
|
name: string;
|
|
@@ -23,5 +23,12 @@ export declare function validateEntry(baseNode: AST.JSONObjectExpression, key: s
|
|
|
23
23
|
export declare function validateImplementationNode(implementationNode: AST.JSONProperty, key: string, context: TSESLint.RuleContext<MessageIds, Options>, projects: Record<string, ProjectConfiguration>): void;
|
|
24
24
|
export declare function validatePromptNode(promptNode: AST.JSONProperty, key: string, context: TSESLint.RuleContext<MessageIds, Options>): void;
|
|
25
25
|
export declare function validatePackageGroup(baseNode: AST.JSONObjectExpression, context: TSESLint.RuleContext<MessageIds, Options>): void;
|
|
26
|
+
/**
|
|
27
|
+
* A duplicate key anywhere in these manifests silently drops data:
|
|
28
|
+
* JSON parsers keep only the last occurrence, so a duplicated generator,
|
|
29
|
+
* executor, or migration entry key discards the earlier definition with no
|
|
30
|
+
* error at runtime.
|
|
31
|
+
*/
|
|
32
|
+
export declare function validateNoDuplicateKeys(node: AST.JSONObjectExpression | AST.JSONArrayExpression, context: TSESLint.RuleContext<MessageIds, Options>): void;
|
|
26
33
|
export declare function validateVersionJsonExpression(node: AST.JSONExpression, context: TSESLint.RuleContext<MessageIds, Options>): string | boolean;
|
|
27
34
|
export declare function checkIfIdentifierIsFunction(filePath: string, identifier: string): boolean;
|
|
@@ -7,6 +7,7 @@ exports.validateEntry = validateEntry;
|
|
|
7
7
|
exports.validateImplementationNode = validateImplementationNode;
|
|
8
8
|
exports.validatePromptNode = validatePromptNode;
|
|
9
9
|
exports.validatePackageGroup = validatePackageGroup;
|
|
10
|
+
exports.validateNoDuplicateKeys = validateNoDuplicateKeys;
|
|
10
11
|
exports.validateVersionJsonExpression = validateVersionJsonExpression;
|
|
11
12
|
exports.checkIfIdentifierIsFunction = checkIfIdentifierIsFunction;
|
|
12
13
|
const tslib_1 = require("tslib");
|
|
@@ -82,6 +83,7 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => ``)({
|
|
|
82
83
|
missingImplementation: '{{ key }}: Missing required property - `implementation`',
|
|
83
84
|
invalidPromptPath: '{{ key }}: Prompt path should point to a valid file',
|
|
84
85
|
missingVersion: '{{ key }}: Missing required property - `version`',
|
|
86
|
+
duplicateKey: '{{ key }}: Duplicate key. JSON parsers keep only the last occurrence, silently dropping the earlier one',
|
|
85
87
|
},
|
|
86
88
|
},
|
|
87
89
|
defaultOptions: [DEFAULT_OPTIONS],
|
|
@@ -109,6 +111,7 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => ``)({
|
|
|
109
111
|
}
|
|
110
112
|
return {
|
|
111
113
|
['JSONExpressionStatement > JSONObjectExpression'](node) {
|
|
114
|
+
validateNoDuplicateKeys(node, context);
|
|
112
115
|
if (sourceFilePath === generatorsJson) {
|
|
113
116
|
checkCollectionFileNode(node, 'generator', context, projects);
|
|
114
117
|
}
|
|
@@ -425,6 +428,43 @@ function validatePackageGroup(baseNode, context) {
|
|
|
425
428
|
}
|
|
426
429
|
}
|
|
427
430
|
}
|
|
431
|
+
/**
|
|
432
|
+
* A duplicate key anywhere in these manifests silently drops data:
|
|
433
|
+
* JSON parsers keep only the last occurrence, so a duplicated generator,
|
|
434
|
+
* executor, or migration entry key discards the earlier definition with no
|
|
435
|
+
* error at runtime.
|
|
436
|
+
*/
|
|
437
|
+
function validateNoDuplicateKeys(node, context) {
|
|
438
|
+
if (node.type === 'JSONObjectExpression') {
|
|
439
|
+
const seen = new Set();
|
|
440
|
+
for (const property of node.properties) {
|
|
441
|
+
const key = property.key.type === 'JSONLiteral'
|
|
442
|
+
? String(property.key.value)
|
|
443
|
+
: property.key.name;
|
|
444
|
+
if (seen.has(key)) {
|
|
445
|
+
context.report({
|
|
446
|
+
messageId: 'duplicateKey',
|
|
447
|
+
data: { key },
|
|
448
|
+
node: property.key,
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
seen.add(key);
|
|
452
|
+
if (property.value.type === 'JSONObjectExpression' ||
|
|
453
|
+
property.value.type === 'JSONArrayExpression') {
|
|
454
|
+
validateNoDuplicateKeys(property.value, context);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
for (const element of node.elements) {
|
|
460
|
+
if (element &&
|
|
461
|
+
(element.type === 'JSONObjectExpression' ||
|
|
462
|
+
element.type === 'JSONArrayExpression')) {
|
|
463
|
+
validateNoDuplicateKeys(element, context);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
428
468
|
function validateVersionJsonExpression(node, context) {
|
|
429
469
|
return (node &&
|
|
430
470
|
node.type === 'JSONLiteral' &&
|
|
@@ -7,8 +7,8 @@ exports.circularPathHasPair = circularPathHasPair;
|
|
|
7
7
|
exports.findFilesInCircularPath = findFilesInCircularPath;
|
|
8
8
|
exports.findFilesWithDynamicImports = findFilesWithDynamicImports;
|
|
9
9
|
exports.expandIgnoredCircularDependencies = expandIgnoredCircularDependencies;
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const devkit_1 = require("@nx/devkit");
|
|
11
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
12
12
|
const reach = {
|
|
13
13
|
graph: null,
|
|
14
14
|
matrix: null,
|
|
@@ -125,7 +125,7 @@ function findFilesInCircularPath(projectFileMap, circularPath) {
|
|
|
125
125
|
const next = circularPath[i + 1].name;
|
|
126
126
|
const files = projectFileMap[circularPath[i].name] || [];
|
|
127
127
|
filePathChain.push(files
|
|
128
|
-
.filter((file) => file.deps && file.deps.find((d) => (0,
|
|
128
|
+
.filter((file) => file.deps && file.deps.find((d) => (0, internal_1.fileDataDepTarget)(d) === next))
|
|
129
129
|
.map((file) => file.file));
|
|
130
130
|
}
|
|
131
131
|
return filePathChain;
|
|
@@ -135,8 +135,8 @@ function findFilesWithDynamicImports(projectFileMap, sourceProjectName, targetPr
|
|
|
135
135
|
projectFileMap[sourceProjectName].forEach((file) => {
|
|
136
136
|
if (!file.deps)
|
|
137
137
|
return;
|
|
138
|
-
if (file.deps.some((d) => (0,
|
|
139
|
-
(0,
|
|
138
|
+
if (file.deps.some((d) => (0, internal_1.fileDataDepTarget)(d) === targetProjectName &&
|
|
139
|
+
(0, internal_1.fileDataDepType)(d) === devkit_1.DependencyType.dynamic)) {
|
|
140
140
|
files.push(file);
|
|
141
141
|
}
|
|
142
142
|
});
|
|
@@ -145,8 +145,8 @@ function findFilesWithDynamicImports(projectFileMap, sourceProjectName, targetPr
|
|
|
145
145
|
function expandIgnoredCircularDependencies(ignoredCircularDependencies, projectGraph) {
|
|
146
146
|
const allowed = new Map();
|
|
147
147
|
for (const [a, b] of ignoredCircularDependencies) {
|
|
148
|
-
const setA = new Set((0,
|
|
149
|
-
const setB = new Set((0,
|
|
148
|
+
const setA = new Set((0, internal_1.findMatchingProjects)([a], projectGraph.nodes));
|
|
149
|
+
const setB = new Set((0, internal_1.findMatchingProjects)([b], projectGraph.nodes));
|
|
150
150
|
for (const projectA of setA) {
|
|
151
151
|
if (!allowed.has(projectA)) {
|
|
152
152
|
allowed.set(projectA, new Set());
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type PackageJson } from '@nx/devkit/internal';
|
|
2
2
|
export declare function getAllDependencies(packageJson: PackageJson): Record<string, string>;
|
|
3
3
|
export declare function getProductionDependencies(packageJson: PackageJson): Record<string, string>;
|
|
4
4
|
export declare function getPackageJson(path: string): PackageJson;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ProjectFileMap, ProjectGraph } from '@nx/devkit';
|
|
2
|
-
import { ProjectRootMappings } from 'nx/src/project-graph/utils/find-project-for-path';
|
|
3
2
|
import { TargetProjectLocator } from '@nx/js/internal';
|
|
3
|
+
import { ProjectRootMappings } from '@nx/devkit/internal';
|
|
4
4
|
export declare function ensureGlobalProjectGraph(ruleName: string): void;
|
|
5
5
|
export declare function readProjectGraph(ruleName: string): {
|
|
6
6
|
projectGraph: ProjectGraph;
|
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ensureGlobalProjectGraph = ensureGlobalProjectGraph;
|
|
4
4
|
exports.readProjectGraph = readProjectGraph;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
5
6
|
const devkit_1 = require("@nx/devkit");
|
|
6
7
|
const runtime_lint_utils_1 = require("./runtime-lint-utils");
|
|
7
|
-
const
|
|
8
|
-
const find_project_for_path_1 = require("nx/src/project-graph/utils/find-project-for-path");
|
|
9
|
-
const configuration_1 = require("nx/src/config/configuration");
|
|
8
|
+
const picocolors_1 = tslib_1.__importDefault(require("picocolors"));
|
|
10
9
|
const internal_1 = require("@nx/js/internal");
|
|
11
|
-
const
|
|
10
|
+
const internal_2 = require("@nx/devkit/internal");
|
|
12
11
|
function ensureGlobalProjectGraph(ruleName) {
|
|
13
12
|
/**
|
|
14
13
|
* Only reuse graph when running from terminal
|
|
@@ -18,7 +17,7 @@ function ensureGlobalProjectGraph(ruleName) {
|
|
|
18
17
|
!globalThis.projectRootMappings ||
|
|
19
18
|
!globalThis.projectFileMap ||
|
|
20
19
|
!(0, runtime_lint_utils_1.isTerminalRun)()) {
|
|
21
|
-
const nxJson = (0,
|
|
20
|
+
const nxJson = (0, internal_2.readNxJsonFromDisk)();
|
|
22
21
|
globalThis.workspaceLayout = nxJson.workspaceLayout;
|
|
23
22
|
/**
|
|
24
23
|
* Because there are a number of ways in which the rule can be invoked (executor vs ESLint CLI vs IDE Plugin),
|
|
@@ -27,13 +26,13 @@ function ensureGlobalProjectGraph(ruleName) {
|
|
|
27
26
|
try {
|
|
28
27
|
const projectGraph = (0, devkit_1.readCachedProjectGraph)();
|
|
29
28
|
globalThis.projectGraph = projectGraph;
|
|
30
|
-
globalThis.projectRootMappings = (0,
|
|
31
|
-
globalThis.projectFileMap = (0,
|
|
29
|
+
globalThis.projectRootMappings = (0, internal_2.createProjectRootMappings)(projectGraph.nodes);
|
|
30
|
+
globalThis.projectFileMap = (0, internal_2.readFileMapCache)().fileMap.projectFileMap;
|
|
32
31
|
globalThis.targetProjectLocator = new internal_1.TargetProjectLocator(projectGraph.nodes, projectGraph.externalNodes);
|
|
33
32
|
}
|
|
34
33
|
catch {
|
|
35
|
-
const WARNING_PREFIX = `${
|
|
36
|
-
const RULE_NAME_SUFFIX = `${
|
|
34
|
+
const WARNING_PREFIX = `${picocolors_1.default.reset(picocolors_1.default.yellow('warning'))}`;
|
|
35
|
+
const RULE_NAME_SUFFIX = `${picocolors_1.default.reset(picocolors_1.default.dim(`@nx/${ruleName}`))}`;
|
|
37
36
|
process.stdout
|
|
38
37
|
.write(`${WARNING_PREFIX} No cached ProjectGraph is available. The rule will be skipped.
|
|
39
38
|
If you encounter this error as part of running standard \`nx\` commands then please open an issue on https://github.com/nrwl/nx
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ProjectGraph, ProjectGraphDependency, ProjectGraphExternalNode, ProjectGraphProjectNode } from '@nx/devkit';
|
|
2
2
|
import { TargetProjectLocator } from '@nx/js/internal';
|
|
3
3
|
import { TSESLint, TSESTree } from '@typescript-eslint/utils';
|
|
4
|
-
import { ProjectRootMappings } from 'nx/
|
|
4
|
+
import { ProjectRootMappings } from '@nx/devkit/internal';
|
|
5
5
|
export type Deps = {
|
|
6
6
|
[projectName: string]: ProjectGraphDependency[];
|
|
7
7
|
};
|
|
@@ -30,9 +30,8 @@ const devkit_1 = require("@nx/devkit");
|
|
|
30
30
|
const js_1 = require("@nx/js");
|
|
31
31
|
const utils_1 = require("@typescript-eslint/utils");
|
|
32
32
|
const path = tslib_1.__importStar(require("node:path"));
|
|
33
|
-
const find_project_for_path_1 = require("nx/src/project-graph/utils/find-project-for-path");
|
|
34
|
-
const fileutils_1 = require("nx/src/utils/fileutils");
|
|
35
33
|
const graph_utils_1 = require("./graph-utils");
|
|
34
|
+
const internal_1 = require("@nx/devkit/internal");
|
|
36
35
|
function stringifyTags(tags) {
|
|
37
36
|
return tags.map((t) => `"${t}"`).join(', ');
|
|
38
37
|
}
|
|
@@ -114,7 +113,7 @@ function getTargetProjectBasedOnRelativeImport(imp, projectPath, projectGraph, p
|
|
|
114
113
|
return findProject(projectGraph, projectRootMappings, targetFile);
|
|
115
114
|
}
|
|
116
115
|
function findProject(projectGraph, projectRootMappings, sourceFilePath) {
|
|
117
|
-
return projectGraph.nodes[(0,
|
|
116
|
+
return projectGraph.nodes[(0, internal_1.findProjectForPath)(sourceFilePath, projectRootMappings)];
|
|
118
117
|
}
|
|
119
118
|
function isAbsoluteImportIntoAnotherProject(imp, workspaceLayout = { libsDir: 'libs', appsDir: 'apps' }) {
|
|
120
119
|
return (imp.startsWith(`${workspaceLayout.libsDir}/`) ||
|
|
@@ -252,7 +251,7 @@ function isDirectDependency(source, target) {
|
|
|
252
251
|
packageExistsInPackageJson(target.data.packageName, source.data.root));
|
|
253
252
|
}
|
|
254
253
|
function packageExistsInPackageJson(packageName, projectRoot) {
|
|
255
|
-
const content = (0,
|
|
254
|
+
const content = (0, internal_1.readFileIfExisting)(path.join(devkit_1.workspaceRoot, projectRoot, 'package.json'));
|
|
256
255
|
if (content) {
|
|
257
256
|
const { dependencies, devDependencies, peerDependencies } = (0, devkit_1.parseJson)(content);
|
|
258
257
|
if (dependencies && dependencies[packageName]) {
|
|
@@ -356,7 +355,7 @@ function getEntryPoint(file, projectRoot) {
|
|
|
356
355
|
}
|
|
357
356
|
// for Angular we need to find closest existing ng-package.json
|
|
358
357
|
// in order to determine if the file matches the secondary entry point
|
|
359
|
-
const ngPackageContent = (0,
|
|
358
|
+
const ngPackageContent = (0, internal_1.readFileIfExisting)(path.join(devkit_1.workspaceRoot, parent, 'ng-package.json'));
|
|
360
359
|
if (ngPackageContent) {
|
|
361
360
|
// https://github.com/ng-packagr/ng-packagr/blob/23c718d04eea85e015b4c261310b7bd0c39e5311/src/ng-package.schema.json#L54
|
|
362
361
|
const entryFile = (0, devkit_1.parseJson)(ngPackageContent)?.lib?.entryFile ?? 'src/public_api.ts';
|
|
@@ -367,7 +366,7 @@ function getEntryPoint(file, projectRoot) {
|
|
|
367
366
|
return undefined;
|
|
368
367
|
}
|
|
369
368
|
function getPackageEntryPoints(projectRoot) {
|
|
370
|
-
const packageContent = (0,
|
|
369
|
+
const packageContent = (0, internal_1.readFileIfExisting)(path.join(devkit_1.workspaceRoot, projectRoot, 'package.json'));
|
|
371
370
|
if (!packageContent) {
|
|
372
371
|
return [];
|
|
373
372
|
}
|
|
@@ -409,8 +408,8 @@ function parseExports(exports, projectRoot, entryPaths, basePath = '.') {
|
|
|
409
408
|
* Returns true if the given project contains MFE config with "exposes:" section
|
|
410
409
|
*/
|
|
411
410
|
function appIsMFERemote(project) {
|
|
412
|
-
const mfeConfig = (0,
|
|
413
|
-
(0,
|
|
411
|
+
const mfeConfig = (0, internal_1.readFileIfExisting)(path.join(devkit_1.workspaceRoot, project.data.root, 'module-federation.config.js')) ||
|
|
412
|
+
(0, internal_1.readFileIfExisting)(path.join(devkit_1.workspaceRoot, project.data.root, 'module-federation.config.ts'));
|
|
414
413
|
if (mfeConfig) {
|
|
415
414
|
return !!mfeConfig.match(/('|")?exposes('|")?:/);
|
|
416
415
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nx/eslint-plugin",
|
|
3
|
-
"version": "23.1.
|
|
3
|
+
"version": "23.1.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"files": [
|
|
@@ -95,17 +95,17 @@
|
|
|
95
95
|
"@phenomnomnominal/tsquery": "~6.2.0",
|
|
96
96
|
"@typescript-eslint/type-utils": "^8.0.0",
|
|
97
97
|
"@typescript-eslint/utils": "^8.0.0",
|
|
98
|
-
"chalk": "^4.1.0",
|
|
99
98
|
"confusing-browser-globals": "^1.0.9",
|
|
100
99
|
"globals": "^17.0.0",
|
|
101
100
|
"jsonc-eslint-parser": "^2.1.0",
|
|
101
|
+
"picocolors": "^1.1.0",
|
|
102
102
|
"semver": "^7.6.3",
|
|
103
103
|
"tslib": "^2.3.0",
|
|
104
|
-
"@nx/devkit": "23.1.
|
|
105
|
-
"@nx/js": "23.1.
|
|
104
|
+
"@nx/devkit": "23.1.2",
|
|
105
|
+
"@nx/js": "23.1.2"
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
|
-
"nx": "23.1.
|
|
108
|
+
"nx": "23.1.2"
|
|
109
109
|
},
|
|
110
110
|
"publishConfig": {
|
|
111
111
|
"access": "public"
|