Skip to content

Commit

Permalink
fix(linter): fix dependencies from projects on themselves when anothe…
Browse files Browse the repository at this point in the history
…r circular dependency exists (#3163)
  • Loading branch information
FrozenPandaz authored Jun 12, 2020
1 parent 0d9b8bb commit fc61fcb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ export default createESLintRule<Options, MessageIds>({
return;
}

// same project => allow
if (sourceProject === targetProject) {
return;
}

// check constraints between libs and apps
// check for circular dependency
if (isCircular(projectGraph, sourceProject, targetProject)) {
Expand All @@ -176,11 +181,6 @@ export default createESLintRule<Options, MessageIds>({
return;
}

// same project => allow
if (sourceProject === targetProject) {
return;
}

// cannot import apps
if (targetProject.type !== ProjectType.lib) {
context.report({
Expand Down
12 changes: 6 additions & 6 deletions packages/workspace/src/tslint/nxEnforceModuleBoundariesRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,19 @@ class EnforceModuleBoundariesWalker extends Lint.RuleWalker {
return;
}

// same project => allow
if (sourceProject === targetProject) {
super.visitImportDeclaration(node);
return;
}

// check for circular dependency
if (isCircular(this.projectGraph, sourceProject, targetProject)) {
const error = `Circular dependency between "${sourceProject.name}" and "${targetProject.name}" detected`;
this.addFailureAt(node.getStart(), node.getWidth(), error);
return;
}

// same project => allow
if (sourceProject === targetProject) {
super.visitImportDeclaration(node);
return;
}

// cannot import apps
if (targetProject.type !== ProjectType.lib) {
this.addFailureAt(
Expand Down

0 comments on commit fc61fcb

Please sign in to comment.