two action result in different result, caused by prettier does not respect eslint config .
CMT + SHIFT+ P -> Format Document -> Prettier formats code.
Save again -> eslint autofix formats code.
// Place your settings in this file to overwrite the default settings
{
"window.zoomLevel": 1,
"gitlens.advanced.messages": {
"suppressCommitHasNoPreviousCommitWarning": false,
"suppressCommitNotFoundWarning": false,
"suppressFileNotUnderSourceControlWarning": false,
"suppressGitVersionWarning": false,
"suppressLineUncommittedWarning": false,
"suppressNoRepositoryWarning": false,
"suppressUpdateNotice": true,
"suppressWelcomeNotice": false
},
"prettier.eslintIntegration": true,
"prettier.stylelintIntegration": true,
"editor.formatOnSave": false,
"eslint.autoFixOnSave": true,
"eslint.validate": [
"javascript",
"javascriptreact",
{
"language": "vue",
"autoFix": true
},
{
"language": "html",
"autoFix": true
},
"vue"
]
}
What's the difference between those 2 outputs?
With eslintIntegration it already calls eslint --fix
They follow different rule.
It doesn't make sense to use both at once, as both will run the code through ESLint. You shoud either use:
"editor.formatOnSave": false,
"eslint.autoFixOnSave": true,
or
"editor.formatOnSave": true,
"eslint.autoFixOnSave": false,
@azz Thanks so much
For some reason, this combination stopped working for me:
"editor.formatOnSave": true,
"eslint.autoFixOnSave": false,
This one still works though:
"editor.formatOnSave": false,
"eslint.autoFixOnSave": true,
For the latest eslint extension, the settings should look like this:
{
"editor.formatOnSave": false,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
}
}
That disabled prettier entirely right?
Trying to wrap my head around the integration of prettier and eslint as well …
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
It doesn't make sense to use both at once, as both will run the code through ESLint. You shoud either use:
or