简体   繁体   中英

How to install eslint-airbnb?

when i run ( export PKG=eslint-config-airbnb; npm info "$PKG@latest" peerDependencies --json | command sed 's/[\\{\\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest" ) successfully. eslint --init and run the script in package.json .

Info : my Node node v7.5.0 npm 4.1.2

there is problem below.

npm ERR! Darwin 15.6.0
npm ERR! argv "/Users/next/.nvm/versions/node/v7.5.0/bin/node"
/Users/next/.nvm/versions/node/v7.5.0/bin/npm" "run" "lint"
npm ERR! node v7.5.0
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! beslint@1.0.0 lint: `eslint app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the beslint@1.0.0 lint script 'eslint app.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the beslint package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     eslint app.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs beslint
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls beslint
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/next/es6/jsmodules/beslint/npm-debug.log

Are you sure that running eslint --init worked ?

This is like you have no .eslintrc file (the configuration file for ESLint parser options and rules). Check/create the .eslintrc file at the root directory of your project that you called " beslint ".

Then you'll need to add this in the .eslintrc file in order that ESLint take into account that you want to extend the rules from the Airbnb team:

{ "extends": "airbnb" }

Note that you can install different rules from the Airbnb team:

  • " airbnb ": Airbnb ESLint rules, including ECMAScript 6+ and React
  • " airbnb-base ": Airbnb ESLint rules, including ECMAScript 6+
  • " airbnb-base/legacy ": Airbnb ESLint rules, including ECMAScript 5 and below

The extends value in your .eslintrc file should match your installation and be one of these three previous values.

I made a little command line tool that can install ESLint with one of these three different Airbnb configs. It automatically creates and configure the .eslintrc file if it has not already been done. It helps me a lot on my personal projects and at work! It's called esbnb . Hope it could help you.

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