Skip to content

Commit 41bdb58

Browse files
committed
Fix jsx-indent indentation calculation with nested JSX (fixes #1117)
1 parent ab03af8 commit 41bdb58

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/rules/jsx-indent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ module.exports = {
284284
prevToken = prevToken.type === 'JSXExpressionContainer' ? prevToken.expression : prevToken;
285285

286286
var parentElementIndent = getNodeIndent(prevToken);
287-
if (prevToken.type === 'JSXElement') {
287+
if (prevToken.type === 'JSXElement' && (!prevToken.parent || prevToken.parent.type !== 'LogicalExpression')) {
288288
parentElementIndent = getOpeningElementIndent(prevToken.openingElement);
289289
}
290290

tests/lib/rules/jsx-indent.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,22 @@ ruleTester.run('jsx-indent', rule, {
459459
].join('\n'),
460460
options: [2],
461461
parserOptions: parserOptions
462+
}, {
463+
code: [
464+
'function foo() {',
465+
' return (',
466+
' <div>',
467+
' {bar &&',
468+
' <Div>',
469+
' <span />',
470+
' </Div>',
471+
' }',
472+
' </div>',
473+
' );',
474+
'}'
475+
].join('\n'),
476+
options: [2],
477+
parserOptions: parserOptions
462478
}],
463479

464480
invalid: [{

0 commit comments

Comments
 (0)