Closed wispamulet closed 4 years ago
Hi! No, there isn’t. You have Prettier’s way or always curlies to choose between. I’d suggest always using curlies – it’s just one extra line compared to your wanted style (and it makes it easy to add another line to the if
).
Hi!
I'm using
prettier
integrating witheslint
now. I have installedeslint-config-prettier
andeslint-plugin-prettier
and it worked as fine as I expected.Somehow I want to write my code like this (it doesn't make any sense, but I'm just curious 🙄
By default it would be fixed to one line because obviously it's much less than printWidth. Or I can manually add curly braces around this one-line statement.
Then I found two rules related to this: curly nonblock-statement-body-position
For this rule curly,
"multi-or-nest"
is what I'm looking for, But on the README of this repo, it says, This rule requires certain options. which means it would only work when setting to"all"
, so the code would always be like this,For the other one, it would conflict between eslint and prettier when I set to this
'nonblock-statement-body-position': [1, "below"]
, eslint yelled 'Expected a linebreak before this statement.' but prettier insisted to make them on one line.😲 So, is there any method to omit curly braces with a block when there is only one line statement and enforce body to next line?