I use Visual Studio Code with Vetur extension, when I right click on my .vue file and chose "Format Document" option Visual Studio Code automatically add the semicolons that intentionally removed them.
How do I stop this?
I use Visual Studio Code with Vetur extension, when I right click on my .vue file and chose "Format Document" option Visual Studio Code automatically add the semicolons that intentionally removed them.
How do I stop this?
Put this in your user settings and it won't change your semis:
"vetur.format.defaultFormatter.js": "vscode-typescript",
Forget the earlier answer, gives me runtime issues.
Install Prettier- code formatter extension and disable the addition of semi colons by unchecking the Prettier:Semi as in the screenshot below
Note : Dont forget to reload your vs code after you install the extension and before u do the config changes
Adding .prettierrc
file in project root worked for me with following settings:
{
"semi": false,
"singleQuote": true
}
Changing prettier settings in VSCode Workspace did not work in my case.
You can go to VSCode settings and search for the prettier section.... there's an option for turning off adding semicolons....
Or, just add this line to your custom settings in VSCode:
"prettier.semi": false
I was trying to find a way to do this in the eslint config, and have vs code pick up whatever settings are in the eslint settings... but haven't found it yet. In the meantime, the above works for me...
"javascript.format.semicolons": "remove",
"typescript.format.semicolons": "remove",
"typescriptHero.imports.insertSemicolons": false,
"typescript.preferences.quoteStyle": "single",
"javascript.preferences.quoteStyle": "single",
You can add in your VSCode settings.json
"vetur.format.defaultFormatterOptions": {
"prettier": {
"semi": false
}
},
May be, you have different extensions installed where the usage of semicolons (;) is defined. Try to go to VSCode settings and search for "semicolon". All settings regarding the usage of semicolon will be shown and you can configure it as you like.
Add this line to your custom settings in VSCode (helps with js files):
"autoimport.useSemiColon": false
setting organizedimports to false worked for me
"editor.codeActionsOnSave": {
"source.organizeImports": false
},
Seems many formatters can make this stupid work. Maybe the ideas in other question works, maybe they don't work. This depends additionaly on the fact, which formatter is in use.
So, make rightclick in the code and choose "Format document with.." and then choose "Configure default formatter..". In my case (bu I am not sure about my Code state because I already made some attempts mentioned on this Stackoverflow page): Prettier made the problem, while Vetur and Volar worked well (no semicolon change).
Easiest fix is go to "Settings" in vs code, Search for ";"
In the search result that follows, remove ";" as demonstrated in the below screenshots.
Before the change:
After the change: