Skip to content

Commit a8fca2a

Browse files
committed
[Fix] jsx-indent: do not report on non-jsx-returning ternaries that contain null
Fixes #3222
1 parent fe708e1 commit a8fca2a

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
77

88
### Fixed
99
* [`jsx-curly-brace-presence`]: avoid warning on curlies containing quote characters ([#3214][] @ljharb)
10+
* [`jsx-indent`]: do not report on non-jsx-returning ternaries that contain null ([#3222][] @ljharb)
1011

12+
[#3222]: https://github.com/yannickcr/eslint-plugin-react/issues/3222
1113
[#3214]: https://github.com/yannickcr/eslint-plugin-react/issues/3214
1214

1315
## [7.29.1] - 2022.02.25

lib/rules/jsx-indent.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ module.exports = {
425425
}
426426
if (
427427
!fn
428-
|| !jsxUtil.isReturningJSX((n) => isCreateElement(n, context), node, context)
428+
|| !jsxUtil.isReturningJSX((n) => isCreateElement(n, context), node, context, true)
429429
) {
430430
return;
431431
}

tests/lib/rules/jsx-indent.js

+10
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,16 @@ const Component = () => (
12091209
features: ['class fields'],
12101210
options: [2],
12111211
},
1212+
{
1213+
code: `
1214+
function test (foo) {
1215+
return foo != null
1216+
? Math.max(0, Math.min(1, 10))
1217+
: 0
1218+
}
1219+
`,
1220+
options: [99],
1221+
},
12121222
]),
12131223

12141224
invalid: parsers.all([].concat(

0 commit comments

Comments
 (0)