@nx/eslint-plugin 24.0.0-beta.1 → 24.0.0-beta.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.
@@ -146,6 +146,24 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
146
146
  }
147
147
  const workspaceLayout = global.workspaceLayout;
148
148
  const expandedIgnoreCircularDependencies = (0, graph_utils_1.expandIgnoredCircularDependencies)(ignoredCircularDependencies, projectGraph);
149
+ let ultracacheImportsSpec;
150
+ // Atomized e2e specs (`<target>--<spec path>`) with the
151
+ // `// @nx-ultracache: imports` directive import app code with bare imports
152
+ // (`import 'app/feature'`) to hash from it.
153
+ function isUltracacheImport(node, sourceProject, sourceFilePath) {
154
+ if (node.type !== utils_1.AST_NODE_TYPES.ImportDeclaration ||
155
+ context.sourceCode.getFirstToken(node, 1).range[0] !==
156
+ node.source.range[0]) {
157
+ return false;
158
+ }
159
+ if (ultracacheImportsSpec === undefined) {
160
+ const specPath = (0, devkit_1.normalizePath)((0, path_1.relative)(sourceProject.data.root, sourceFilePath));
161
+ ultracacheImportsSpec =
162
+ (0, internal_2.hasUltracacheImportsDirective)(context.sourceCode.text) &&
163
+ Object.keys(sourceProject.data.targets ?? {}).some((targetName) => targetName.endsWith(`--${specPath}`));
164
+ }
165
+ return ultracacheImportsSpec;
166
+ }
149
167
  function run(imp, node) {
150
168
  // whitelisted import
151
169
  if (allow.some((a) => (0, runtime_lint_utils_1.matchImportWithWildcard)(a, imp))) {
@@ -166,8 +184,9 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
166
184
  else {
167
185
  targetProject = (0, runtime_lint_utils_1.getTargetProjectBasedOnRelativeImport)(imp, projectPath, projectGraph, projectRootMappings, sourceFilePath);
168
186
  }
169
- if ((targetProject && sourceProject !== targetProject) ||
170
- isAbsoluteImportIntoAnotherProj) {
187
+ if (((targetProject && sourceProject !== targetProject) ||
188
+ isAbsoluteImportIntoAnotherProj) &&
189
+ !isUltracacheImport(node, sourceProject, sourceFilePath)) {
171
190
  context.report({
172
191
  node,
173
192
  messageId: 'noRelativeOrAbsoluteImportsAcrossLibraries',
@@ -374,7 +393,9 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
374
393
  return;
375
394
  }
376
395
  // cannot import apps
377
- if (targetProject.type === 'app' && !(0, runtime_lint_utils_1.appIsMFERemote)(targetProject)) {
396
+ if (targetProject.type === 'app' &&
397
+ !(0, runtime_lint_utils_1.appIsMFERemote)(targetProject) &&
398
+ !isUltracacheImport(node, sourceProject, sourceFilePath)) {
378
399
  context.report({
379
400
  node,
380
401
  messageId: 'noImportsOfApps',
@@ -406,7 +427,8 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
406
427
  // this check only applies to ES import/export statements, not require() calls
407
428
  if (node.type !== utils_1.AST_NODE_TYPES.CallExpression &&
408
429
  !checkDynamicDependenciesExceptions.some((a) => (0, runtime_lint_utils_1.matchImportWithWildcard)(a, imp)) &&
409
- (0, runtime_lint_utils_1.hasStaticImportOfDynamicResource)(node, projectGraph, sourceProject.name, targetProject.name, imp, sourceFilePath)) {
430
+ (0, runtime_lint_utils_1.hasStaticImportOfDynamicResource)(node, projectGraph, sourceProject.name, targetProject.name, imp, sourceFilePath) &&
431
+ !isUltracacheImport(node, sourceProject, sourceFilePath)) {
410
432
  const filesWithLazyImports = (0, graph_utils_1.findFilesWithDynamicImports)(projectFileMap, sourceProject.name, targetProject.name);
411
433
  context.report({
412
434
  data: {
@@ -421,7 +443,8 @@ exports.default = utils_1.ESLintUtils.RuleCreator(() => `https://github.com/nrwl
421
443
  return;
422
444
  }
423
445
  // check that dependency constraints are satisfied
424
- if (depConstraints.length > 0) {
446
+ if (depConstraints.length > 0 &&
447
+ !isUltracacheImport(node, sourceProject, sourceFilePath)) {
425
448
  const constraints = (0, runtime_lint_utils_1.findConstraintsFor)(depConstraints, sourceProject);
426
449
  // when no constrains found => error. Force the user to provision them.
427
450
  if (constraints.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nx/eslint-plugin",
3
- "version": "24.0.0-beta.1",
3
+ "version": "24.0.0-beta.2",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "files": [
@@ -100,8 +100,8 @@
100
100
  }
101
101
  },
102
102
  "dependencies": {
103
- "@nx/devkit": "24.0.0-beta.1",
104
- "@nx/js": "24.0.0-beta.1",
103
+ "@nx/devkit": "24.0.0-beta.2",
104
+ "@nx/js": "24.0.0-beta.2",
105
105
  "@phenomnomnominal/tsquery": "~6.2.0",
106
106
  "@typescript-eslint/type-utils": "^8.0.0",
107
107
  "@typescript-eslint/utils": "^8.0.0",
@@ -113,7 +113,7 @@
113
113
  "tslib": "^2.3.0"
114
114
  },
115
115
  "devDependencies": {
116
- "nx": "24.0.0-beta.1"
116
+ "nx": "24.0.0-beta.2"
117
117
  },
118
118
  "publishConfig": {
119
119
  "access": "public"