-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
New: add yarn support to --init (fixes #13645) #13756
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
I think the proposal is to simply add an "npm or yarn" question instead of trying to figure out that automatically, but let's wait for the issue to be accepted before doing any changes.
Please note that this enhancement isn't accepted yet. Per our process, it still needs a champion from the team.
We approved this change in today's TSC meeting. The issue and this PR are now marked as Accepted. To reduce complexity, |
Can we add another package manager "pnpm"? |
lib/init/config-initializer.js
Outdated
{ | ||
type: "select", | ||
name: "packageManager", | ||
message: "Which package manager does your project use?", | ||
initial: 0, | ||
choices: ["npm", "yarn"] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we skip this step if the previous answer was "No"?
Also, I'm still not sure would it be better to have just one step with "No"/"Yes, with npm"/"Yes, with yarn".
If user doesn't want npm
or yarn
but some third package manager, at this point the only choice for them would be to somehow exit the process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we skip this step if the previous answer was "No"?
Now skipped if No
was selected. but we still have a different question for selecting the package manager.
I tried this version with Yarn 2:
It crashes probably because the github version of ESLint gets removed while installing a new version, but continues to execute. I'm not sure if the same will happen with the real package, and how to test that before publishing. It seems that Also, unlike npm, yarn declares dependencies exactly as they were given to {
"name": "testproject",
"devDependencies": {
"eslint": "^5.16.0 || ^6.8.0 || ^7.2.0",
"eslint-config-airbnb-base": "latest",
"eslint-plugin-import": "^2.22.1"
}
} That looks different than dependencies "devDependencies": {
"eslint": "^7.14.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.22.1"
} (*) - I believe this causes problems with Yarn 1 and
|
Works for me. It may be failed for you because you didn't create an index.js file as per ┌─[snitin315@parrot]─[~/test/eslint-init]
└──╼ $yarn add eslint@https://github.com/snitin315/eslint#feat/yarn-init -D
yarn add v1.22.4
warning ../../package.json: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ [email protected]
info All dependencies
└─ [email protected]
Done in 18.61s.
┌─[snitin315@parrot]─[~/test/eslint-init]
└──╼ $yarn eslint --init
yarn run v1.22.4
warning ../../package.json: No license field
$ /home/snitin315/test/eslint-init/node_modules/.bin/eslint --init
✔ How would you like to use ESLint? · style
✔ What type of modules does your project use? · esm
✔ Which framework does your project use? · none
✔ Does your project use TypeScript? · No / Yes
✔ Where does your code run? · browser
✔ How would you like to define a style for your project? · guide
✔ Which style guide do you want to follow? · standard
✔ What format do you want your config file to be in? · JavaScript
Checking peerDependencies of eslint-config-standard@latest
The config that you've selected requires the following dependencies:
eslint-config-standard@latest eslint@^7.12.1 eslint-plugin-import@^2.22.1 eslint-plugin-node@^11.1.0 eslint-plugin-promise@^4.2.1
✔ Would you like to install them now? · No / Yes
✔ Which package manager does your project use? · yarn
Installing eslint-config-standard@latest, eslint@^7.12.1, eslint-plugin-import@^2.22.1, eslint-plugin-node@^11.1.0, eslint-plugin-promise@^4.2.1
warning ../../package.json: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 2 new dependencies.
info Direct dependencies
├─ [email protected]
└─ [email protected]
info All dependencies
├─ [email protected]
└─ [email protected]
Successfully created .eslintrc.js file in /home/snitin315/test/eslint-init
Done in 31.43s.
┌─[snitin315@parrot]─[~/test/eslint-init]
└──╼ $ |
It could be that this won't be happening often, but installing local packages initiated from an already installed local package still seems problematic, especially when that local package (ESLint) reinstalls itself with Yarn 2, which will then abort the current process right away (I think that's what happened in my test with Yarn 2). It seems better to extract the The other problem is with |
Sounds good to me 👍🏻 |
@snitin315 are you still working on this? |
I'm not sure what else do we need to update here. If anyone is interested feel free to take over the PR. |
I think we assumed that this will be more or less just running |
It seems like there is consensus that it would be better to extract the init functionality into a separate package, so should we close this? |
Closing this in favor of solving it in an extracted package is fine by me. |
Agreed, so closing this PR. |
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[ ] Bug fix (template)
[ ] New rule (template)
[ ] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[x] Other, please explain:
Add support of the installation of dependencies via
yarn
when usingeslint --init
What changes did you make? (Give an overview)
Fixes eslint/create-config#20
Is there anything you'd like reviewers to focus on?