繁体   English   中英

如何安装eslint-airbnb?

[英]How to install eslint-airbnb?

当我运行时( export PKG=eslint-config-airbnb; npm info "$PKG@latest" peerDependencies --json | command sed 's/[\\{\\},]//g ; s/: /@/g' | xargs npm install --save-dev "$PKG@latest" )成功。 eslint --init并在package.json运行脚本。

信息:我的节点node v7.5.0 npm 4.1.2

下面有问题。

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

你确定运行eslint --init有效吗?

这就像你没有.eslintrc文件(ESLint解析器选项和规则的配置文件)。 检查/创建项目根目录下的.eslintrc文件,该文件名为“ beslint ”。

然后,您需要在.eslintrc文件中添加此项,以便ESLint考虑您要从Airbnb团队扩展规则:

{ "extends": "airbnb" }

请注意,您可以安装Airbnb团队的不同规则:

  • airbnb ”:Airbnb ESLint规则,包括ECMAScript 6+和React
  • airbnb-base ”:Airbnb ESLint规则,包括ECMAScript 6+
  • airbnb-base / legacy ”:Airbnb ESLint规则,包括ECMAScript 5及以下版本

.eslintrc文件中的extends值应与您的安装相匹配,并且是以前三个值中的一个。

我制作了一个小命令行工具,可以使用这三种不同的Airbnb配置之一安装ESLint。 它会自动创建和配置.eslintrc文件(如果尚未完成)。 它对我的个人项目和工作有很大帮助! 它叫做esbnb 希望它可以帮到你。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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