【问题标题】:Visual Studio Code: Failed to apply ESLint fixes to the documentVisual Studio Code:无法将 ESLint 修复应用于文档
【发布时间】:2017-02-26 02:42:52
【问题描述】:

我正在使用 Visual Studio Code 1.6.1,安装并启用了最新版本的 ESLint 扩展。 我有

"eslint.options": {
  "rules": {
    ...
  }
}

在我的 vs-code 用户设置中。 我能够使用自动命令“eslint.executeAutofix”自动修复我的 js 文件,但可能从我上次更新 vs-code 开始,我收到以下错误:

Failed to apply ESLint fixes to the document. Please consider opening an issue with steps to reproduce.

有人可以帮助我或指出我可以解决此问题的方向吗?

【问题讨论】:

  • 问题仍然存在。我注意到 eslint 正在开发新项目,但在我目前的项目中却没有。有什么我可以检查的吗?

标签: javascript visual-studio-code eslint linter


【解决方案1】:

对于遇到相同问题的任何人。要进行故障排除,请尝试运行 npx eslint path/to/your/file 以查看实际的 eslint 输出。

就我而言,它缺少 Prettier 插件:

Failed to load plugin 'prettier' declared in '.eslintrc.js » @react-native-community/eslint-config': Cannot find module 'eslint-plugin-prettier'

【讨论】:

    【解决方案2】:

    不知何故 npm install eslint --save-dev 解决了这个问题。 现在即使在 npm uninstall eslint --save-dev 之后它也可以工作。 奇怪……

    【讨论】:

      【解决方案3】:

      在您的文件上运行 eslint lint .\filename 并查看它的内容。

      就我而言,它是Error: unreachable。然后我开始删除我的小块代码并一遍又一遍地运行eslint lint .\filename,直到找到导致问题的确切行。原来我在js文件中使用??而不是||犯了一个愚蠢的错误

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2019-05-12
        • 2020-07-31
        • 2018-02-25
        • 1970-01-01
        • 2016-12-09
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多