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

eslint --init with airbnb config doesn't install all necessary peerDependencies #6843

Closed
vitorbal opened this issue Aug 4, 2016 · 6 comments
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features

Comments

@vitorbal
Copy link
Member

vitorbal commented Aug 4, 2016

What version of ESLint are you using?
3.2.2

What parser (default, Babel-ESLint, etc.) are you using?
default

Please show your full configuration:
Was automatically generated by eslint --init command (See raw output in the end):

module.exports = {
    "extends": "airbnb",
    "plugins": [
        "react"
    ]
};

What did you do? Please include the actual source code causing the issue.
I called eslint --init from the command line. See raw output in the end

What did you expect to happen?
I expected eslint --init to install everything needed for the AirBnB style guide after I selected that I wanted to follow that style guide.

What actually happened? Please include the actual, raw output from ESLint.
Two dependencies were missing for eslint-config-airbnb to run properly, eslint-plugin-import and eslint-plugin-jsx-a11y.
Full output starting from a fresh eslint --init call:

~/Workspace/test_eslint_init$ node_modules/.bin/eslint --init
? How would you like to configure ESLint? Use a popular style guide
? Which style guide do you want to follow? AirBnB
? What format do you want your config file to be in? JavaScript
Installing eslint-plugin-react, eslint-config-airbnb
test_eslint_init@1.0.0 /Users/vitorbalocco/Workspace/test_eslint_init
├─┬ eslint-config-airbnb@10.0.0
│ ├── eslint-config-airbnb-base@5.0.1
│ └── UNMET PEER DEPENDENCY eslint-plugin-import@^1.12.0
├── UNMET PEER DEPENDENCY eslint-plugin-import@^1.12.0
├── UNMET PEER DEPENDENCY eslint-plugin-jsx-a11y@^2.0.1
└─┬ eslint-plugin-react@6.0.0
  └── jsx-ast-utils@1.3.1

npm WARN eslint-config-airbnb@10.0.0 requires a peer of eslint-plugin-jsx-a11y@^2.0.1 but none was installed.
npm WARN eslint-config-airbnb@10.0.0 requires a peer of eslint-plugin-import@^1.12.0 but none was installed.
npm WARN eslint-config-airbnb-base@5.0.1 requires a peer of eslint-plugin-import@^1.12.0 but none was installed.
npm WARN test_eslint_init@1.0.0 No description
npm WARN test_eslint_init@1.0.0 No repository field.
Successfully created .eslintrc.js file in /Users/vitorbalocco/Workspace/test_eslint_init
~/Workspace/test_eslint_init$
~/Workspace/test_eslint_init$ touch test.js
~/Workspace/test_eslint_init$ node_modules/.bin/eslint test.js

Oops! Something went wrong! :(

ESLint couldn't find the plugin "eslint-plugin-jsx-a11y". This can happen for a couple different reasons:

1. If ESLint is installed globally, then make sure eslint-plugin-jsx-a11y is also installed globally. A globally-installed ESLint cannot find a locally-installed plugin.

2. If ESLint is installed locally, then it's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

    npm i eslint-plugin-jsx-a11y@latest --save-dev

If you still can't figure out the problem, please stop by https://gitter.im/eslint/eslint to chat with the team.
@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Aug 4, 2016
@vitorbal vitorbal added bug ESLint is working incorrectly accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Aug 4, 2016
@vitorbal
Copy link
Member Author

vitorbal commented Aug 4, 2016

Ideally we could find a way to keep the peerDependencies in sync with the help of a shell command like the one suggested in the eslint-config-airbnb repository.

But considering the added amount of work, I think for now it would be acceptable to just update the getConfigForStyleGuide function in lib/config/config-initializer.js.

I'm willing to work on this.

@vitorbal vitorbal self-assigned this Aug 4, 2016
@platinumazure
Copy link
Member

Looking ahead a bit, I wonder if we could extract some of that information to a configurable JSON file to make maintenance a bit easier?

I'm not advocating doing that for this issue-- just thinking it might be a worthwhile refactor later on.

@vitorbal
Copy link
Member Author

vitorbal commented Aug 4, 2016

Agreed, the thought crossed my mind as well. How do we usually approach this? A separate "Chore:" commit, perhaps?

vitorbal added a commit to vitorbal/eslint that referenced this issue Aug 4, 2016
@platinumazure
Copy link
Member

@vitorbal Yeah, separate chore issue and commit might be the way to go. (Although that could be an Update, not sure.)

@ilyavolodin ilyavolodin added the core Relates to ESLint's core APIs and features label Aug 4, 2016
@ilyavolodin
Copy link
Member

I don't really think that extracting it to JSON file is going to help any. It's already trivial to add dependencies to the init command, since it just requires adding additional string to an array. (see https://github.com/eslint/eslint/pull/6657/files#diff-da527c6839c0e6e4d343b5c77fcdd27cR281)

@ljharb
Copy link
Sponsor Contributor

ljharb commented Aug 5, 2016

The airbnb config may add or remove peer deps at any time, so using the command referenced here, which looks up whatever's in the config's package.json, is going to be the most robust approach.

vitorbal added a commit to vitorbal/eslint that referenced this issue Aug 5, 2016
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 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 Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features
Projects
None yet
Development

No branches or pull requests

5 participants