You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing an if that contains multiple let bindings, a where clause, etc. I often split the expressions into multiple lines indented one level below the if for readability. When doing this, I move the opening brace to a new line (matching the indentation level of the if) to help distinguish the statements within the if from the conditions, since they are at the same indentation level.
For example, instead of something like this:
if
let blah = blah,
let foo = blah.foo
where foo.something {
// do something
}
I find the following more readable:
if
let blah = blah,
let foo = blah.foo
where foo.something
{
// do something
}
I would like the opening brace rule to be configurable to support opening braces in this style, under these conditions.
The text was updated successfully, but these errors were encountered:
I too prefer this style for multi-line if, guard, and while, so I have been thinking about a way to accomplish it. Since the current implementation uses regex to find violations, I came up with what I think is a regex pattern to detect these cases: ((?:if|guard|while)\n(?:.+\n)+{). I'm no regex expert, so additional verification would be appreciated.
I was originally hoping to modify the existing regex to exclude these matches, but I have found that to be difficult--again, no regex expert. I thought a negative lookbehind would be the best option, but because the number of conditions is unbounded, this didn't pan out. My second approach is to find the ranges matching the existing regex, then find the ranges matching my regex, and then filter out the overlap. I have some performance concerns about this approach though.
When writing an if that contains multiple
let
bindings, awhere
clause, etc. I often split the expressions into multiple lines indented one level below theif
for readability. When doing this, I move the opening brace to a new line (matching the indentation level of theif
) to help distinguish the statements within theif
from the conditions, since they are at the same indentation level.For example, instead of something like this:
I find the following more readable:
I would like the opening brace rule to be configurable to support opening braces in this style, under these conditions.
The text was updated successfully, but these errors were encountered: