So I feel like I should not be having to ask for help on this, but I feel like I have grown very annoyed with formatters fighting over each other that it has actually gotten old to write TypeScript/JavaScript code in VSCode with Vue (or really any other frontend framework).
Issue
So here is my issue: Currently I have my .vue files formatting correctly and it is giving me good eslint warnings and errors. Though now the issue is in my .ts or .js files. These files never want to format properly now and I can't get it to format on save. Then if I do end up getting it to format on save, it seems it will fight against the .vue files.
Example: Currently my .vue files format properly and use my preferred 2 spaces for tabbing. While my .ts or .js files will just go straight to using the 4 spaces for tabs, and won't even correct itself no matter what I do.
What I'm looking for
What I'm looking for a great environment and project setup that will do the following:
- Listen to the projects eslint settings
- Listen to the projects prettier settings for formatting
- Be able to auto format on save all my files and not have them conflict with each other
- Best way to update and modify settings
Current Environment/Project Setup
Currently the environment/project setup is the following:
- VSCode
- Vetur Extension
- ESLint Extension
- VueJS
- eslint and prettier on project
For Vetur I have all my formatters turned on. I also have the format on save turned on. For the Vue project I am using the following packages/rules for eslint
extends: ["prettier", "prettier/standard", "plugin:@typescript-eslint/recommended", "plugin:vue/recommended"],
plugins: ["vue", "prettier"],
parser: "vue-eslint-parser",
And for prettier, I have the following setup:
{
"singleQuote": true,
"trailingComma": "none",
"endOfLine": "auto",
"htmlWhitespaceSensitivity": "ignore",
"tabWidth": 2
}
I will take any suggestions on best practices to take. I understand a lot of this will be opinionated as everyone has different takes on how formatting should be done, but I am looking for the best practices to make sure your environment and project is setup properly so you are not fighting these issues for every new project that you start or work with, with other people.
Any help/suggestions is greatly appreciated. Thanks!







I definitely relate to this - the biggest problem I had with Vue was getting it to play nicely with Prettier/ESLint 😅
Something I have in my settings.json file is:
I'm not 100% sure when/why I added these, but it might help with the issue.
I will also note that I have this in my .eslintrc.js file (only the vue plugins you listed):
extends: ["plugin:vue/essential", "@vue/prettier"],and this:
I very much poked at these files until I got them where I liked them, and am by no means an expert on these set ups, but maybe some of these differences will either help or set you on the path to victory 😀