Skip to content

Instantly share code, notes, and snippets.

@pedroalmeida415
Last active April 7, 2020 23:32
Show Gist options
  • Save pedroalmeida415/f759972b53f2def21eb06634ad27ffcc to your computer and use it in GitHub Desktop.
Save pedroalmeida415/f759972b53f2def21eb06634ad27ffcc to your computer and use it in GitHub Desktop.
Run prettier on all files in a directory with the given extension(s)
  1. Install prettier
  2. Make a .prettierignore file, and add directories you'd like prettier to not format, for example: **/node_modules
  3. Run prettier --write "**/*.{ts,js,css,html,insertAnyFilesExtensionHere}" **Don't forget the quotes.

You could also add this to your projects package.json under scripts to simply run npm run prettier to format your code before committing it:

{ ... "scripts": { "prettier": "prettier --write '**/*.{ts,js,css,html}'" } ... }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment