Run prettier on all js/ts files in a directory recursively

25 November, 2018

Prettier beautifies your JavaScript or TypeScript code. I use it with my IDE, "WebStorm", which checks on my files as I save them.

Now once in a while I like to work on older projects - projects where I did not use Prettier before. Instead of saving each file manually, so that my IDE triggers the Prettier binary, I would like to process all files in my project in one go.

prettier --write "src/**/*.ts"

emoji-bulbUse js for JavaScript and ts for TypeScript emoji-wink

emoji-bulbBe sure to use double quotes: ". Otherwise your bash will mistake them for wildcards

emoji-bulbCommit all changes in a single commit. Don't mix them up with any other changes you've done so far.

emoji-bulbBe sure to run your unit-tests afterwards

Author: Marcel Michelfelder


Add a comment

Want to get in touch?