diff --git a/lib/rules/indent.js b/lib/rules/indent.js index b9db4a78245..cf5e5d95aba 100644 --- a/lib/rules/indent.js +++ b/lib/rules/indent.js @@ -695,19 +695,11 @@ module.exports = { // TODO - come up with a better strategy in future if (isNodeFirstInLine(node)) { const parent = node.parent; - let effectiveParent = parent; - if (parent.type === "MemberExpression") { - if (isNodeFirstInLine(parent)) { - effectiveParent = parent.parent.parent; - } else { - effectiveParent = parent.parent; - } - } - nodeIndent = getNodeIndent(effectiveParent).goodChar; + nodeIndent = getNodeIndent(parent).goodChar; if (parentVarNode && parentVarNode.loc.start.line !== node.loc.start.line) { if (parent.type !== "VariableDeclarator" || parentVarNode === parentVarNode.parent.declarations[0]) { - if (parent.type === "VariableDeclarator" && parentVarNode.loc.start.line === effectiveParent.loc.start.line) { + if (parent.type === "VariableDeclarator" && parentVarNode.loc.start.line === parent.loc.start.line) { nodeIndent = nodeIndent + (indentSize * options.VariableDeclarator[parentVarNode.parent.kind]); } else if ( parent.type === "ObjectExpression" || @@ -720,7 +712,7 @@ module.exports = { nodeIndent = nodeIndent + indentSize; } } - } else if (!parentVarNode && !isFirstArrayElementOnSameLine(parent) && effectiveParent.type !== "MemberExpression" && effectiveParent.type !== "ExpressionStatement" && effectiveParent.type !== "AssignmentExpression" && effectiveParent.type !== "Property") { + } else if (!parentVarNode && !isFirstArrayElementOnSameLine(parent) && parent.type !== "MemberExpression" && parent.type !== "ExpressionStatement" && parent.type !== "AssignmentExpression" && parent.type !== "Property") { nodeIndent = nodeIndent + indentSize; } diff --git a/tests/lib/rules/indent.js b/tests/lib/rules/indent.js index 20351b7a881..e04db10c0c1 100644 --- a/tests/lib/rules/indent.js +++ b/tests/lib/rules/indent.js @@ -1698,6 +1698,18 @@ ruleTester.run("indent", rule, { " new Car('!')\n" + ");", options: [2, {CallExpression: {arguments: 4}}] + }, + + // https://github.com/eslint/eslint/issues/7484 + { + code: + "var foo = function() {\n" + + " return bar(\n" + + " [{\n" + + " }].concat(baz)\n" + + " );\n" + + "};", + options: [2] } ], invalid: [