- set up eslint
- set up prettier-eslint
Demo code for configuration below
npm install --save-dev \
npm install --save-dev prettier-eslint prettier-eslint-cli
"lint": "eslint --fix src",
Configure a few VSCode settings:
“prettier.eslintIntegration”: true — tells Prettier to use prettier-eslint instead of Prettier
“prettier.stylelintIntegration”: true — tells Prettier to use prettier-stylelint instead of Prettier
“eslint.autoFixOnSave”: false — we don’t need ESLint to fix our code for us directly, since prettier-eslint will be running eslint –fix for us anyways.
“editor.formatOnSave”: true — runs Prettier with the above options on every file save, so you never have to manually invoke VSCode’s format command.
Additionally, you can check-in the above workplace settings to source control so its easier for other team members to set up their editors. You can do so by creating a .vscode folder at the root of your project and putting all of the above rules in a settings.json file.
Note: Even with eslint, it cannot fix everything for us.