From f5bd39833ba5dda828a382169163c6fbef4a3b9c Mon Sep 17 00:00:00 2001 From: Moong0122 Date: Wed, 14 Oct 2020 01:29:51 +0900 Subject: [PATCH] [Fix] : Code modification for correct indentation: --- lib/rules/jsx-indent-props.js | 4 ++++ tests/lib/rules/jsx-indent-props.js | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/rules/jsx-indent-props.js b/lib/rules/jsx-indent-props.js index 7a07cca283..b2c08cec83 100644 --- a/lib/rules/jsx-indent-props.js +++ b/lib/rules/jsx-indent-props.js @@ -124,10 +124,14 @@ module.exports = { const indent = regExp.exec(src); const useOperator = /^([ ]|[\t])*[:]/.test(src) || /^([ ]|[\t])*[?]/.test(src); + const useBracket = /^([ ]|[\t])*[<]/.test(src); + line.currentOperator = false; if (useOperator) { line.isUsingOperator = true; line.currentOperator = true; + } else if (useBracket) { + line.isUsingOperator = false; } return indent ? indent[0].length : 0; diff --git a/tests/lib/rules/jsx-indent-props.js b/tests/lib/rules/jsx-indent-props.js index cc037fa39b..67e4b1223e 100644 --- a/tests/lib/rules/jsx-indent-props.js +++ b/tests/lib/rules/jsx-indent-props.js @@ -38,6 +38,23 @@ ruleTester.run('jsx-indent-props', rule, { '/>' ].join('\n'), options: [2] + }, { + code: [ + 'const Test = () => ([', + ' (x', + ' ?
', + ' :
),', + ' ,', + ' ,', + ']);' + ].join('\n'), + options: [2] }, { code: [ '