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"

Use js for JavaScript and ts for TypeScript

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

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

Be sure to run your unit-tests afterwards

Author: Marcel Michelfelder


Add a comment

  • evgenii
    evgenii

    18 September, 2019

    thx

    reply

Want to get in touch?

Contact