Skip to content
Latchkey

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.

Nx
error  A project tagged with "scope:shared" can only depend on libs tagged with
"scope:shared". Violation: importing "@app/feature-x"  @nx/enforce-module-boundaries

Common 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

  1. Read the source and target tags in the error.
  2. Either move the code so the import is allowed, or widen depConstraints if the dependency is intentional.
  3. Re-run lint to confirm the boundary passes.
.eslintrc.json
"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.

project.json
{ "name": "feature-x", "tags": ["scope:feature", "type:feature"] }

How to prevent it

  • Tag every project so boundary rules apply consistently.
  • Keep depConstraints aligned with your intended architecture.
  • Run the boundaries lint locally before pushing.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →