【问题标题】:eslint not giving errors in VSCode according to rules in .eslintrc fileeslint 没有根据 .eslintrc 文件中的规则在 VSCode 中给出错误
【发布时间】:2019-05-02 15:02:21
【问题描述】:

我已经使用 npm 全局安装了 eslint,并添加了我自己的 .eslintrc 文件,其中包含以下代码:

{
    "env": {
        "browser": true,
        "commonjs": true,
        "es6": true,
        "node": true
    },
    "extends": [
        "eslint:recommended",
        "plugin:react/recommended"
    ],
    "parserOptions": {
        "ecmaFeatures": {
            "experimentalObjectRestSpread": true,
            "jsx": true
        },
        "sourceType": "module"
    },
    "plugins": [
        "react"
    ],
    "rules": {
        "indent": [
            "error",
            "tab"
        ],
        "linebreak-style": [
            "error",
            "unix"
        ],
        "quotes": [
            "error",
            "single"
        ],
        "semi": [
            "error",
            "always"
        ]
    }
}

我添加了以下开发依赖项:

"eslint": "3.19.0",
    "eslint-config-standard": "10.2.1",
    "eslint-plugin-import": "2.7.0",
    "eslint-plugin-markdown": "1.0.0-beta.6",
    "eslint-plugin-node": "5.1.1",
    "eslint-plugin-promise": "3.5.0",
    "eslint-plugin-standard": "3.0.1"

并且还在我的 react native 项目中安装了eslint-plugin-react。 尽管显示了解析错误,但仍然没有显示缩进、分号、双引号错误。 附言在 VScode 中启用了 eslint 插件。

【问题讨论】:

    标签: javascript react-native visual-studio-code eslint


    【解决方案1】:

    同样的事情也发生在我身上。我通过查看 Eslint 日志发现了这个问题的原因:

    1. Ctrl + Shift + P 打开命令面板
    2. 选择Eslint: Show Output Channel

    在我的例子中,输出通道显示如下: Failed to load config "airbnb-base" to extend from. Referenced from: ...eslintrc.js

    我只是在添加开发依赖项后忘了做npm install

    【讨论】:

      猜你喜欢
      • 2018-06-06
      • 2021-05-10
      • 1970-01-01
      • 2018-11-23
      • 2021-12-20
      • 1970-01-01
      • 2019-09-27
      • 2020-10-01
      • 1970-01-01
      相关资源
      最近更新 更多