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

@nx/enforce-module-boundaries doesn't work with ESM .js-style imports of TSX files with deep import and aliases #22356

Closed
1 of 4 tasks
lionelhorn opened this issue Mar 17, 2024 · 2 comments
Assignees
Labels
outdated scope: linter Issues related to Eslint support in Nx type: bug

Comments

@lionelhorn
Copy link

lionelhorn commented Mar 17, 2024

Current Behavior

Similar but not exactly to #15996

Linting fails because @nx/enforce-module-boundaries doesn't properly resolve imports when

  • Tsconfig paths are used
  • Alias has a *
  • Esm import with .js extension are used

Like "@nx-example/shared/product/ui/*": ["libs/shared/product/ui/src/lib/*"],

https://github.com/lionelhorn/nx-examples/blob/530304282599b6f596f9cac04df38b31357f8e4e/tsconfig.base.json#L49

Error: ENOENT: no such file or directory, open '/PROG/_experiments/_nx/nx-examples/libs/shared/product/ui/src/lib/product-price/dummy-component.js'
Occurred while linting C:\PROG\_experiments\_nx\nx-examples\libs\shared\product\ui\src\lib\product-price\some-component.tsx:3
Rule: "@nx/enforce-module-boundaries"
    at Object.openSync (node:fs:603:3)
    at readFileSync (node:fs:471:35)
    at getRelativeImportPath (C:\PROG\_experiments\_nx\nx-examples\node_modules\@nx\eslint-plugin\src\utils\ast-utils.js:101:47)

Expected Behavior

Linting to show @nx/enforce-module-boundaries errors instead of file import resolve issues

GitHub Repo

https://github.com/lionelhorn/nx-examples

Steps to Reproduce

  1. git clone https://github.com/lionelhorn/nx-examples
  2. cd nx-examples
  3. yarn install
  4. cd libs/shared/product/ui
  5. yarn run lint-repro

Nx Report

Node   : 18.18.2
OS     : win32-x64
yarn   : 1.22.22

nx (global)        : 18.0.3
nx                 : 18.1.0-beta.10
@nx/js             : 18.1.0-beta.10
@nx/jest           : 18.1.0-beta.10
@nx/linter         : 18.1.0-beta.10
@nx/eslint         : 18.1.0-beta.10
@nx/workspace      : 18.1.0-beta.10
@nx/angular        : 18.1.0-beta.10
@nx/cypress        : 18.1.0-beta.10
@nx/devkit         : 18.1.0-beta.10
@nx/eslint-plugin  : 18.1.0-beta.10
@nx/react          : 18.1.0-beta.10
@nrwl/tao          : 18.1.0-beta.10
@nx/web            : 18.1.0-beta.10
@nx/webpack        : 18.1.0-beta.10
typescript         : 5.3.3
---------------------------------------
Community plugins:
@ngrx/component-store : 17.0.1
@ngrx/effects         : 17.0.1
@ngrx/entity          : 17.0.1
@ngrx/router-store    : 17.0.1
@ngrx/store           : 17.0.1
@ngrx/store-devtools  : 17.0.1

Failure Logs

No response

Package Manager Version

No response

Operating System

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

Additional Information

No response

@FrozenPandaz FrozenPandaz added the scope: linter Issues related to Eslint support in Nx label Mar 18, 2024
@fahslaj fahslaj assigned JamesHenry and unassigned fahslaj May 14, 2024
@leosvelperez
Copy link
Member

This was fixed by #26373.

Copy link

github-actions bot commented Jul 6, 2024

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: linter Issues related to Eslint support in Nx type: bug
Projects
None yet
Development

No branches or pull requests

5 participants