vyt*_*ute 15 eslint visual-studio-code
我正在按照教程打开保存文件时的 ESLint 自动修复。教程演示了如何选中复选框。我找不到它。我需要任何扩展或 smth 吗?
转到:查看 -> 命令面板 -> 首选项:打开工作区设置 -> 扩展 -> ESLint
这是教程中设置页面的样子:
这就是我所看到的:
hot*_*ink 36
该设置已弃用。Auto Fix on Save 现在是 VS Code 的 Code Action on Save 基础设施的一部分。请参阅发行说明。只是为了好玩,您可以通过添加"eslint.autoFixOnSave": true到settings.json来恢复复选框。但是,您现在需要添加的是:
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
Run Code Online (Sandbox Code Playgroud)
小智 5
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
Run Code Online (Sandbox Code Playgroud)
Since VSCode 1.56, this solution only works when you trigger save action manually by Ctrl/Cmd + S.
It won't work with auto save with onFocusChange or onWindowChange.
In my case, I wanna trigger eslint anytime my code saved. So instead of using editor.codeActionsOnSave, I set eslint as the default formatter for js/ts, then trigger format on save.
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"eslint.format.enable": true,
"editor.formatOnSave": true,
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8798 次 |
| 最近记录: |