diff --git a/lib/rules/jsx-indent.js b/lib/rules/jsx-indent.js
index 5d1cfda332..773e979de1 100644
--- a/lib/rules/jsx-indent.js
+++ b/lib/rules/jsx-indent.js
@@ -275,7 +275,8 @@ module.exports = {
do {
prevToken = sourceCode.getTokenBefore(prevToken);
} while (prevToken.type === 'Punctuator');
- prevToken = sourceCode.getNodeByRangeIndex(prevToken.start);
+ prevToken = sourceCode.getNodeByRangeIndex(prevToken.range[0]);
+
while (prevToken.parent && prevToken.parent.type !== 'ConditionalExpression') {
prevToken = prevToken.parent;
}
diff --git a/tests/lib/rules/jsx-indent.js b/tests/lib/rules/jsx-indent.js
index 20e07641c7..737fdf45b2 100644
--- a/tests/lib/rules/jsx-indent.js
+++ b/tests/lib/rules/jsx-indent.js
@@ -410,6 +410,47 @@ ruleTester.run('jsx-indent', rule, {
].join('\n'),
options: [4, {indentLogicalExpressions: true}],
parserOptions: parserOptions
+ }, {
+ code: [
+ '',
+ ' {condition ?',
+ ' :',
+ ' ',
+ ' }',
+ ''
+ ].join('\n'),
+ options: [2],
+ parserOptions: parserOptions
+ }, {
+ code: [
+ '',
+ ' {condition ?',
+ ' :',
+ ' ',
+ ' }',
+ ''
+ ].join('\n'),
+ options: [2],
+ parserOptions: parserOptions
+ }, {
+ code: [
+ 'function foo() {',
+ ' ',
+ ' {condition ?',
+ ' :',
+ ' ',
+ ' }',
+ ' ',
+ '}'
+ ].join('\n'),
+ options: [2],
+ parserOptions: parserOptions
}],
invalid: [{