首页 > 解决方案 > Eslint 正在从终端工作,但在编辑器 UI (VSCode) 中未显示错误

问题描述

我已经按照以下步骤安装了 ESlint: https ://travishorn.com/setting-up-eslint-on-vs-code-with-airbnb-javascript-style-guide-6eb78a535ba6

现在,我的 ESlint 正在终端上运行,但错误/警告没有显示在代码窗口中,这是我的项目结构及其外观:

eslint 终端

和我的eslintrc配置:

module.exports = {
  env: {
    browser: true,
    commonjs: true,
    es6: true,
    node: true,
  },
  extends: [
    'airbnb-base',
  ],
  globals: {
    Atomics: 'readonly',
    SharedArrayBuffer: 'readonly',
  },
  parserOptions: {
    ecmaVersion: 2018,
  },
  rules: {
  },
};

为什么它不能在编辑器中显示错误?

标签: javascriptvisual-studio-codeeslinteslint-config-airbnbeslintrc

解决方案


我最近遇到了这个问题,并通过将我的.eslintrc.js文件更改为只是.eslintrc(仅限 JSON 对象,无注释,所有引用正确,无扩展名)来修复它。重新启动 VSCode 后,它正确拾取文件并在 VSCode 中给了我 linter 错误。


推荐阅读