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

Running nx lint results in eslint error due too wrong cli flag format #22498

Closed
1 of 4 tasks
pvds opened this issue Mar 25, 2024 · 2 comments
Closed
1 of 4 tasks

Running nx lint results in eslint error due too wrong cli flag format #22498

pvds opened this issue Mar 25, 2024 · 2 comments
Assignees
Labels

Comments

@pvds
Copy link
Contributor

pvds commented Mar 25, 2024

Current Behavior

After upgrading from nx@18.0.4 to nx@18.1.2, when running nx lint on any project I get this error:
Warning: command "eslint . --fix false" exited with non-zero status code

I have located the possible cause, introduced in this PR: feat(core): forward options for run command #22064 which was first released officially in nx@18.1.1.

I think the issue is that:

  • since the above PR unknownOptions are passed with a space between key and value
  • eslint interprets the false cli value as a glob to run the linter on instead of the value for the --fix flag

I verified this by changing the unknownOptions mapping
From using a space

.map((k) => `--${k} ${opts.unknownOptions[k]}`)

To using an equal sign

.map((k) => `--${k}=${opts.unknownOptions[k]}`)

Also commenting out the assignment of unknownOptions to args resolves the issue.

Workaround

In my repo i'm using lint instead of @nx/eslint:lint as targetDefaults and i'm setting "options": { "fix": false },.
When I use @nx/eslint:lint it works, when I use lint it doesn't work

"@nx/eslint:lint": {
  "inputs": ["default", "{workspaceRoot}/.eslintrc.json"],
  "options": { "fix": false },
  "cache": true
}

Expected Behavior

Forward options for run command using unknownOptions does not break eslint (and potentially other cli's)

GitHub Repo

https://github.com/nrwl/nx-example

Steps to Reproduce

  1. In nx.json change the targetDefaults for @nx/eslint:lint to lint
  2. add "options": { "fix": false }, to the targetDefaults for lint
  3. run nx lint cart (or any other project)

For some reason using the @nx/eslint:lint executor as targetDefault with the custom option does not generate an error, but using lint as targetDefault does.

Nx Report

Node   : 20.9.0
OS     : darwin-arm64
pnpm   : 8.10.5

nx                 : 18.1.2
@nx/js             : 18.1.2
@nx/jest           : 18.1.2
@nx/linter         : 18.1.2
@nx/eslint         : 18.1.2
@nx/workspace      : 18.1.2
@nx/angular        : 18.1.2
@nx/cypress        : 18.1.2
@nx/devkit         : 18.1.2
@nx/eslint-plugin  : 18.1.2
@nx/node           : 18.1.2
@nx/plugin         : 18.1.2
@nx/storybook      : 18.1.2
@nrwl/tao          : 18.1.2
@nx/web            : 18.1.2
@nx/webpack        : 18.1.2
typescript         : 5.3.3
---------------------------------------
Community plugins:
@compodoc/compodoc   : 1.1.23
@ngrx/effects        : 17.1.0
@ngrx/router-store   : 17.1.0
@ngrx/store          : 17.1.0
@ngrx/store-devtools : 17.1.0
@storybook/angular   : 7.6.14
@twittwer/compodoc   : 1.12.0
ng-mocks             : 14.12.1
nx-stylelint         : 17.1.3

Failure Logs

ESLint: 8.56.0

No files matching the pattern "false" were found.
Please check for typing mistakes in the pattern.

Warning: command "eslint . --fix false" exited with non-zero status code

Package Manager Version

No response

Operating System

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

Additional Information

No response

@pvds pvds added the type: bug label Mar 25, 2024
@FrozenPandaz FrozenPandaz added the scope: core core nx functionality label Mar 27, 2024
@xiongemi
Copy link
Collaborator

should be fixed by #22756

Copy link

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 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants