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

[Feature] Rename .yarnrc into .yarnrc.yml #239

Closed
arcanis opened this issue Jun 19, 2019 · 8 comments
Closed

[Feature] Rename .yarnrc into .yarnrc.yml #239

arcanis opened this issue Jun 19, 2019 · 8 comments
Labels
enhancement New feature or request

Comments

@arcanis
Copy link
Member

arcanis commented Jun 19, 2019

Describe the user story

I'm a user, I want to migrate to Yarn 2. It's currently a real pain to deal with v1 rc files versus v2 rc files, both because of the syntax and the different configuration keys.

Describe the solution you'd like

I initially kept the .yarnrc name because why not, but thinking about it we might have a better time using a different name. I think using .yarnrc.yml would be a good idea because:

  • We could stop reading .yarnrc altogether (and thus wouldn't have to deal with old-style syntax, old-style settings, ...)
  • People using both the v1 and the v2 wouldn't have to use the berry: hack to have configuration for the two tools
  • We can get rid of the # yarn lockfile v1 detection, which doesn't work well for manually-created rc files (I used to remove them a lot).
  • Changing the rc names in such a way isn't unheard of - for example .babelrc as a Javascript counterpart with .babelrc.js, and it's the same thing for ESLint
  • Since we're switching to the Yaml format, adding the type hint in the extension makes it really clear what is expected (otherwise I'm concerned users will just keep writing old-style).
  • It opens the way to later support .yarnrc.js, if we decide to do this.

Describe the drawbacks of your solution

It might be surprising at first why the settings aren't applied. I'm not sure we can do much to avoid this (we potentially could read the .yarnrc and throw if it contains v2 keys, but that sounds fishy).

Describe alternatives you've considered

  • We could use a different file name - for example .berryrc.
  • And of course, we could keep the existing system.
@arcanis arcanis added the enhancement New feature or request label Jun 19, 2019
@milesj
Copy link

milesj commented Jun 19, 2019

Just want to note that it should probably be .yaml and not .yml. https://yaml.org/faq.html

@arcanis
Copy link
Member Author

arcanis commented Jun 20, 2019

Since most other yaml files I've seen in use in the JS community use .yml (.gitlab-ci.yml, azure-pipelines.yml, appveyor.md) I'd tend to ignore the official recommendation in this case 🤔

Related: pnpm/pnpm#1380

@arcanis
Copy link
Member Author

arcanis commented Jun 20, 2019

There will be one significant issue: yarn-path. If we end up with two different files, then it becomes a fair bit more difficult to interact with the yarn-path settings; should we read it from .yarnrc? Or from .yarnrc.yml? Or both? Where to set the flag when calling yarn set version? How well would it integrate with Yarn v1, which is likely to be the global binary for some time?

@arcanis
Copy link
Member Author

arcanis commented Jun 21, 2019

Done in #244

@arcanis arcanis closed this as completed Jun 21, 2019
@accidentaldeveloper
Copy link
Contributor

When converting a project to v2 I run yarn policies set-version berry. This creates a .yarnrc file with the line yarn-path ".yarn\\releases\\yarn-berry.js" and downoloads the yarn-berry.js file.

If I then run yarn set version berry a .yarnrc.yml file is created with the line yarnPath: .yarn/releases/yarn-rc.js and changes the file name to yarn-rc.js.

The old .yarnrc file is still pointing to the old location: yarn-berry.js. Should I delete the .yarnrc file? I did Google for an answer to this but didn't find anything.

@arcanis
Copy link
Member Author

arcanis commented Nov 14, 2019

  • The 1.17.2+ uses both .yarnrc.yml and .yarnrc to figure out which version of Yarn to use
  • In this case, the .yarnrc.yml file is preferred over the .yarnrc file
  • The v2 uses exclusively the .yarnrc.yml file

So you shouldn't need the .yarnrc file if you have an up-to-date Yarn installed globally (1.17.2+). I just haven't got around implementing the change in the set-policies command in the v1 trunk to generate a .yarnrc.yml instead of .yarnrc.

@zypA13510
Copy link
Contributor

zypA13510 commented May 4, 2020

@arcanis

Since most other yaml files I've seen in use in the JS community use .yml (.gitlab-ci.yml, azure-pipelines.yml, appveyor.md)

I think this is a false assumption, e.g. ESLint supports both but gives .eslintrc.yaml priority, load-grunt-config uses *.yaml only, and in the case of GitLab, it is "accepting merge request" for the change and you can name it .gitlab-ci.yaml and then set "Custom CI configuration path". Also, in the issue you linked to they decided to stick with .yaml.

Related: pnpm/pnpm#1380

So instead of using .yarnrc.yml only, why not handle it like ESLint, i.e. supports both but uses the one with higher priority only, in case both exist?

@layla-lili
Copy link

Just want to note that it should probably be .yaml and not .yml. https://yaml.org/faq.html

Works for me, thanks

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

No branches or pull requests

5 participants