javascript - eslint-config-google 没有检测到全局安装的 eslint

标签 javascript atom-editor eslint linter eslintrc

每当我尝试通过

全局安装eslint-config-google

npm install -g eslint-config-google

我明白了

npm WARN eslint-config-google@0.9.1 requires a peer of eslint@>=4.1.1 but none is installed.
You must install peer dependencies yourself.

但是当我做 eslint --v只是为了再次确认,我得到 v4.16.0 .

我不知道我哪里错了。


从属问题:此外,我有一个全局默认值 .eslintrc文件在我的~我从 linter - eslint 指向的(主)文件夹打包在 Atom 中。当我在 Atom 上保存任何 .js 文件时,我得到

Cannot find module 'eslint-config-google' Referenced from: /Users/aakashverma/.eslintrc.js

这是我的 .eslintrc.js文件在 ~ :

module.exports = {
  "extends": ["eslint:recommended", "google"],
  "rules": {
    "indent": [
      "error",
      4
    ],
    "linebreak-style": [
      "error",
      "unix"
    ],
    "quotes": [
      "error",
      "single"
    ],
    "semi": [
      "error",
      "always"
    ],
    // allow console and debugger in development
    'no-console': process.env.NODE_ENV === 'production' ? 2 : 0,
    'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
  }
}

This kind of talks about it.

最佳答案

好吧,我不确定这是缓存问题还是什么,但我不认为这是因为我一直重启 Atom 和 zsh 但它是这样工作的:

在 Atom 中,我将 .eslintrc Path 更改为 ~/.eslintrc.js 并将 Use global ESlint installation 更改为“checked”。 p>

这是我在 Atom 中指向的主文件夹中的 .eslintrc

enter image description here

最后,为了让它在打开Use global ESlint installation 的情况下工作,我将 eslint-config-googleeslint 都包含在我的 $PATH 变量是这样的

/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
/Users/aakashverma/.nvm/versions/node/v9.4.0/lib/node_modules/eslint/
/Users/aakashverma/.nvm/versions/node/v9.4.0/lib/node_modules/eslint-config-google/

引用@ginna的回答here和我的评论 here .

关于javascript - eslint-config-google 没有检测到全局安装的 eslint,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48360073/

相关文章:

javascript - gulp-angular-templatecache 没有这样的文件或目录,lstat 'templates.js' 错误

ruby-on-rails - Atom-Editor:Rubocop 不适用于 atom

html - 如何设置 Atom-Beautify Wrap HTML 属性

typescript - 如何处理 TypeScript 中 document.getElementById() 方法类型转换期间的 ESLint 错误?

reactjs - Webpack 5 & Jest - 类型 'toBeInTheDocument' 上不存在属性 'JestMatchers<HTMLElement>'

javascript - 没有端口号的 Socket.IO

javascript - Html 页面不向下滚动? CSS

javascript - 在 Ruby on Rails 中的 JavaScript 事件中重新呈现局部 View

python - 原子Python : Functions not recognised

ecmascript-6 - 为什么原子包 linter-eslint 不能识别模板文字?