diff --git a/lib/rules/jsx-indent-props.js b/lib/rules/jsx-indent-props.js index 8935616988..5d33ded173 100644 --- a/lib/rules/jsx-indent-props.js +++ b/lib/rules/jsx-indent-props.js @@ -153,7 +153,7 @@ module.exports = { const indent = regExp.exec(src); const useOperator = /^([ ]|[\t])*[:]/.test(src) || /^([ ]|[\t])*[?]/.test(src); - const useBracket = /^([ ]|[\t])*[<]/.test(src); + const useBracket = /[<]/.test(src); line.currentOperator = false; if (useOperator) { diff --git a/tests/lib/rules/jsx-indent-props.js b/tests/lib/rules/jsx-indent-props.js index bfa5f20d9d..69df13ac79 100644 --- a/tests/lib/rules/jsx-indent-props.js +++ b/tests/lib/rules/jsx-indent-props.js @@ -195,6 +195,48 @@ ruleTester.run('jsx-indent-props', rule, { }, ], }, + { + code: ` + const F = () => { + const foo = true + ?
test
+ : false; + + return
+ test +
+ } + `, + options: [ + { + indentMode: 2, + ignoreTernaryOperator: false, + }, + ], + }, + { + code: ` + const F = () => { + const foo = true + ?
test
+ : false; + + return
+ test +
+ } + `, + options: [ + { + indentMode: 2, + ignoreTernaryOperator: true, + }, + ], + }, { code: ` {this.props.ignoreTernaryOperatorTrue @@ -607,5 +649,95 @@ ruleTester.run('jsx-indent-props', rule, { }, ], }, + { + code: ` + const F = () => { + const foo = true + ?
test
+ : false; + + return
+ test +
+ } + `, + output: ` + const F = () => { + const foo = true + ?
test
+ : false; + + return
+ test +
+ } + `, + options: [ + { + indentMode: 2, + ignoreTernaryOperator: false, + }, + ], + errors: [ + { + messageId: 'wrongIndent', + data: { + needed: 12, + type: 'space', + characters: 'characters', + gotten: 14, + }, + }, + ], + }, + { + code: ` + const F = () => { + const foo = true + ?
test
+ : false; + + return
+ test +
+ } + `, + output: ` + const F = () => { + const foo = true + ?
test
+ : false; + + return
+ test +
+ } + `, + options: [ + { + indentMode: 2, + ignoreTernaryOperator: true, + }, + ], + errors: [ + { + messageId: 'wrongIndent', + data: { + needed: 12, + type: 'space', + characters: 'characters', + gotten: 14, + }, + }, + ], + }, ]), });