• 请不要在回答技术问题时复制粘贴 AI 生成的内容
doublleft
V2EX  ›  程序员

VSCode 的格式化和保存时格式化的标准不一致咋办

  •  
  •   doublleft · Aug 24, 2017 · 7098 views
    This topic created in 3211 days ago, the information mentioned may be changed or developed.
    装了一个 StandardJS,设置了 onSave 格式化,结果就是保存文件时会按照 StandardJS 标准格式化
    但是编辑器自带的快捷键格式化和 onSave 不是一套标准,主动格式化的代码规范有地方修改吗?
    10 replies    2017-09-21 16:49:47 +08:00
    crysislinux
        1
    crysislinux  
       Aug 24, 2017 via Android
    用 editorconfig 插件改
    crysislinux
        2
    crysislinux  
       Aug 24, 2017 via Android
    我错了。你这个不一样。
    cxbig
        3
    cxbig  
       Aug 24, 2017
    关掉那个 onSave,或找到它的配置文件
    doublleft
        4
    doublleft  
    OP
       Aug 24, 2017
    @cxbig 我还不知道关掉 onSave ? 我设置的 onSave 目的就是用 standardjs 啊
    dgeibi
        5
    dgeibi  
       Aug 24, 2017 via Android
    换 eslint 用 prettier https://github.com/prettier/prettier-vscode 开启 prettier.eslintIntegration
    cxbig
        6
    cxbig  
       Aug 24, 2017
    @doublleft 我理解错了。
    我这没看到官方有自动触发的格式化工具,是不是你同时开启了别的插件?
    owt5008137
        7
    owt5008137  
       Aug 25, 2017 via Android
    这种情况,你应该给 standardjs 去提 issue
    doublleft
        8
    doublleft  
    OP
       Aug 25, 2017
    @cxbig

    VSCode 的 editor.action.format 的格式化,和 StandardJS 的 standard.autoFixOnSave
    crossingmay
        9
    crossingmay  
       Sep 20, 2017   ❤️ 1
    楼主这个是不是因为具名函数之前必须要空格,然后官方 format 默认是没有空格的?
    这个可以搜索`insertSpaceBeforeFunctionParenthesis`,设置为 true 应该就没问题了。
    我自己还用了 vetur 这个插件,设置同样的选项在 vue 文件里也能正常使用。
    doublleft
        10
    doublleft  
    OP
       Sep 21, 2017
    @crossingmay 我试下 谢谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1322 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 52ms · UTC 17:23 · PVG 01:23 · LAX 10:23 · JFK 13:23
    ♥ Do have faith in what you're doing.