VSCode single to double quote automatic replace

前端 未结 22 955
死守一世寂寞
死守一世寂寞 2021-01-30 12:03

When I execute a Format Document command on a Vue Component.vue file VSCode replace all single quoted string with double quoted string.

In my specific case

相关标签:
22条回答
  • 2021-01-30 12:38

    For newbies like me:

    From the menu Nav bar at the top: Select File -> Preferences -> Settings. In the search text box, type in Quote In the filtered list that appears below, look for the gear icon and next to it - "Prettier". Click on check box to enable "Prettier: Single Quote"

    0 讨论(0)
  • 2021-01-30 12:39

    It works for me to check single quote in Prettier as well tslint.autoFixOnSave as true

    0 讨论(0)
  • 2021-01-30 12:40

    Well for me both options solved the issue:

    1. By adding inside the .prettierrc - "singleQuote": true

    2. Or by adding following inside the package.json -> "prettier": { "singleQuote": true }

    Though I tried also adding .prettierrc.js and have following

    module.exports = { singleQuote: true };

    This didn't worked.

    0 讨论(0)
  • 2021-01-30 12:43

    For JSX use:

    {"jsxSingleQuote": false}
    
    0 讨论(0)
  • 2021-01-30 12:44

    Install prettier extension and paste below code in your VSCode settings.json file

     "prettier.useEditorConfig": false,
     "prettier.singleQuote": true
    

    this will ignore your .editorconfig file setting.

    0 讨论(0)
  • 2021-01-30 12:46

    For projects that use .editorconfig file by default. The formatter will ignore the rules in the settings and use the rules in .editorconfig, then you can either:

    • Remove .editorconfig file, and use your VSCode settings.
    • Add quote_type = single to the .editorconfig file regarding your file type. You can also set quote_type value to double or auto.
    0 讨论(0)
提交回复
热议问题