简体   繁体   中英

Visual Studio Code is auto formatting my js file that has markup

I upgraded my visual studio code version 1.33.0 recently and am having issues with saving my files because they keep formatting when I save the document.

I have looked through the update - https://code.visualstudio.com/updates/v1_33 and opened up the javascript and javascriptreact languages in the settings.json file.

settings.json file

{
  "window.zoomLevel": 0,
  "files.associations": {
    "*.scss": "scss"
  },
  "mssql.connections": [
    {
      "server": "localhost",
      "database": "",
      "authenticationType": "SqlLogin",
      "user": "SA",
      "password": "",
      "emptyPasswordInput": false,
      "savePassword": true,
      "profileName": "localhost profile"
    }
  ],
  "javascript.implicitProjectConfig.experimentalDecorators": false,
  "editor.tabSize": 2,
  "php.validate.enable": false,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "workbench.startupEditor": "none",
  "javascript.format.insertSpaceBeforeFunctionParenthesis": true,
  "editor.formatOnSave": false,
  "[javascript]": {
      "editor.formatOnSave": false,
      "editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
    "editor.formatOnSave": false,
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }
}

This does not matter, it ignores these preferences and auto formats it to VSCs auto default format. I am using .js files with react and switching the rsx is not an option. Thanks

There are 3 levels of settings(User level, Workspace Level, Global) in VSC. Check if formatOnSave is false for all of them. If it still indents your code, then create a .editorconfig file in your project and mention your settings there. It gets the highest preference in VSC settings and will override all the others.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM