[使用VSCode保存文件时,我只想运行漂亮的文件

问题描述 投票:0回答:1

我想在保存JS文件时使用Pretter进行格式化,添加VSCode Prettier扩展名并将其设置为"editor.formatOnSave": true

文件目前已自动格式化,但是存储库中的ESLint AutoFix也同时执行。

首先,我认为ESLint的扩展名不好,并且设置"eslint.autoFixOnSave": false无效。

通过运行prettier --write并带有允许在保存文件时运行任意命令的扩展名,可以解决当前情况。

但是,由于格式化将比通过formatOnSave的扩展名运行Prettier延迟,因此延迟。

因此,我正在研究是否可以不依赖于除Prettier和ESLint之外的扩展来完成它。

存储库在这里。https://github.com/pvcresin/es

javascript visual-studio-code eslint formatter prettier
1个回答
0
投票

我将在此处跟踪问题:https://github.com/microsoft/vscode-eslint/issues/380

好像自动保存似乎在“格式”和“ ESLint修复”或“漂亮”之间冲突。

您可以尝试暂时解决他们对javascript的建议:

"editor.formatOnSave": true,
"[javascript]": {
    "editor.formatOnSave": false
}
© www.soinside.com 2019 - 2024. All rights reserved.