Skip to content

Commit eab7bbf

Browse files
1 parent 62ebc72 commit eab7bbf

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/util/attr.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ function isSingleLine(str) {
3232
*/
3333
function getClassNamesFromAttribute(attrVal, trim = true) {
3434
let classNames = [];
35-
if (attrVal === undefined || attrVal === null || attrVal.length === 0) {
35+
const valid = typeof attrVal === 'string' && attrVal.length;
36+
if (!valid) {
3637
return classNames;
3738
}
3839
if (isSingleLine(attrVal)) {

tests/lib/rules/no-custom-classname.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,16 @@ ruleTester.run("no-custom-classname", rule, {
496496
code: `
497497
<div className={'!hidden sm:!flex lg:!block 2xl:!block'}>Important modifier</div>`,
498498
},
499+
{
500+
code: `
501+
<button
502+
type="button"
503+
className={classnames(
504+
"p-2 font-medium",
505+
boolVal ? false : "text-black"
506+
)}
507+
/>`,
508+
},
499509
],
500510

501511
invalid: [

0 commit comments

Comments
 (0)