【问题标题】:How to install eslint-airbnb?如何安装 eslint-airbnb?
【发布时间】:2017-07-06 11:13:49
【问题描述】:

当我跑步时 ( 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.0npm 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

【问题讨论】:

    标签: npm eslint


    【解决方案1】:

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

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

    然后您需要将其添加到.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。希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 2021-07-02
      • 2017-07-06
      • 2019-07-14
      • 1970-01-01
      • 2018-04-21
      • 2020-09-09
      • 2016-10-14
      • 2019-03-08
      • 2017-11-23
      相关资源
      最近更新 更多