From 2c80322df62beae402aa97a7450553af6988200f Mon Sep 17 00:00:00 2001 From: Abhas Date: Mon, 24 Sep 2018 20:58:25 +0530 Subject: [PATCH] Fix JSXAttribute check --- lib/rules/no-classname-with-stylename.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/rules/no-classname-with-stylename.js b/lib/rules/no-classname-with-stylename.js index 1c20fcf..00bf723 100644 --- a/lib/rules/no-classname-with-stylename.js +++ b/lib/rules/no-classname-with-stylename.js @@ -38,16 +38,14 @@ module.exports = { return { "JSXOpeningElement": function (node) { - console.log(node.attributes); - const hasClassNameWithoutExpr = node.attributes.some((attr) => ( - attr.name.type === "JSXIdentifier" && attr.name.name === "className" && + attr.type === "JSXAttribute" && attr.name.name === "className" && (attr.value === null || attr.value.type !== 'JSXExpressionContainer') )); - const hasStyleName = node.attributes.some((attr) => attr.name.type === "JSXIdentifier" && attr.name.name === "styleName"); + const hasStyleName = node.attributes.some((attr) => attr.type === "JSXAttribute" && attr.name.name === "styleName"); if (hasClassNameWithoutExpr && hasStyleName) { - const nodeAttrClassName = node.attributes.find((attr) => attr.name.type === "JSXIdentifier" && attr.name.name === "className"); + const nodeAttrClassName = node.attributes.find((attr) => attr.type === "JSXAttribute" && attr.name.name === "className"); context.report(nodeAttrClassName, reportText); } }