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

Add option to --init for shareable configs #7488

Closed
jsejcksn opened this issue Oct 30, 2016 · 10 comments
Closed

Add option to --init for shareable configs #7488

jsejcksn opened this issue Oct 30, 2016 · 10 comments
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion needs bikeshedding Minor details about this change need to be discussed

Comments

@jsejcksn
Copy link

jsejcksn commented Oct 30, 2016

What version are you using? 3.9.0

What did you do? Try to add an already installed shareable config after installing (during --init)

What happened? I couldn't

What did you expect to happen? To be able to

Here's more detail:

I mainly use ESLint with the linter-eslint Atom plugin, and I created a shareable config so I wouldn't have to manually sort that part out for each new project. So now I just run $ npm install eslint @jsejcksn/eslint-config --save-dev in the beginning, but I still need a .eslintrc.* file, which I have to create manually. Right? Am I missing something?

It seems natural that after running ./node_modules/.bin/eslint --init, one of the main menu options should be to specify an already installed shareable config (and not just "the most popular ones")—in my case, I would enter @jsejcksn. (I couldn't find this in the docs, but I did find this comment in an issue.

And that would produce the .eslintrc.* file with the following:

{ "extends": "@jsejcksn" }

I am still pretty new to ESLint, so maybe I am missing an easier option that doesn't require copying from another project or manually creating my .eslintrc.json file myself in order to have ESLint use my shareable config.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Oct 30, 2016
@nzakas nzakas added enhancement This change enhances an existing feature of ESLint core Relates to ESLint's core APIs and features evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Oct 30, 2016
@nzakas
Copy link
Member

nzakas commented Oct 30, 2016

That's an interesting idea. We really only intended --init to be used by people without prior ESLint experience with the thinking that more experienced users would probably just copy-paste their config over. That said, I'm not opposed to this.

How would you envision it working?

(FWIW, I'm not sure we can really show a list of installed shareable configs because there's no guaranteed location where shareable configs are installed nor do we have any transparency into whether or not the shareable config package contains multiple configs.)

@jsejcksn
Copy link
Author

jsejcksn commented Nov 3, 2016

@nzakas As I said before, I'm new to ESLint, so I'm not exactly sure how the init process works. Originally I had thought that it would just add a shareable config that was already installed, but maybe it can download the shareable config by the npm address, just like it does for "Use a popular style guide".

The new menu entry would go below the three that are already there, and would read something like Type the name of a shareable config to import it. The user would select it and then be able to type the name of the shareable config on npm. For my case, I would type @jsejcksn/eslint-config and then press enter, and it would install the package and then create a .eslintrc.json file with { "extends": "@jsejcksn" } as the content.

@nzakas
Copy link
Member

nzakas commented Nov 3, 2016

Gotcha. That's an interesting idea, though I'm a bit concerned that some configs require dependencies to be manually installed to work properly. We currently special case the style guides we support in --init so we take care of installing the extra dependencies, but we wouldn't be able to do that dynamically.

Let's see what others think.

@jsejcksn
Copy link
Author

jsejcksn commented Nov 4, 2016

@nzakas I didn't realize that it was a special-case implementation for the popular ones—I thought it was just automated (but with hardcoded package names). Now that I've gone back and experimented a bit, it seems that, when using --init with "a popular style guide", ESLint is taking the liberty of adding itself and the config's dependencies as developer dependencies in my package.json file. That leads me to believe that it's installing them via $ npm install shareable-config --save-dev. Is there documentation on how this works?

@nzakas
Copy link
Member

nzakas commented Nov 4, 2016

There's no documentation on how it works, but here's the code:
https://github.com/eslint/eslint/blob/master/lib/config/config-initializer.js#L262

@vitorbal
Copy link
Member

vitorbal commented Nov 6, 2016

I think this issue could be a good enhancement after something like this is implemented: #7338 (comment)
I actually have a branch where I almost got it to work. Only need to get to adding some more tests and fixing existing ones.

@kaicataldo
Copy link
Member

kaicataldo commented Jan 10, 2017

This is a really interesting idea - seems worth exploring further (maybe after #7338 (comment) has been finalized).

@kaicataldo kaicataldo added the needs bikeshedding Minor details about this change need to be discussed label Jan 10, 2017
@dinoboff
Copy link

dinoboff commented Feb 2, 2017

eslint could add flags to skip some prompt:

  • eslint --init: all prompt.
  • eslint --init --init-config=xo: skip style prompt, install "eslint-config-xo" and use it as based config.
  • eslint --init --init-format=yaml: skip format prompt and create .eslintrc.yaml.

A shortcut would be nice to, e.g. eslint --init-with=yaml:xo, with maybe a way to install plugins too (and configure them), e.g. eslint --init-with=yaml:xo:react,ava,node

@not-an-aardvark
Copy link
Member

Thanks for your interest in improving ESLint. Unfortunately, it looks like this issue didn't get consensus from the team, so I'm closing it. We define consensus as having three 👍s from team members, as well as a team member willing to champion the proposal. This is a high bar by design -- we can't realistically accept and maintain every feature request in the long term, so we only accept feature requests which are useful enough that there is consensus among the team that they're worth adding.

@jsejcksn
Copy link
Author

jsejcksn commented Nov 5, 2017

I'm sad about that, but I understand because you explained it well. Thanks, @not-an-aardvark.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators May 3, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label May 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion core Relates to ESLint's core APIs and features enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion needs bikeshedding Minor details about this change need to be discussed
Projects
None yet
Development

No branches or pull requests

7 participants