Skip to content

Commit

Permalink
[Fix] jsx-boolean-value: assumeUndefinedIsFalse with never must not a…
Browse files Browse the repository at this point in the history
…llow explicit true value
  • Loading branch information
6uliver committed May 14, 2024
1 parent d97e3ed commit 0702c9a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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

0 comments on commit 0702c9a

Please sign in to comment.