- Install prettier
- Make a .prettierignore file, and add directories you'd like prettier to not format, for example:
**/node_modules
- Run
prettier --write "**/*.js"
*Don't forget the quotes. - Optional: if you want to format JSON/SCSS files too, replace js with json/scss.
Last active
January 7, 2025 03:23
-
-
Save Mohamed3on/840b34ecb7e9abf06ace035183b7f1fc to your computer and use it in GitHub Desktop.
Run prettier on all JS files in a directory
*Don't forget the quotes.
It saves my life 👍
Thanks
*Don't forget the quotes.
It saves my life 👍
Thanks
Thanks. That's what I was missing. 👌🏻
I'm using: prettier --write "src/**/*.js"
Or within the package.json file, within the "scripts" section:
"pretty": "prettier --write \"src/**/*.js\""
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
Thanks for an easy and straightforward solution. My only suggestion would be to mention that you can add options, and maybe link to https://prettier.io/docs/en/options.html.