Fix: Check indentation on multiline variable declarations (fixes #6911)#6912
Fix: Check indentation on multiline variable declarations (fixes #6911)#6912Trott wants to merge 1 commit intoeslint:masterfrom
Conversation
…nt#6911) Add `BinaryExpression` option for `indent` rule to check multi-line variable declarations for indentation issues.
|
LGTM |
| * Indent of 2 spaces with `MemberExpression` set to `0` will indent the multi-line property chains with 0 spaces. | ||
| * Indent of 2 spaces with `MemberExpression` set to `1` will indent the multi-line property chains with 2 spaces. | ||
| * Indent of 2 spaces with `MemberExpression` set to `2` will indent the multi-line property chains with 4 spaces. | ||
| * Indent of 2 spaces with `BinaryExpression` set to `0` will indent the multi-line continuations with 0 spaces. |
There was a problem hiding this comment.
What would be the use-case for indenting with user-defined number of indentation levels? Shouldn't we always indent by just 1 indentation level?
There was a problem hiding this comment.
Two reasons:
- Doing it that way to be consistent with existing options (MemberExpression, SwitchCase, etc.)
- Turns out there are folks who indent string continuations in variable declarations at different levels. Node.js project uses two for everything else, but four for this situation, apparently. See test: add uncaught exception test for debugger nodejs/node#8087 (comment)
¯_(ツ)_/¯
There was a problem hiding this comment.
Hmm.. OK, that sounds like a good enough reason:-)
|
I added "do not merge" label since the issue has not been accepted.
If we want to warn all BinaryExpressions in future, how do we do? Maybe it's going to a breaking change? |
Quite possibly. Each expansion of BinaryExpression in the future would need to be evaluated. |
What issue does this pull request address?
#6911: Indent rule doesn't cover multiline VariableDeclarations
What changes did you make? (Give an overview)
Added a
BinaryExpressionoption to the indent rule that (for now) only is used inside aVariableDeclaration. It warns if continuations are not indented.Is there anything you'd like reviewers to focus on?
Add
BinaryExpressionoption forindentrule to check multi-linevariable declarations for indentation issues.