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 convert-to-inferred stopped working in 19.3 #26775

Closed
4 tasks
robertIsaac opened this issue Jul 1, 2024 · 13 comments · Fixed by #27035
Closed
4 tasks

eslint convert-to-inferred stopped working in 19.3 #26775

robertIsaac opened this issue Jul 1, 2024 · 13 comments · Fixed by #27035
Assignees
Labels
outdated scope: linter Issues related to Eslint support in Nx type: bug

Comments

@robertIsaac
Copy link
Contributor

Current Behavior

when I try to run nx g convert-to-inferred it throw an error

Expected Behavior

running it to work

GitHub Repo

No response

Steps to Reproduce

  1. create a project using 19.1
  2. update to 19.3 using nx migrate latest
  3. run nx g convert-to-inferred and choose eslint

Nx Report

Node   : 20.12.2
OS     : win32-x64
npm    : 10.5.0

nx (global)        : 19.1.1
nx                 : 19.3.2
@nx/js             : 19.3.2
@nx/jest           : 19.3.2
@nx/linter         : 19.3.2
@nx/eslint         : 19.3.2
@nx/workspace      : 19.3.2
@nx/angular        : 19.3.2
@nx/cypress        : 19.3.2
@nx/devkit         : 19.3.2
@nx/eslint-plugin  : 19.3.2
@nrwl/tao          : 19.3.2
@nx/web            : 19.3.2
@nx/webpack        : 19.3.2
typescript         : 5.4.5

Failure Logs

nx g convert-to-inferred
 NX  Falling back to ts-node for local typescript execution. This may be a little slower.
  - To fix this, ensure @swc-node/register and @swc/core have been installed
√ Which generator would you like to use? · @nx/eslint:convert-to-inferred

 NX  Generating @nx/eslint:convert-to-inferred


 NX   The nx plugin did not find a project inside libs/auth. File an issue at https://github.com/nrwl/nx with information about your project structure.

Package Manager Version

No response

Operating System

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

Additional Information

it was working in 19.1, reverting this commit does make it work, nothing was updated in the upgrade other than .nx/workspace-data being ignored in git and prettier

@AgentEnder AgentEnder added the scope: linter Issues related to Eslint support in Nx label Jul 8, 2024
@leosvelperez
Copy link
Member

This issue was fixed by #26638. Please update to Nx 19.4.4 or 19.5.0 or later. After migrating you might need to run nx reset to prevent pulling from a stale tasks cache.

@robertIsaac
Copy link
Contributor Author

hi @leosvelperez
the issue still exists

@robertIsaac
Copy link
Contributor Author

Node : 20.12.2
OS : win32-x64
npm : 10.5.0

nx (global) : 19.5.1
nx : 19.5.1
@nx/js : 19.5.1
@nx/jest : 19.5.1
@nx/linter : 19.5.1
@nx/eslint : 19.5.1
@nx/workspace : 19.5.1
@nx/angular : 19.5.1
@nx/cypress : 19.5.1
@nx/devkit : 19.5.1
@nx/eslint-plugin : 19.5.1
@nrwl/tao : 19.5.1
@nx/web : 19.5.1
@nx/webpack : 19.5.1
typescript : 5.5.3

Registered Plugins:
@nx/eslint/plugin

@robertIsaac
Copy link
Contributor Author

even in a newly created angular application using nx it doesn't work
here is how I created it

npx create-nx-workspace@latest test-reprod
Need to install the following packages:
[email protected]
Ok to proceed? (y) y


 NX   Let's create a new workspace [https://nx.dev/getting-started/intro]

√ Which stack do you want to use? · angular
√ Integrated monorepo, or standalone project? · standalone
√ Which bundler would you like to use? · esbuild
√ Default stylesheet format · css
√ Do you want to enable Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering)? · No
√ Test runner to use for end to end (E2E) tests · none
√ Which CI provider would you like to use? · skip
√ Would you like remote caching to make your build faster? · skip

 NX   Creating your v19.5.1 workspace.

✔ Installing dependencies with npm
✔ Successfully created the workspace: test-reprod.

here is how it stop working

F:\test-reprod git:[master]
nx lint

> nx run test-reprod:lint

Linting "test-reprod"...
✔ All files pass linting

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

 NX   Successfully ran target lint for project test-reprod (955ms)

F:\test-reprod git:[master]
nx g convert-to-inferred
√ Which generator would you like to use? · @nx/eslint:convert-to-inferred

 NX  Generating @nx/eslint:convert-to-inferred

UPDATE project.json
UPDATE nx.json
F:\test-reprod git:[master]
nx lint

 NX   Cannot find configuration for task test-reprod:lint

please reopen the issue @leosvelperez

@robertIsaac
Copy link
Contributor Author

@leosvelperez leosvelperez reopened this Jul 22, 2024
@leosvelperez
Copy link
Member

@robertIsaac thanks for the detailed reproduction steps. The issue only occurs for standalone workspaces, which the original reproduction steps didn't mention. I've identified the issue now and I'll push a fix for it.

@robertIsaac
Copy link
Contributor Author

Thanks for the update
I wasn't sure what was the root cause

@leosvelperez
Copy link
Member

leosvelperez commented Jul 22, 2024

No worries! Sometimes it's hard to know which little detail might cause an issue. This is why detailed reproduction steps are so important to help us reproduce the issues. TBF, you always provide good information, so keep it up!

There was an issue for Windows and ESLint matching your original description that was addressed in the PR I linked before. That's why I thought it was already addressed.

FrozenPandaz pushed a commit that referenced this issue Jul 22, 2024
…efault option values (#27035)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

Converting a root project to inferred results in the plugin registration
to have the `includes` option set to `./**/*`. This is invalid and
causes no project to be inferred.

Additionally, the eslint `convert-to-inferred` generator:

- keeps a redundant `config` option, which is not needed because
inferred tasks only work with default/known ESLint config files, so
there's no need to specify it in the options
- converts all `lintFilePatterns` to `args`, which is correct, but it
keeps the patterns that are already inferred by the plugin, which leads
to duplicated patterns when running the task

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

Converting a root project to inferred should work as expected and result
in the `lint` task being inferred for the project.
Also, default inferred options should be removed from the target
options.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #26775

(cherry picked from commit 5217c33)
@robertIsaac
Copy link
Contributor Author

robertIsaac commented Jul 25, 2024

Hi @leosvelperez
The fix works, thank you so much
I have the issue with inferred for jest
Do I need to file another issue for it?

@leosvelperez
Copy link
Member

leosvelperez commented Jul 25, 2024

@robertIsaac are the reproduction steps similar to the one you provided in #26775 (comment)? Either way, yes, go ahead and create a new issue. You can ping me and I'll take a look.

@leosvelperez
Copy link
Member

I can't reproduce any issue with the @nx/jest:convert-to-inferred using the same reproduction steps.

FWIW, the fix for ESLint should have addressed it for other plugins as well. The root cause of the issue was in a shared utility we use in all the convert-to-inferred generators. So, if there's an issue with the Jest one should be something else.

@robertIsaac
Copy link
Contributor Author

when I'm trying to make a reprod, it actually does work
I'm not sure why it's not working in my project
what I noticed is that the failed suits are more than what should be tested, so I guess it's trying to test all of the files in the project not the files related only to each project

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 Aug 27, 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

Successfully merging a pull request may close this issue.

3 participants