Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
### Fixed
* [`prop-types`]: null-check rootNode before calling getScope ([#3762][] @crnhrv)
* [`boolean-prop-naming`]: avoid a crash with a spread prop ([#3733][] @ljharb)
* [`jsx-boolean-value`]: `assumeUndefinedIsFalse` with `never` must not allow explicit `true` value ([#3757][] @6uliver)

[#3762]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3762
[#3757]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3757
[#3733]: https://github.com/jsx-eslint/eslint-plugin-react/issues/3733

## [7.34.2] - 2024.05.24
Expand Down
1 change: 0 additions & 1 deletion lib/rules/jsx-boolean-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ module.exports = {
}
if (
isNever(configuration, exceptions, propName)
&& !configObject.assumeUndefinedIsFalse
&& value
&& value.type === 'JSXExpressionContainer'
&& value.expression.value === true
Expand Down
19 changes: 19 additions & 0 deletions tests/lib/rules/jsx-boolean-value.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ ruleTester.run('jsx-boolean-value', rule, {
code: '<App />;',
options: ['never', { assumeUndefinedIsFalse: true }],
},
{
code: '<App foo={false} />;',
options: ['never', { assumeUndefinedIsFalse: false }],
},
{
code: '<App foo={false} />;',
options: ['never', { assumeUndefinedIsFalse: true, always: ['foo'] }],
Expand Down Expand Up @@ -145,6 +149,21 @@ ruleTester.run('jsx-boolean-value', rule, {
},
],
},
{
code: '<App foo={true} bak={false} />;',
output: '<App foo />;',
options: ['never', { assumeUndefinedIsFalse: true }],
errors: [
{
messageId: 'omitBoolean',
data: { propName: 'foo' },
},
{
messageId: 'omitPropAndBoolean',
data: { propName: 'bak' },
},
],
},
{
code: '<App foo={true} bar={false} baz={false} bak={false} />;',
output: '<App foo={true} bar={false} />;',
Expand Down