【问题标题】:I want to run only Prettier when saving files with VSCode使用 VSCode 保存文件时,我只想运行 Prettier
【发布时间】:2020-01-31 11:26:30
【问题描述】:

我想在保存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】:

    我会在这里跟踪这个问题:https://github.com/microsoft/vscode-eslint/issues/380

    好像自动保存在“格式”和“ESLint 修复”或 Prettier 等之间出现冲突。

    您可以尝试临时修复他们对 javascript 的建议:

    "editor.formatOnSave": true,
    "[javascript]": {
        "editor.formatOnSave": false
    }
    

    【讨论】:

    • 谢谢你的回答我没有解决,但我放弃了。
    猜你喜欢
    • 2018-05-16
    • 2020-03-08
    • 2019-02-07
    • 2012-08-25
    • 2019-07-09
    • 2020-01-17
    • 1970-01-01
    • 1970-01-01
    • 2016-09-24
    相关资源
    最近更新 更多