Skip to content

Commit

Permalink
[Fix] : Code modification for correct indentation:
Browse files Browse the repository at this point in the history
  • Loading branch information
Moong0122 committed Oct 13, 2020
1 parent 632639b commit f5bd398
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rules/jsx-indent-props.js
Expand Up @@ -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;
Expand Down
17 changes: 17 additions & 0 deletions tests/lib/rules/jsx-indent-props.js
Expand Up @@ -38,6 +38,23 @@ ruleTester.run('jsx-indent-props', rule, {
'/>'
].join('\n'),
options: [2]
}, {
code: [
'const Test = () => ([',
' (x',
' ? <div key="1" />',
' : <div key="2" />),',
' <div',
' key="3"',
' align="left"',
' />,',
' <div',
' key="4"',
' align="left"',
' />,',
']);'
].join('\n'),
options: [2]
}, {
code: [
'<App',
Expand Down

0 comments on commit f5bd398

Please sign in to comment.