npm - 如何安装 eslint-airbnb?

标签 npm eslint

当我运行时( 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 及以下
  • extends您的值(value) .eslintrc文件应该与您的安装相匹配,并且是这三个先前值之一。

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

    关于npm - 如何安装 eslint-airbnb?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42289259/

    相关文章:

    angular - 如何动态覆盖 Angular2 可注入(inject)服务?

    node.js - “npx create-react-app appname” 不工作

    node.js - 在 package.json 中设置环境变量

    node.js - 没有名为 ForceSet 的成员

    javascript - 如何修复此 ESLint/JSDoc 语法错误?

    node.js - 向 Mongoose 注册模型的正确方法

    eslint - 如何修复/禁用看似错误的 "No named exports found in module"错误?

    html - npm http-server 下载 index.html 而不是服务

    ecmascript-6 - 如何避免 eslint 规则 no-unneed-ternary 违规 : 'Unnecessary use of conditional expression for default assignment'

    reactjs - 更新状态,而不将其设置为 useEffect 中的依赖项?详尽的 deps lint 规则