blob: 94e9a3a94809bcd5eaf0c7daa8849b226a4e6442 [file] [log] [blame]
40 columns |
>>> Chained assignment.
a=b=c;
<<<
a = b = c;
>>> Compound assignment operators.
a*=b/=c~/=d%=e;
<<<
a *= b /= c ~/= d %= e;
>>>
a+=b-=c;
<<<
a += b -= c;
>>>
a<<=b>>>=c>>=d;
<<<
a <<= b >>>= c >>= d;
>>>
a&=b^=c|=d;
<<<
a &= b ^= c |= d;
>>>
a??=b;
<<<
a ??= b;
>>> Split after `=`.
variableName = thisIsReallyQuiteAVeryLongVariableName;
<<<
variableName =
thisIsReallyQuiteAVeryLongVariableName;
>>> Prefer to split at "=" over infix operator.
variableName = argument * argument + argument;
<<<
variableName =
argument * argument + argument;
>>> Prefer block-like splitting for collections.
variableName = [element, element, element];
<<<
variableName = [
element,
element,
element,
];
>>> Prefer block-like splitting for function calls.
variableName = function(argument, argument);
<<<
variableName = function(
argument,
argument,
);
>>> No block-like splitting for empty argument lists.
variableNameExactLength____ = function();
<<<
variableNameExactLength____ =
function();
>>> No block-like splitting if function name doesn't fit.
longVariableName = veryLongFunctionName_(argument);
<<<
longVariableName =
veryLongFunctionName_(argument);
>>> Indent block if function name doesn't fit and arguments split.
longVariableName = veryLongFunctionName_(argument, another);
<<<
longVariableName =
veryLongFunctionName_(
argument,
another,
);
>>> Prefer to split at `=` over property chain.
target.property.another = reallyLongValue;
<<<
target.property.another =
reallyLongValue;
>>> Split property chain on left.
target.property.another.lastOneReallyLong = reallyLongValue;
<<<
target
.property
.another
.lastOneReallyLong =
reallyLongValue;
>>> Allow block formatting through nested assignments.
outer = inner = [element1, element2, element3, element4];
<<< 3.7
outer =
inner = [
element1,
element2,
element3,
element4,
];
<<< 3.8
outer = inner = [
element1,
element2,
element3,
element4,
];
>>> Headline format unsplit target of call chain.
variable = (tar + get).method().another().third();
<<< 3.7
variable =
(tar + get)
.method()
.another()
.third();
<<< 3.8
variable = (tar + get)
.method()
.another()
.third();
>>> Don't headline format target of call chain if target splits.
variable = (veryLongTarget + expressionThatSplits).method().another().third();
<<<
variable =
(veryLongTarget +
expressionThatSplits)
.method()
.another()
.third();
>>> Headline format unsplit properties of call chain.
variable = (tar + get).prop.erty.method().another().third();
<<< 3.7
variable =
(tar + get).prop.erty
.method()
.another()
.third();
<<< 3.8
variable = (tar + get).prop.erty
.method()
.another()
.third();