fix(lines-before-block
): Only trigger after ';', '}', '|', and '&'
#1383
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1379 and #1343.
I initially went for a targeted fix that would only solve my issue, #1379, but I noticed that all punctuators didn't seem to me like reasonable places to insert a line before. As I had also been facing #1343 solving it was nice too.
Of course what "feels" right is obviously subjective so let me know if you want me to put this behind an option. I considered exposing
lintedPunctuators
as an option but it felt too granular. Disabling&
could be useful to users of Prettier that want to setignoreSameLine
tofalse
though. Specifically, Prettier really isn't fond of the formatting in this snippet:And will format it like so:
Which I think looks terrible.
As a final note, currently the option
checkBlockStarts
is set to actually control linting after all punctuators because I noticed a number of tests expected it to work that way for more than just{
, like the array test etc. This makes it a bit of a misnomer but it appears it was already a bit of a misnomer.