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

yarn create next-app --ts sets wrong eslint version #29770

Closed
PegasisForever opened this issue Oct 10, 2021 · 9 comments · Fixed by #29837 or #29865
Closed

yarn create next-app --ts sets wrong eslint version #29770

PegasisForever opened this issue Oct 10, 2021 · 9 comments · Fixed by #29837 or #29865
Labels
bug Issue was opened via the bug report template. examples Issue/PR related to examples

Comments

@PegasisForever
Copy link

What example does this report relate to?

yarn create next-app --typescript

What version of Next.js are you using?

11.1.2

What version of Node.js are you using?

16.10.0

What browser are you using?

chrome 94

What operating system are you using?

Arch Linux

How are you deploying your application?

N/A

Describe the Bug

When creating a next.js project using yarn create next-app --typescript, eslint version of the project is set to 8.0.0 in package.json, however eslint-config-next depends on eslint ^7.23.0.

When running yarn lint, it errors:

yarn run v1.22.15
$ next lint
info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
error - ESLint must be installed: yarn add --dev eslint
Done in 0.86s.

When creating a next.js using npx create-next-app@latest --ts, the eslint version is set correctly.

I didn't test the non-ts version.

Expected Behavior

eslint version of the project should be ^7.23.0

To Reproduce

yarn create next-app --typescript
cd project_name
yarn lint
@PegasisForever PegasisForever added bug Issue was opened via the bug report template. examples Issue/PR related to examples labels Oct 10, 2021
@DarkSuniuM
Copy link

DarkSuniuM commented Oct 10, 2021

Same just happened to me, ESLint version is 8.0.0 and I'm getting Error: Failed to patch ESLint because the calling module was not recognized.

As the author of this issue said, Downgrading ESLint to ^7.23.0 fixed my problem

@stefanprobst
Copy link
Contributor

could be fixed by pinning the installed eslint version here i think

- const devDependencies = ['eslint', 'eslint-config-next']
+ const devDependencies = ['eslint@7', 'eslint-config-next']

@johngrant
Copy link

Same here. I created a new nextjs app using the boiler plate. Ran yarn lint. My package.json was initialized with version 8. When running subsequent lint or build commands I get the error error - ESLint must be installed: yarn add --dev eslint. Reverting to eslint version 7 removed the error during linting and building.

@karbica
Copy link

karbica commented Oct 11, 2021

I am also encountering this issue. Downgrading the eslint version to 7.x.x from 8.0.0 fixed the issue.

@finn-orsini
Copy link
Contributor

finn-orsini commented Oct 12, 2021

Adding some additional context here:

The cause of the ESLint must be installed failure is that eslint/lib/api.js is no longer an export of eslint v8. See v8 exports and the v8 migration guide. This causes the has-necessary-dependencies resolution to throw (Package subpath './lib/api.js' is not defined by "exports") and mark the dep as missing.

Updating the file value here to

- {file: 'eslint/lib/api.js',pkg: 'eslint'}, 
+ {file: 'eslint',pkg: 'eslint'}, 

would resolve this particular error.

However, the next eslint config has a rushstack dependency, so even when allowing for v8 above, you get the error mentioned in a few comments here:

Error: Cannot read config file: <repo_root>/node_modules/eslint-config-next/index.js
Error: Failed to patch ESLint because the calling module was not recognized.
If you are using a newer ESLint version that may be unsupported, please create a GitHub issue:
https://github.com/microsoft/rushstack/issues

See another report of this here: #29829.

Rushstack does not yet support eslint v8, but they have an issue here to do so: microsoft/rushstack#2890.

I'm happy to submit a PR to pin to ^7 as mentioned above in the meantime 👍

@housseindjirdeh
Copy link
Collaborator

housseindjirdeh commented Oct 12, 2021

Thanks for logging this folks, and apologies for any inconvenience this may be causing. @stefanprobst and @finn-orsini are both correct, and thank you @finn-orsini for submitting a PR to fix this so quickly!

Once #29837 is merged, the latest canary version will stick to installing v7 of ESLint and there's an open PR to add support for v8 (#29865). Once all sub-dependencies used in Next.js' ESLint config and plugin is supported, including rushstack, it'll be merged!

@kodiakhq kodiakhq bot closed this as completed in #29837 Oct 12, 2021
kodiakhq bot pushed a commit that referenced this issue Oct 12, 2021
Fixes #29770

## Description

Pins `eslint` to `v7`. This avoids issues with `v8` from both [changes to the public api](https://eslint.org/docs/8.0.0/user-guide/migrating-to-8.0.0#the-lib-entrypoint-has-been-removed) and [lack of support from rushstack](microsoft/rushstack#2890). See #29770 (comment) for slightly more detail. 

Local testing showed output of next app correctly pinned to `v7`. 

<img width="495" alt="Screen Shot 2021-10-12 at 12 31 56 AM" src="https://user-images.githubusercontent.com/29002354/136892312-1571718c-882b-4235-98f4-c1b8d4c72d26.png">


### Bug Checklist

- [X] Related issues linked using `fixes #number`
- [ ] Integration tests added
   - Happy to add an integration test for pinning to v7 if we'd like, will need to be updated / removed when v8 is supported. 
- [ ] Errors have helpful link attached, see `contributing.md`
	- No errors to add links for
@ykzts ykzts mentioned this issue Oct 13, 2021
8 tasks
@tdkn
Copy link
Contributor

tdkn commented Oct 13, 2021

I think if the next lint exits with an error, the exit code should be 1, not 0.
Otherwise, CI such as GitHub Action will pass the test.

❯ yarn lint
info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
error - ESLint must be installed: yarn add --dev eslint

❯ echo $?
0

CI PASSED ESLint Step 😱
image

@stephanelpaul
Copy link

stephanelpaul commented Oct 15, 2021

sorry nevermind saw the first post used the same version and it works fine now.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
natew pushed a commit to natew/next.js that referenced this issue Feb 16, 2022
Fixes vercel#29770

## Description

Pins `eslint` to `v7`. This avoids issues with `v8` from both [changes to the public api](https://eslint.org/docs/8.0.0/user-guide/migrating-to-8.0.0#the-lib-entrypoint-has-been-removed) and [lack of support from rushstack](microsoft/rushstack#2890). See vercel#29770 (comment) for slightly more detail. 

Local testing showed output of next app correctly pinned to `v7`. 

<img width="495" alt="Screen Shot 2021-10-12 at 12 31 56 AM" src="https://user-images.githubusercontent.com/29002354/136892312-1571718c-882b-4235-98f4-c1b8d4c72d26.png">


### Bug Checklist

- [X] Related issues linked using `fixes #number`
- [ ] Integration tests added
   - Happy to add an integration test for pinning to v7 if we'd like, will need to be updated / removed when v8 is supported. 
- [ ] Errors have helpful link attached, see `contributing.md`
	- No errors to add links for
LuighiV pushed a commit to openpolitica/create-openpolitica-nextjs-app that referenced this issue Aug 24, 2022
Fixes vercel/next.js#29770

## Description

Pins `eslint` to `v7`. This avoids issues with `v8` from both [changes to the public api](https://eslint.org/docs/8.0.0/user-guide/migrating-to-8.0.0#the-lib-entrypoint-has-been-removed) and [lack of support from rushstack](microsoft/rushstack#2890). See vercel/next.js#29770 (comment) for slightly more detail. 

Local testing showed output of next app correctly pinned to `v7`. 

<img width="495" alt="Screen Shot 2021-10-12 at 12 31 56 AM" src="https://user-images.githubusercontent.com/29002354/136892312-1571718c-882b-4235-98f4-c1b8d4c72d26.png">


### Bug Checklist

- [X] Related issues linked using `fixes #number`
- [ ] Integration tests added
   - Happy to add an integration test for pinning to v7 if we'd like, will need to be updated / removed when v8 is supported. 
- [ ] Errors have helpful link attached, see `contributing.md`
	- No errors to add links for
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. examples Issue/PR related to examples
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants