Skip to content

Ready for review: yarn v2 compat [open discussion] #8

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

Merged
merged 2 commits into from
Feb 26, 2020

Conversation

AlexandreBonaventure
Copy link
Contributor

Here, the idea is to have a shim of the @typescript-eslint/eslint-plugin so we can keep require statement inside @vue/eslint-config-typescript while keeping it as a peer dependencies.

@AlexandreBonaventure
Copy link
Contributor Author

This needs typescript-eslint/typescript-eslint#1593 in order to work

@AlexandreBonaventure
Copy link
Contributor Author

In order to keep the ball moving forward on vuejs/vue-cli#5135
I opened several PRs. Please consider this as a work-in-progress and an open discussion. I'd like to avoid this dirty shimming monkey patch but this is working at least...

Feel free to provide some feedback and contribute

@AlexandreBonaventure
Copy link
Contributor Author

At the end of the day, it is more a problem to has to do with how eslint loads plugins and the fact that it has not been designed to fit yarn v2 requirements. According to yarnpkg/berry#8 it seems like eslint has shipped some changes to have better support, but I'm not sure yet how it is affecting this issue.

@AlexandreBonaventure
Copy link
Contributor Author

edit: it actually works like that without the shimming monkey patch

@@ -43,5 +43,8 @@
"@typescript-eslint/parser": "^2.7.0",
"eslint": "^5.0.0 || ^6.0.0",
"eslint-plugin-vue": "^5.2.3 || ^6.0.0"
},
"dependencies": {
"vue-eslint-parser": "^7.0.0"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we add vue-eslint-parser as a dependency rather than a peerDependency, otherwise yarn will throw this kind of error

Error: A package is trying to access a peer dependency that should be provided by its direct ancestor but isn't
Required package: vue-eslint-parser (via "vue-eslint-parser")
Required by: @vue/eslint-config-typescript

And it is arguably right to say it has a direct dependency to it anyways

@AlexandreBonaventure AlexandreBonaventure changed the title WIP: yarn v2 compat [open discussion] Ready for review: yarn v2 compat [open discussion] Feb 13, 2020
@AlexandreBonaventure
Copy link
Contributor Author

As demonstrated here: https://github.com/AlexandreBonaventure/workspace-yarn2-example
this patch works, the only breaking change would be that vue-eslint-parser is now added as a direct dependency.

@haoqunjiang
Copy link
Member

Makes sense.
It's not a breaking change though. In other configs, vue-eslint-parser is required in the eslint-plugin-vue source code, which has directly depended on it, so previously it's not listed in this package. But now that we want to override the config, we cannot rely on the implict hoisting.

@haoqunjiang
Copy link
Member

Actually, for vue-eslint-parser, just adding the dependency should suffice. Because ESLint knows where the parser is required and calls a require function relative to the package directory https://github.com/eslint/eslint/blob/1aa021d77fdd2c68d7b7d2f4603252110c414b32/lib/cli-engine/config-array-factory.js#L888-L906

require.resolve is fine, too, of course.

@haoqunjiang haoqunjiang merged commit e7e184c into vuejs:master Feb 26, 2020
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

Successfully merging this pull request may close these issues.

2 participants