Formatting Javascript/Typescript Code With Prettier
You’ve got a bunch of Typescript files with both .ts
and.tsx
. You need to format them using prettier. Your code is managed with source control so you can back out of the changes whenever you need to.
Here’s a quick command line invocation to do it:
npx prettier -w '**/*.ts' '**/*.tsx'
If there are any directories you’d like to ignore, list it in the arguments with a !
:
npx prettier -w '**/*.ts' '**/*.tsx' '!src/gen/**'
I know the help includes the –ignore-path
but this doesn’t actually ignore a path. Instead, it configures the “prettier ignore” file that’s used.