Skip to content

Module Boundary Rules Not Enforced Due to Nx TargetProject Resolver Not Resolving Target Project Correctly #33985

@qing-lin-007

Description

@qing-lin-007

Current Behavior

In a monorepo that uses npm workspaces and relies on package name imports instead of path aliases, and each project’s package.json does not define a main or exports field. We are seeing issues when using @nx/eslint-plugin and @nx/eslint

The @nx/enforce-module-boundaries rule is not enforced because Nx’s target project locator fails to resolve the target project correctly.

In the example PR, running:

nx run cart:lint --skip-nx-cache

from the repo root does not produce the expected linting errors:

Image

Expected Behavior

Running the above nx command should throw linting errors, just as native eslint does:

npx eslint 'apps/cart/**/*.{ts,tsx,js,jsx}' --cache=false
Image

GitHub Repo

nrwl/nx-examples#404

Steps to Reproduce

  1. Checkout the branch
  2. yarn install
  3. in the root, run: nx run cart:lint --skip-nx-cache
  4. in the root, run: npx eslint 'apps/cart/**/*.{ts,tsx,js,jsx}' --cache=false

Nx Report

Node           : 22.21.0
OS             : darwin-arm64
Native Target  : aarch64-macos
yarn           : 4.2.2

nx (global)            : 21.0.3
nx                     : 22.4.0-beta.0
@nx/js                 : 22.4.0-beta.0
@nx/eslint             : 22.4.0-beta.0
@nx/workspace          : 22.4.0-beta.0
@nx/angular            : 22.4.0-beta.0
@nx/jest               : 22.4.0-beta.0
@nx/cypress            : 22.4.0-beta.0
@nx/devkit             : 22.4.0-beta.0
@nx/eslint-plugin      : 22.4.0-beta.0
@nx/module-federation  : 22.4.0-beta.0
@nx/react              : 22.4.0-beta.0
@nx/rollup             : 22.4.0-beta.0
@nx/rspack             : 22.4.0-beta.0
@nx/vite               : 22.4.0-beta.0
@nx/vitest             : 22.4.0-beta.0
@nx/web                : 22.4.0-beta.0
@nx/webpack            : 22.4.0-beta.0
typescript             : 5.9.2
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/cypress/plugin
@nx/jest/plugin
---------------------------------------
Community plugins:
@ngrx/component-store : 21.0.0
@ngrx/effects         : 21.0.0
@ngrx/entity          : 21.0.0
@ngrx/operators       : 21.0.0
@ngrx/router-store    : 21.0.0
@ngrx/store           : 21.0.0
@ngrx/store-devtools  : 21.0.0
---------------------------------------
Cache Usage: 1.96 KB / 46.04 GB

Failure Logs

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions