From 0702c9aede90ac3c59903ec2e4912f2430632229 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20N=C3=A9meth?= Date: Tue, 14 May 2024 10:54:14 +0200 Subject: [PATCH] [Fix] jsx-boolean-value: assumeUndefinedIsFalse with never must not allow explicit true value --- lib/rules/jsx-boolean-value.js | 1 - tests/lib/rules/jsx-boolean-value.js | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/rules/jsx-boolean-value.js b/lib/rules/jsx-boolean-value.js index 1cff171147..4572e7ff8d 100644 --- a/lib/rules/jsx-boolean-value.js +++ b/lib/rules/jsx-boolean-value.js @@ -132,7 +132,6 @@ module.exports = { } if ( isNever(configuration, exceptions, propName) - && !configObject.assumeUndefinedIsFalse && value && value.type === 'JSXExpressionContainer' && value.expression.value === true diff --git a/tests/lib/rules/jsx-boolean-value.js b/tests/lib/rules/jsx-boolean-value.js index e8cbbb3e7f..f4216f2ce1 100644 --- a/tests/lib/rules/jsx-boolean-value.js +++ b/tests/lib/rules/jsx-boolean-value.js @@ -52,6 +52,10 @@ ruleTester.run('jsx-boolean-value', rule, { code: ';', options: ['never', { assumeUndefinedIsFalse: true }], }, + { + code: ';', + options: ['never', { assumeUndefinedIsFalse: false }], + }, { code: ';', options: ['never', { assumeUndefinedIsFalse: true, always: ['foo'] }], @@ -145,6 +149,21 @@ ruleTester.run('jsx-boolean-value', rule, { }, ], }, + { + code: ';', + output: ';', + options: ['never', { assumeUndefinedIsFalse: true }], + errors: [ + { + messageId: 'omitBoolean', + data: { propName: 'foo' }, + }, + { + messageId: 'omitPropAndBoolean', + data: { propName: 'bak' }, + }, + ], + }, { code: ';', output: ';',