To setup your Visual Studio Code to run prettier to reprint the code on File Save follow these steps.
- Install ESLint Plugin and Enable autofix on the save from Settings.
- Install Prettier Plugin.
Now when you will save your file it will use ESLint --fix
option which will run prettier
to reprint entire code. Then it will run ESLint rules to catch the actual bugs in your code. This will also show red squiggly lines with errors.
- Prettier Error Example:
Delete
,eslint(prettier/prettier)
- ESLint Error Example:
Parsing error: Unexpected token {eslint