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

eslint enforce-module-boundaries rule throws error if there's no entryFile in ng-package.json of secondary entry point #27949

Open
1 of 4 tasks
mkhodan opened this issue Sep 17, 2024 · 1 comment
Assignees
Labels
scope: linter Issues related to Eslint support in Nx type: bug

Comments

@mkhodan
Copy link

mkhodan commented Sep 17, 2024

Current Behavior

Right now if user hasn't specified entryFile in ng-package.json of secondary entry point enforce-module-boundaries throws an error:

Oops! Something went wrong! :(

ESLint: 8.57.0

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
Occurred while linting 
Rule: "@nrwl/nx/enforce-module-boundaries"
    at Object.join (node:path:433:7)
    at joinPathFragments (C:\dev\app-3\node_modules\nx\src\utils\path.js:22:31)
    at getAngularEntryPoint (C:\dev\app-3\node_modules\@nx\eslint-plugin\src\utils\runtime-lint-utils.js:348:51)
    at belongsToDifferentNgEntryPoint (C:\dev\app-3\node_modules\@nx\eslint-plugin\src\utils\runtime-lint-utils.js:333:30)
    at run (C:\dev\app-3\node_modules\@nx\eslint-plugin\src\rules\enforce-module-boundaries.js:228:78)
    at ImportDeclaration (C:\dev\app-3\node_modules\@nx\eslint-plugin\src\rules\enforce-module-boundaries.js:467:17)
    at ruleErrorHandler (C:\dev\app-3\node_modules\eslint\lib\linter\linter.js:1076:28)
    at C:\dev\app-3\node_modules\eslint\lib\linter\safe-emitter.js:45:58
    at Array.forEach (<anonymous>)
    at Object.emit (C:\dev\app-3\node_modules\eslint\lib\linter\safe-emitter.js:45:38)

Expected Behavior

According to https://github.com/ng-packagr/ng-packagr/blob/main/docs/secondary-entrypoints.md the contents of my_package/testing/ng-package.json can be as simple as:

{}

and ng-packagr will assume that it is src/public_api.ts

GitHub Repo

No response

Steps to Reproduce

  1. Create an angular library with secondary entry point
  2. leave ng-package.json config of secondary entry point as an empty object
  3. run eslint with a rule enforce-module-boundaries enabled

Nx Report

Node   : 20.15.1
OS     : win32-x64
npm    : 10.7.0

nx                 : 18.2.4
@nx/js             : 18.2.4
@nx/jest           : 18.2.4
@nx/linter         : 18.2.4
@nx/eslint         : 18.2.4
@nx/workspace      : 18.2.4
@nx/angular        : 18.2.4
@nx/cypress        : 18.2.4
@nx/devkit         : 18.2.4
@nx/eslint-plugin  : 18.2.4
@nx/plugin         : 18.2.4
@nx/storybook      : 18.2.4
@nrwl/tao          : 18.2.4
@nx/web            : 18.2.4
@nx/webpack        : 18.2.4
typescript         : 5.4.5
---------------------------------------
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/schematics      : 17.0.1
@ngrx/signals         : 17.2.0
@ngrx/store           : 17.0.1
@ngrx/store-devtools  : 17.0.1
@storybook/angular    : 7.6.17
ngx-build-plus        : 14.0.0

Failure Logs

No response

Package Manager Version

No response

Operating System

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

Additional Information

No response

@mkhodan
Copy link
Author

mkhodan commented Sep 17, 2024

The issue seems to be in this file: https://github.com/nrwl/nx/blob/57a201a56202b7cf97ca7d55a5e0a0a3f138b8cc/packages/eslint-plugin/src/utils/runtime-lint-utils.ts#L528C1-L528C7

where it checks if ng-package.json exists it calls joinPathFragments(parent, entryFile) even though entryFile is undefined

@jaysoo jaysoo added the scope: linter Issues related to Eslint support in Nx label Sep 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: linter Issues related to Eslint support in Nx type: bug
Projects
None yet
Development

No branches or pull requests

3 participants