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: Failed to load parser in examples/design-system #1911

Closed
theurgi opened this issue Sep 11, 2022 · 4 comments · Fixed by #5884
Closed

ESLint: Failed to load parser in examples/design-system #1911

theurgi opened this issue Sep 11, 2022 · 4 comments · Fixed by #5884
Assignees
Labels
area: examples Improvements or additions to examples

Comments

@theurgi
Copy link
Contributor

theurgi commented Sep 11, 2022

What version of Turborepo are you using?

latest

What package manager are you using / does the bug impact?

Yarn v1

What operating system are you using?

Mac

Describe the Bug

After cloning examples/design-system and installing dependencies, VSCode's ESLint extension produces the following error:

ESLint: Failed to load parser './parser.js' declared in 
'.eslintrc.js » eslint-config-acme » eslint-config-next': 
Cannot find module 'next/dist/compiled/babel/eslint-parser'

It seems that eslint-config-next depends on next:

// node_modules/eslint-config-next/parser.js

const {
  parse,
  parseForESLint,
} = require('next/dist/compiled/babel/eslint-parser') // ❌ Cannot find module

Despite what examples/with-nextjs says, examples/design-system doesn't contain next.

Expected Behavior

No ESLint errors, all dependencies to resolve.

To Reproduce

npx degit vercel/turborepo/examples/design-system design-system
cd design-system
yarn install
git init . && git add . && git commit -m "Init"
@mehulkar
Copy link
Contributor

mehulkar commented Sep 12, 2022

VSCode's ESLint extension produces the following error:

Could you show how to reproduce this part? I ran the setup steps and opened the project in VSCode and opened a few files and didn't see any issues (in acme-core/src/, etc)

Despite what examples/with-nextjs says, examples/design-system doesn't contain next.

IMO, with-nextjs is out of date and should be deleted, and we should rename basic to with-nextjs. Some of the remaining examples contain Next.js, but not all, so it's a bit out of date. A PR to that effect would probably be a good start @theurgi! cc @vercel/turbo-oss

@theurgi
Copy link
Contributor Author

theurgi commented Sep 12, 2022

vscode: VSCodium v1.71.0
extension: dbaeumer.vscode-eslint v2.2.6

Could you show how to reproduce this part? I ran the setup steps and opened the project in VSCode and opened a few files and didn't see any issues (in acme-core/src/, etc)

After degit and install, I just open one of .eslintrc.js or packages/eslint-config-acme/index.js

image

And then opening node_modules/eslint-config-next/parser.js

image

This makes sense because node_modules/next doesn't exist. I assume this is related to: vercel/next.js#38939 (comment)

It seems that there are a few options:

  1. Refactor eslint-config-acme removing the eslint-config-next dependency and adding the relevant configs that comprise it (i.e. eslint-plugin-react, eslint-plugin-react-hooks, etc.)

  2. Add next as a dependency somewhere in monorepo—this is why other examples/with-nextjs that actually contain next and have an identical package/eslint-config-acme don't encounter this issue.

Option 1 seems most logical. Adding next just to satisfy an eslint config seems backwards. And if I'm not mistaken, even in the examples that do contain next, the only reason they don't encounter this issue is because next is being hoisted to the root node_modules and can therefore be resolved in different in-monorepo packages—this also seems a bit backwards.

Hope that makes sense 🙏

@nathanhammond nathanhammond added area: examples Improvements or additions to examples and removed needs: author input labels Sep 19, 2022
@nathanhammond
Copy link
Contributor

We need to fix our config for examples/design-system here. It contains the wrong dependencies.

While in here we should also move away from acme, which we only use in design-system and with-changesets.

@nathanhammond
Copy link
Contributor

@theurgi Thank you for the extremely detailed reproduction!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: examples Improvements or additions to examples
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants