【问题标题】:How to Prevent the Beautify Extension from Formatting Inline Javascript?如何防止美化扩展格式化内联 Javascript?
【发布时间】:2019-05-29 01:19:03
【问题描述】:

我希望 ESLint 扩展成为内联 Javascript 中唯一的格式化程序。美化只是搞砸了,我必须手动更正。

我已将这些行添加到我的 .jsbeautifyrc 文件中:

    "format.contentUnformatted": "script",
    "format.unformatted": "script", 

但它没有效果:Beautify 仍然格式化 html 文件中的每一行。我忽略了什么?

【问题讨论】:

    标签: javascript visual-studio-code js-beautify


    【解决方案1】:

    根据documentation 应该是这样的:

    {
      "unformatted": ["script"]
    }
    

    如果这不起作用,那么使用language 设置可能会起作用。

    您可以使用 beautify.language 设置控制应美化哪些文件类型、扩展名或特定文件名。

    {
     "beautify.language": {
       "js": {
         "type": ["javascript", "json"],
         "filename": [".jshintrc", ".jsbeautifyrc"]
         // "ext": ["js", "json"]
         // ^^ to set extensions to be beautified using the javascript beautifier
       },
       "css": ["css", "scss"],
       "html": ["htm", "html"]
       // ^^ providing just an array sets the VS Code file type
     }
    }
    

    以上配置应该只对指定的 .js 文件启用格式化。

    祝你好运。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-15
      • 2017-09-04
      相关资源
      最近更新 更多