Nx "enforce-module-boundaries" lint violation in CI
The @nx/enforce-module-boundaries ESLint rule blocks imports that violate your project tag constraints (for example a scope:feature importing a scope:app). CI runs lint and fails on the forbidden import.
What this error means
ESLint fails in CI with an @nx/enforce-module-boundaries error naming the source and target tags and the disallowed import.
error A project tagged with "scope:shared" can only depend on libs tagged with
"scope:shared". Violation: importing "@app/feature-x" @nx/enforce-module-boundariesCommon causes
An import breaks a tag constraint
The rule's depConstraints forbid this source tag from depending on the target tag, so the import is a violation.
A missing or wrong tag on a project
A project without the right tags falls outside the allowed set, so an otherwise valid import is flagged.
How to fix it
Fix the import or the constraint
- Read the source and target tags in the error.
- Either move the code so the import is allowed, or widen
depConstraintsif the dependency is intentional. - Re-run lint to confirm the boundary passes.
"depConstraints": [
{ "sourceTag": "scope:shared", "onlyDependOnLibsWithTags": ["scope:shared"] }
]Tag the project correctly
Add the right tags in project.json so the import falls within an allowed relationship.
{ "name": "feature-x", "tags": ["scope:feature", "type:feature"] }How to prevent it
- Tag every project so boundary rules apply consistently.
- Keep
depConstraintsaligned with your intended architecture. - Run the boundaries lint locally before pushing.