Skip to content

Commit

Permalink
cleanup(core): simplify tags variable naming
Browse files Browse the repository at this point in the history
rename allowedTags & disallowedTags variables for consistency and simplicity
  • Loading branch information
jaytavares committed Feb 4, 2022
1 parent d0acaee commit 631e736
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
12 changes: 6 additions & 6 deletions packages/eslint-plugin-nx/src/rules/enforce-module-boundaries.ts
Expand Up @@ -106,8 +106,8 @@ export default createESLintRule<Options, MessageIds>({
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: [
Expand Down Expand Up @@ -398,15 +398,15 @@ export default createESLintRule<Options, MessageIds>({
constraint.onlyDependOnLibsWithTags
)
) {
const allowedTags = constraint.onlyDependOnLibsWithTags
const tags = constraint.onlyDependOnLibsWithTags
.map((s) => `"${s}"`)
.join(', ');
context.report({
node,
messageId: 'onlyTagsConstraintViolation',
data: {
sourceTag: constraint.sourceTag,
allowedTags,
tags,
},
});
return;
Expand All @@ -419,15 +419,15 @@ export default createESLintRule<Options, MessageIds>({
constraint.notDependOnLibsWithTags
)
) {
const disallowedTags = constraint.notDependOnLibsWithTags
const tags = constraint.notDependOnLibsWithTags
.map((s) => `"${s}"`)
.join(', ');
context.report({
node,
messageId: 'notTagsConstraintViolation',
data: {
sourceTag: constraint.sourceTag,
disallowedTags: disallowedTags,
tags,
},
});
return;
Expand Down
Expand Up @@ -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;
}
Expand Down
4 changes: 1 addition & 3 deletions packages/workspace/src/utils/runtime-lint-utils.ts
Expand Up @@ -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;

Expand Down

0 comments on commit 631e736

Please sign in to comment.