Skip to content

Commit 237547e

Browse files
Moong0122ljharb
authored andcommitted
[Fix] jsx-indent-props: Apply indentation when using brackets
Per #2808 (comment)
1 parent 632639b commit 237547e

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
55

66
## Unreleased
77

8+
### Fixed
9+
* [`jsx-indent-props`]: Apply indentation when using brackets ([#2826][] @Moong0122)
10+
11+
[#2826]: https://github.com/yannickcr/eslint-plugin-react/issues/2826
12+
813
## [7.21.4] - 2020.10.09
914

1015
### Fixed

lib/rules/jsx-indent-props.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,14 @@ module.exports = {
124124

125125
const indent = regExp.exec(src);
126126
const useOperator = /^([ ]|[\t])*[:]/.test(src) || /^([ ]|[\t])*[?]/.test(src);
127+
const useBracket = /^([ ]|[\t])*[<]/.test(src);
128+
127129
line.currentOperator = false;
128130
if (useOperator) {
129131
line.isUsingOperator = true;
130132
line.currentOperator = true;
133+
} else if (useBracket) {
134+
line.isUsingOperator = false;
131135
}
132136

133137
return indent ? indent[0].length : 0;

tests/lib/rules/jsx-indent-props.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@ ruleTester.run('jsx-indent-props', rule, {
3838
'/>'
3939
].join('\n'),
4040
options: [2]
41+
}, {
42+
code: [
43+
'const Test = () => ([',
44+
' (x',
45+
' ? <div key="1" />',
46+
' : <div key="2" />),',
47+
' <div',
48+
' key="3"',
49+
' align="left"',
50+
' />,',
51+
' <div',
52+
' key="4"',
53+
' align="left"',
54+
' />,',
55+
']);'
56+
].join('\n'),
57+
options: [2]
4158
}, {
4259
code: [
4360
'<App',

0 commit comments

Comments
 (0)