Skip to content

Instantly share code, notes, and snippets.

@Mohamed3on
Last active April 5, 2024 17:03
Show Gist options
  • Star 52 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save Mohamed3on/840b34ecb7e9abf06ace035183b7f1fc to your computer and use it in GitHub Desktop.
Save Mohamed3on/840b34ecb7e9abf06ace035183b7f1fc to your computer and use it in GitHub Desktop.
Run prettier on all JS files in a directory
  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 "**/*.js" *Don't forget the quotes.
  4. Optional: if you want to format JSON/SCSS files too, replace js with json/scss.
@tuanluu-agilityio
Copy link

 *Don't forget the quotes.

It saves my life 👍

Thanks

@ameernormie
Copy link

 *Don't forget the quotes.

It saves my life 👍

Thanks

Thanks. That's what I was missing. 👌🏻

@melroy89
Copy link

melroy89 commented Nov 16, 2021

I'm using: prettier --write "src/**/*.js"

Or within the package.json file, within the "scripts" section:

    "pretty": "prettier --write \"src/**/*.js\""

@ankurparihar
Copy link

ankurparihar commented Feb 5, 2022

For multiple file formats

prettier --write "**/*.{css,js,json}"

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