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

@nrwl/nx/enforce-module-boundaries doesn't work with ESM .js-style imports of TS files #15996

Closed
Maxim-Mazurok opened this issue Mar 31, 2023 · 1 comment · Fixed by #16049
Closed
Assignees
Labels
outdated scope: linter Issues related to Eslint support in Nx type: bug

Comments

@Maxim-Mazurok
Copy link

Current Behavior

In my index.ts I import files using ESM-style with .js:

export * from './lib/is-even.js';
export * from './lib/is-number.js';

And inside of is-even/src/lib/is-even.ts I'm violating @nrwl/nx/enforce-module-boundaries eslint rule by importing from itself using non-relative path: import { isNumber } from '@myorg/is-even';

Now the rule doesn't work anymore and throws unrelated errors trying to read non-existing file, see logs below for error.

Expected Behavior

Rule doesn't throw error related to being unable to find a file, but rather warns about having to use relative imports.

GitHub Repo

https://github.com/Maxim-Mazurok/nx-recipes/tree/enforce-module-boundaries-repro/integrated

Steps to Reproduce

  1. git clone https://github.com/Maxim-Mazurok/nx-recipes
  2. cd nx-recipes
  3. git switch enforce-module-boundaries-repro
  4. cd integrated
  5. npm ci
  6. npm test
  7. Observe error

Nx Report

~/nx-recipes/integrated$ nx report

 >  NX   Report complete - copy this into the issue template

   Node : 16.13.0
   OS   : linux x64
   npm  : 8.1.0
   
   nx : 15.4.8
   @nrwl/angular : Not Found
   @nrwl/cypress : Not Found
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.0.10
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.0.10
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.0.10
   @nrwl/js : 15.0.10
   @nrwl/linter : 15.0.10
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : 15.0.2
   @nrwl/nx-plugin : Not Found
   @nrwl/react : Not Found
   @nrwl/react-native : Not Found
   @nrwl/rollup : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : Not Found
   @nrwl/webpack : Not Found
   @nrwl/workspace : 15.0.10
   @nrwl/vite : Not Found
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:

Failure Logs

~/nx-recipes/integrated$ nx run is-even:lint

> nx run is-even:lint


Linting "is-even"...

 >  NX   ENOENT: no such file or directory, open '/home/maxim/nx-recipes/integrated/packages/is-even/src/lib/is-even.js/index.ts'

   Occurred while linting /home/maxim/nx-recipes/integrated/packages/is-even/src/lib/is-even.ts:1
   Rule: "@nrwl/nx/enforce-module-boundaries"
   Pass --verbose to see the stacktrace.


 ——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Ran target lint for project is-even (1s)
 
    ✖    1/1 failed
    ✔    0/1 succeeded [0 read from cache]
 
   View structured, searchable error logs at https://cloud.nx.app/runs/O3W6N5z5O2

Additional Information

No response

@github-actions
Copy link

github-actions bot commented May 4, 2023

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 May 4, 2023
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

Successfully merging a pull request may close this issue.

3 participants