ESLint不会自动格式化代码

8

我有一个简单的项目,只有几个html和js文件。我安装了VS code的ESLint扩展,并将ESLint设置为默认格式化程序:

setting

另外,此设置已转为全部

setting2

这是我的 settings.json 文件:

 "window.zoomLevel": 1,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true
  },
"eslint.validate": ["javascript"],
  "git.enableSmartCommit": true,
  "eslint.alwaysShowStatus": true,
  "files.autoSave": "off",
  "editor.formatOnSave": true,
  "editor.formatOnPaste": true,
  "editor.formatOnType": true,
  "git.ignoreWindowsGit27Warning": true,
  "eslint.options": {
    "eslint brace-style": [
      "error",
      "allman",
      {
        "allowSingleLine": true
      }
    ]
  },
  "eslint.codeAction.showDocumentation": {

    "enable": true
  },
  "editor.defaultFormatter": "dbaeumer.vscode-eslint",
  "eslint.format.enable": true
}

当我按保存键时,ESLint无法在我的js文件上工作(没有修正括号、空格等)。我之前在React应用程序中使用过ESLint,所以一年前它能正常工作。
1个回答

25

我已经找到了自己问题的答案 :)

后来我收到了一条通知

ESLint is disabled since its execution has not been approved or denied yet. Use the light bulb menu to open the approval dialog.eslint

所以我按了这里:

点击位置

打开 ESLint 并允许该扩展程序执行其工作。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接