Vetur Ignores .eslintrc settings when formatOnSave is true
See original GitHub issueInfo
- Platform: Linux (Ubuntu 16.04)
- Vetur version: 0.11.7
- VS Code version: 1.22.2
- ESLint extension version: 1.4.8
Problem
When "editor.formatOnSave"
is set to true
in the VS Code settings, Vetur does not respect the settings in .eslintrc
.
Reproducible Case
- Install Vetur VS Code Extension
- Install ESLint VS Code Extension
- Add the following to VS Code User Settings:
"editor.formatOnSave": true,
"eslint.validate": [
"javascript",
"javascriptreact",
"vue"
],
"eslint.autoFixOnSave": true,
}
- Reload VS Code
- Use the vue 3.0 cli (I used version
3.0.0-beta.6
) to create a new project:vue create new-project
- Choose
Manually select features
- Choose
Linter / Formatter
- Choose
ESLint + Airbnb config
- Choose
Lint on save
- Choose
In dedicated config files
- Open the new project in VS Code
- Make a change to the App.vue file
- *Notice that it changed single quotes to double and removed trailing commas contrary to the .eslintrc config
Issue Analytics
- State:
- Created 5 years ago
- Reactions:17
- Comments:19 (5 by maintainers)
Top Results From Across the Web
ESLint in VSCode not fixing on save - Stack Overflow
Making all our formatter settings look like this: "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.fixAll" ...
Read more >ESLint and Prettier with Vite and Vue.js 3 - Vue School Blog
We just need to install the eslint-config-prettier config. This disables the formatting rules in ESLint that Prettier is going to be responsible ...
Read more >How to setup ESLint and Prettier with VS Code and VueJS
You can set Vetur as the default by selecting ”Configure Default Formatter” after ”Format Document With…” then select ”Vetur” from the options.
Read more >Eslint for Vue projects in VSCode - DEV Community
I'd like to share my VSCode and ESLint configuration that I use in ... fixAll.eslint": true }, "vetur.validation.template": false, "editor.
Read more >Vetur/Eslint/VS Code - can't set space between parenthesis for ...
Then we should add following to settings.json in VS Code. "editor.formatOnSave": true, "editor.codeActionsOnSave": { "source.fixAll": true },.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I solved this by adding the following to the default value for
vetur.format.defaultFormatterOptions
So it looks like this:
Looks like I found a config to get this working. If I add the below configuration to VS Code it works although it seems a little glitchy. For example, if in addition to the config below, I also set
"editor.formatOnSave": true
, then I see the code flash with double quotes and then get correctly formatted with single quotes, so it seems like Vetur might be formatting it with quotes and then ESLint is fixing it afterwards. It would be good if whatever Vetur is doing would respect the .eslintrc config.Here’s the VSCode config that makes it work: