Skip to content

Commit

Permalink
Fix: ignore MemberExpression in VariableDeclarators (fixes eslint#6795)
Browse files Browse the repository at this point in the history
Chained properties on objects will typically not be indented as the rule
expects in variable declarations. For now, ignore variable declarations
(as was done in the previous version of ESLint, where all chained
properties were ignored) and possibly revisit later to offer users
opportunity to enforce alignment and/or sensible indentation.
  • Loading branch information
Trott committed Jul 29, 2016
1 parent 5230310 commit 977e24f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rules/indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,10 @@ module.exports = {
return;
}

if (getVariableDeclaratorNode(node)) {
return;
}

let propertyIndent = getNodeIndent(node) + indentSize * options.MemberExpression;

let checkNodes = [node.property];
Expand Down
6 changes: 6 additions & 0 deletions tests/lib/rules/indent.js
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,12 @@ ruleTester.run("indent", rule, {
" .foo\n" +
" .bar",
options: [2, {MemberExpression: 2}]
},
{
code:
"var foo = bar.baz()\n" +
" .bip();",
options: [2]
}
],
invalid: [
Expand Down

0 comments on commit 977e24f

Please sign in to comment.