简体   繁体   中英

Can ESLint - Airbnb be installed on Ubuntu 16.04 Sublime Text 3

I don't why I am having such a difficult time trying to install ESLint, and I am starting to think it is because I am on Ubuntu.

Basically, I wanted to use the the Airbnb JavaScript and/or Airbnb Ruby style guide for my code because it inconsistent, there is unused variables everywhere, and console.log / debugger 's everywhere, so I want to get a hold of that.

So initially I globally installed eslint, and then installed eslint-config-airbnb using

(
  export PKG=eslint-config-airbnb;
  npm info "$PKG@latest" peerDependencies --json | command sed 's/[\{\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest"
)

我认为它奏效了...

I also installed all of these eslint , eslint-plugin-import , eslint-plugin-react , and eslint-plugin-jsx-a11y.

Next, I created - or I think it was generated - the .eslintrc file with only

{
    "extends": "airbnb"
}

I didn't really know what to do afterwards. Like, how do I know if I have the styles installed. I thought the next step would be to some how RUN the .eslintrc file so it knows what I want, thus, I did eslint app and I also created a script in package.json "lint": "eslint app" but then it was giving me this issue, that:

Error: Cannot find module 'eslint-config-airbnb'

And I was told that I shouldn't install it GLOBALLY. Next , I removed it globally, and installed it in app directory in the dev tools, and it was giving me this issue:

bash: /home/dilraj/.nvm/versions/node/v6.2.1/bin/eslint: No such file or directory

I am starting to think that maybe it's a Ubuntu thing, because every time I google these problems they are from 2013-2015 and it is unclear to me why it is as such :(

Hold Up!

So I decided to install npm install -g eslint-config-airbnb GLOBALLY, and it's giving me some further instructions.

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.

You can install eslint-config-airbnb-bundle globally. This is an Airbnb config bundled with ESLint for the sake of convenience and for solving some trouble with the installation. You'll also find instructions for Sublime Text 3:

https://www.npmjs.com/package/eslint-config-airbnb-bundle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM