Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The enforce-module-boundaries does not support complex TS paths rules #30172

Open
4 tasks
avaly opened this issue Feb 25, 2025 · 0 comments
Open
4 tasks

The enforce-module-boundaries does not support complex TS paths rules #30172

avaly opened this issue Feb 25, 2025 · 0 comments

Comments

@avaly
Copy link

avaly commented Feb 25, 2025

Current Behavior

The following paths config for TS seems to be valid for TypeScript itself.

    "paths": {
      "@libs/prefix-*": ["./libs/prefix/*"],
    }

However, the @nx/enforce-module-boundaries lint rule is complaining about a library from ./libs/prefix/foo importing another sibling library ./libs/prefix/bar.

import { bar } from '@libs/prefix-bar';
error    A project tagged with "type:lib" can only depend on libs tagged with "type:lib"

During investigating this bug, I tracked the source of the issue all the way down to these lines: https://github.com/nrwl/nx/blob/master/packages/nx/src/plugins/js/project-graph/build-dependencies/target-project-locator.ts#L249-L254

Expected Behavior

The lint rule should understand the complex paths config and not throw errors.

GitHub Repo

No response

Steps to Reproduce

  1. Create two libraries: @libs/prefix-foo & @libs/prefix-bar
  2. Add paths to tsconfig.json:
    "paths": {
      "@libs/prefix-*": ["./libs/prefix/*"],
    }
  1. Import one library from the other
  2. nx run-many -t lint

Nx Report

Node           : 22.13.0
OS             : linux-x64
Native Target  : x86_64-linux
yarn           : 4.6.0

nx                 : 20.4.0
@nx/js             : 20.4.0
@nx/jest           : 20.4.0
@nx/eslint         : 20.4.0
@nx/workspace      : 20.4.0
@nx/devkit         : 20.4.0
@nx/eslint-plugin  : 20.4.0
@nx/plugin         : 20.4.0
typescript         : 5.7.2
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/jest/plugin

Failure Logs

Package Manager Version

No response

Operating System

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

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant