@nx/eslint-plugin 22.4.0-canary.20251229-0da6921 → 22.4.0-canary.20260101-80cde6a

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.4.0-canary.20251229-0da6921",
3
+ "version": "22.4.0-canary.20260101-80cde6a",
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.4.0-canary.20251229-0da6921",
38
- "@nx/js": "22.4.0-canary.20251229-0da6921",
37
+ "@nx/devkit": "22.4.0-canary.20260101-80cde6a",
38
+ "@nx/js": "22.4.0-canary.20260101-80cde6a",
39
39
  "@phenomnomnominal/tsquery": "~5.0.1",
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.4.0-canary.20251229-0da6921"
50
+ "nx": "22.4.0-canary.20260101-80cde6a"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"
@@ -10,6 +10,7 @@ export type Options = [
10
10
  includeTransitiveDependencies?: boolean;
11
11
  useLocalPathsForWorkspaceDependencies?: boolean;
12
12
  runtimeHelpers?: string[];
13
+ peerDepsVersionStrategy?: 'installed' | 'workspace';
13
14
  }
14
15
  ];
15
16
  export type MessageIds = 'missingDependency' | 'obsoleteDependency' | 'versionMismatch' | 'missingDependencySection' | 'invalidCatalogReference';
@@ -1 +1 @@
1
- {"version":3,"file":"dependency-checks.d.ts","sourceRoot":"","sources":["../../../../../packages/eslint-plugin/src/rules/dependency-checks.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAiBvD,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QACxB,wBAAwB,CAAC,EAAE,OAAO,CAAC;QACnC,yBAAyB,CAAC,EAAE,OAAO,CAAC;QACpC,sBAAsB,CAAC,EAAE,OAAO,CAAC;QACjC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;QAC/B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QACxB,6BAA6B,CAAC,EAAE,OAAO,CAAC;QACxC,qCAAqC,CAAC,EAAE,OAAO,CAAC;QAChD,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;KAC3B;CACF,CAAC;AAEF,MAAM,MAAM,UAAU,GAClB,mBAAmB,GACnB,oBAAoB,GACpB,iBAAiB,GACjB,0BAA0B,GAC1B,yBAAyB,CAAC;AAE9B,eAAO,MAAM,SAAS,sBAAsB,CAAC;;AAE7C,wBAgYG"}
1
+ {"version":3,"file":"dependency-checks.d.ts","sourceRoot":"","sources":["../../../../../packages/eslint-plugin/src/rules/dependency-checks.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAmBvD,MAAM,MAAM,OAAO,GAAG;IACpB;QACE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QACxB,wBAAwB,CAAC,EAAE,OAAO,CAAC;QACnC,yBAAyB,CAAC,EAAE,OAAO,CAAC;QACpC,sBAAsB,CAAC,EAAE,OAAO,CAAC;QACjC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;QAC/B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QACxB,6BAA6B,CAAC,EAAE,OAAO,CAAC;QACxC,qCAAqC,CAAC,EAAE,OAAO,CAAC;QAChD,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;QAC1B,uBAAuB,CAAC,EAAE,WAAW,GAAG,WAAW,CAAC;KACrD;CACF,CAAC;AAEF,MAAM,MAAM,UAAU,GAClB,mBAAmB,GACnB,oBAAoB,GACpB,iBAAiB,GACjB,0BAA0B,GAC1B,yBAAyB,CAAC;AAE9B,eAAO,MAAM,SAAS,sBAAsB,CAAC;;AAE7C,wBAqbG"}
@@ -10,6 +10,7 @@ const semver_1 = require("semver");
10
10
  const package_json_utils_1 = require("../utils/package-json-utils");
11
11
  const project_graph_utils_1 = require("../utils/project-graph-utils");
12
12
  const runtime_lint_utils_1 = require("../utils/runtime-lint-utils");
13
+ const WORKSPACE_VERSION_WILDCARD = 'workspace:*';
13
14
  exports.RULE_NAME = 'dependency-checks';
14
15
  exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl/nx/blob/${devkit_1.NX_VERSION}/docs/generated/packages/eslint-plugin/documents/dependency-checks.md`)({
15
16
  name: exports.RULE_NAME,
@@ -32,6 +33,11 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
32
33
  includeTransitiveDependencies: { type: 'boolean' },
33
34
  useLocalPathsForWorkspaceDependencies: { type: 'boolean' },
34
35
  runtimeHelpers: { type: 'array', items: { type: 'string' } },
36
+ peerDepsVersionStrategy: {
37
+ type: 'string',
38
+ enum: ['installed', 'workspace'],
39
+ description: 'Strategy for peer dependency versions. "installed" uses versions from root package.json (default). "workspace" uses workspace:* for all peer dependencies to ensure version synchronization in integrated monorepos.',
40
+ },
35
41
  },
36
42
  additionalProperties: false,
37
43
  },
@@ -55,9 +61,10 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
55
61
  includeTransitiveDependencies: false,
56
62
  useLocalPathsForWorkspaceDependencies: false,
57
63
  runtimeHelpers: [],
64
+ peerDepsVersionStrategy: 'installed',
58
65
  },
59
66
  ],
60
- create(context, [{ buildTargets, ignoredDependencies, ignoredFiles, checkMissingDependencies, checkObsoleteDependencies, checkVersionMismatches, includeTransitiveDependencies, useLocalPathsForWorkspaceDependencies, runtimeHelpers, },]) {
67
+ create(context, [{ buildTargets, ignoredDependencies, ignoredFiles, checkMissingDependencies, checkObsoleteDependencies, checkVersionMismatches, includeTransitiveDependencies, useLocalPathsForWorkspaceDependencies, runtimeHelpers, peerDepsVersionStrategy = 'installed', },]) {
61
68
  if (!(0, runtime_lint_utils_1.getParserServices)(context).isJSON) {
62
69
  return {};
63
70
  }
@@ -93,12 +100,23 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
93
100
  const packageJson = JSON.parse(context.sourceCode.getText());
94
101
  const projPackageJsonDeps = (0, package_json_utils_1.getProductionDependencies)(packageJson);
95
102
  const rootPackageJsonDeps = (0, package_json_utils_1.getAllDependencies)(rootPackageJson);
103
+ function getDependencySection(node) {
104
+ // Check if this node is a dependency section itself
105
+ const directSection = node.key?.value;
106
+ if (['dependencies', 'peerDependencies', 'optionalDependencies'].includes(directSection)) {
107
+ return directSection;
108
+ }
109
+ // Otherwise, traverse up to find the parent section
110
+ const sectionProp = node.parent?.parent;
111
+ return sectionProp?.key?.value;
112
+ }
96
113
  function validateMissingDependencies(node) {
97
114
  if (!checkMissingDependencies) {
98
115
  return;
99
116
  }
100
117
  const missingDeps = expectedDependencyNames.filter((d) => !projPackageJsonDeps[d] && !ignoredDependencies.includes(d));
101
118
  if (missingDeps.length) {
119
+ const dependencySection = getDependencySection(node);
102
120
  context.report({
103
121
  node: node,
104
122
  messageId: 'missingDependency',
@@ -109,8 +127,14 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
109
127
  },
110
128
  fix(fixer) {
111
129
  missingDeps.forEach((d) => {
112
- projPackageJsonDeps[d] =
113
- rootPackageJsonDeps[d] || npmDependencies[d];
130
+ if (dependencySection === 'peerDependencies' &&
131
+ peerDepsVersionStrategy === 'workspace') {
132
+ projPackageJsonDeps[d] = WORKSPACE_VERSION_WILDCARD;
133
+ }
134
+ else {
135
+ projPackageJsonDeps[d] =
136
+ rootPackageJsonDeps[d] || npmDependencies[d];
137
+ }
114
138
  });
115
139
  const deps = node.value.properties;
116
140
  const mappedDeps = missingDeps
@@ -149,7 +173,18 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
149
173
  }
150
174
  }
151
175
  function validateVersionMatchesInstalled(node, packageName, packageRange) {
152
- if (!checkVersionMismatches) {
176
+ if (!checkVersionMismatches)
177
+ return;
178
+ const dependencySection = getDependencySection(node);
179
+ if (dependencySection === 'peerDependencies' &&
180
+ peerDepsVersionStrategy === 'workspace' &&
181
+ !packageRange.startsWith('workspace:')) {
182
+ context.report({
183
+ node: node,
184
+ messageId: 'versionMismatch',
185
+ data: { packageName, version: WORKSPACE_VERSION_WILDCARD },
186
+ fix: (fixer) => fixer.replaceText(node, `"${packageName}": "${WORKSPACE_VERSION_WILDCARD}"`),
187
+ });
153
188
  return;
154
189
  }
155
190
  // Resolve catalog references before validation