Member-only story
Run Prettier on Save
First, add Prettier globally. In Terminal:
yarn global add prettier
Then, in the root directory of whatever project you’re working on create an .prettierrc
file.
Inside the .prettierrc
file, add this:
{}
Yup, just a simple empty object.
Then, go to Code → Preferences → Settings
Or Just do Command + ,
Search in settings format on save
Check the checkbox that says Format on Save.
Search in settings require config
Check Require a ‘prettierconfig’ to format checkbox.
Look up formatter.
Change Default Formatter to Prettier — Code formatter
Now every time you save a file, it will run Prettier on that particular file.