From 631e73600d6a2edf2ab2a997a9807f5d1e65b0e3 Mon Sep 17 00:00:00 2001 From: Jay Tavares Date: Fri, 4 Feb 2022 15:21:49 -0500 Subject: [PATCH] cleanup(core): simplify tags variable naming rename allowedTags & disallowedTags variables for consistency and simplicity --- .../src/rules/enforce-module-boundaries.ts | 12 ++++++------ .../src/tslint/nxEnforceModuleBoundariesRule.ts | 4 ++-- packages/workspace/src/utils/runtime-lint-utils.ts | 4 +--- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.ts b/packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.ts index 17fc0c10f0f726..01430c9c2dd00e 100644 --- a/packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.ts +++ b/packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.ts @@ -106,8 +106,8 @@ export default createESLintRule({ projectWithoutTagsCannotHaveDependencies: `A project without tags matching at least one constraint cannot depend on any libraries`, bannedExternalImportsViolation: `A project tagged with "{{sourceTag}}" is not allowed to import the "{{package}}" package`, noTransitiveDependencies: `Transitive dependencies are not allowed. Only packages defined in the "package.json" can be imported`, - onlyTagsConstraintViolation: `A project tagged with "{{sourceTag}}" can only depend on libs tagged with {{allowedTags}}`, - notTagsConstraintViolation: `A project tagged with "{{sourceTag}}" can not depend on libs tagged with {{disallowedTags}}`, + onlyTagsConstraintViolation: `A project tagged with "{{sourceTag}}" can only depend on libs tagged with {{tags}}`, + notTagsConstraintViolation: `A project tagged with "{{sourceTag}}" can not depend on libs tagged with {{tags}}`, }, }, defaultOptions: [ @@ -398,7 +398,7 @@ export default createESLintRule({ constraint.onlyDependOnLibsWithTags ) ) { - const allowedTags = constraint.onlyDependOnLibsWithTags + const tags = constraint.onlyDependOnLibsWithTags .map((s) => `"${s}"`) .join(', '); context.report({ @@ -406,7 +406,7 @@ export default createESLintRule({ messageId: 'onlyTagsConstraintViolation', data: { sourceTag: constraint.sourceTag, - allowedTags, + tags, }, }); return; @@ -419,7 +419,7 @@ export default createESLintRule({ constraint.notDependOnLibsWithTags ) ) { - const disallowedTags = constraint.notDependOnLibsWithTags + const tags = constraint.notDependOnLibsWithTags .map((s) => `"${s}"`) .join(', '); context.report({ @@ -427,7 +427,7 @@ export default createESLintRule({ messageId: 'notTagsConstraintViolation', data: { sourceTag: constraint.sourceTag, - disallowedTags: disallowedTags, + tags, }, }); return; diff --git a/packages/workspace/src/tslint/nxEnforceModuleBoundariesRule.ts b/packages/workspace/src/tslint/nxEnforceModuleBoundariesRule.ts index 5d6ca05c27061a..967d7964fa9fda 100644 --- a/packages/workspace/src/tslint/nxEnforceModuleBoundariesRule.ts +++ b/packages/workspace/src/tslint/nxEnforceModuleBoundariesRule.ts @@ -277,10 +277,10 @@ class EnforceModuleBoundariesWalker extends Lint.RuleWalker { constraint.onlyDependOnLibsWithTags || [] ) ) { - const allowedTags = constraint.onlyDependOnLibsWithTags + const tags = constraint.onlyDependOnLibsWithTags .map((s) => `"${s}"`) .join(', '); - const error = `A project tagged with "${constraint.sourceTag}" can only depend on libs tagged with ${allowedTags}`; + const error = `A project tagged with "${constraint.sourceTag}" can only depend on libs tagged with ${tags}`; this.addFailureAt(node.getStart(), node.getWidth(), error); return; } diff --git a/packages/workspace/src/utils/runtime-lint-utils.ts b/packages/workspace/src/utils/runtime-lint-utils.ts index 22414dd3ec65a7..41d62c2458bb87 100644 --- a/packages/workspace/src/utils/runtime-lint-utils.ts +++ b/packages/workspace/src/utils/runtime-lint-utils.ts @@ -47,9 +47,7 @@ export function hasAnyOfTheseTags( visited = visited ?? []; let found = - tags.filter((disallowedTag) => - hasTag(graph.nodes[projectName], disallowedTag) - ).length !== 0; + tags.filter((tag) => hasTag(graph.nodes[projectName], tag)).length !== 0; if (found) return true;