Skip to content

Yarn v2 (pnp) compatibility with custom parser #64

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

Closed
AlexandreBonaventure opened this issue Feb 11, 2020 · 4 comments
Closed

Yarn v2 (pnp) compatibility with custom parser #64

AlexandreBonaventure opened this issue Feb 11, 2020 · 4 comments

Comments

@AlexandreBonaventure
Copy link

Hello,
when using vue-eslint-parser + custom parser (with typescript here) in the context of yarn v2 we get the following error:

Parsing error: A package is trying to access another package without the second one being listed as a dependency of the first one

Required package: @typescript-eslint/parser (via "@typescript-eslint/parser")
Required by: vue-eslint-parser

This comes from:
https://github.com/mysticatea/vue-eslint-parser/blob/ea156df3872da715d580ea1c9c67a2c6e340b9ee/src/script/index.ts#L570

Yarn v2 is now enforcing require to be strict (no extraneous deps). In this case, I think the solution could be to make the parserOptions.parser to be the parser itself instead of a string. This way we can actually outsource the require call in the userland (here eslint-config-typescript: https://github.com/vuejs/eslint-config-typescript/blob/master/index.js#L8). It is up to the consuming library then to define its own dependencies.
This is an open discussion, I'm no expert here, but I'll be willing to PR if we agree on a solution.

ref: vuejs/vue-cli#5135

@armano2

This comment has been minimized.

@AlexandreBonaventure
Copy link
Author

yes, I get that, what I mean is: there is probably a solution of passing this custom parser in such way that it is compatible with yarn by supporting to directly forward the parser and not just a string

@mysticatea
Copy link
Member

That parserOptions.parser field is compatible with the top-level parser field, so it's a string. I guess that you can use require.resolve("@typescript-eslint/parser") to give an absolute path for the parser.

@AlexandreBonaventure
Copy link
Author

ok thanks, this works fine 👍 I've updated this PR vuejs/eslint-config-typescript#8

Closing that one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants