Install prettier (code formatter)

Install prettier (code formatter)
0

#1

Hello,

i have now spend 2 complete days to get prettier to work:

but i just cant.

i use webstorm. there are some fields to fill here:

this I should use as a guide:
https://github.com/prettier/prettier/blob/master/editors/webstorm/README.md

this i dont understand:
Parameters set --write [other opts] $FilePathRelativeToProjectRoot$
Working directory set $ProjectFileDir$

Should i now copy that exactly in the input boxes in webstorm? or should i replace everything with what??? should i only replace parts of it with something else?

in the input field “Program” this guide says type “prettier” but then i find sources on the internet saying i should put the path there. was i have now.
you see that here: https://medium.com/@jm90mm/adding-prettier-to-webstorm-a218eeec04d2

I really got no clue anymore people. my bloodpressure is now up by 80 points…

plz help me.

Ron


#2

I’ve done it this way, then you can bind it to a key in Keymap, e.g Alt + x to format on key press.

This is on Windows, on mac it’s a bit different.

You can replace [other opts] with options from https://github.com/prettier/prettier#options


#3

@Implaier

awesome! with ur help i got it fixed.

for some reason i do need to add “\*” to make it work. any idea why?


#4

I am using $FilePathRelativeToProjectRoot$ which expands to e.g src\index.jsx.

You have $FileDirRelativeToProjectRoot$ which expands to src, so for it to work you need a glob pattern.

You can read more on globs here: glob-primer.