From 0468fbe8f9dd390392f803a55bed0dd9a601c508 Mon Sep 17 00:00:00 2001 From: Abhas Date: Mon, 24 Sep 2018 20:16:05 +0530 Subject: [PATCH] Fix issue with attr of type JSXSpreadAttribute --- lib/rules/no-classname-with-stylename.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/rules/no-classname-with-stylename.js b/lib/rules/no-classname-with-stylename.js index 221a52c..188b99e 100644 --- a/lib/rules/no-classname-with-stylename.js +++ b/lib/rules/no-classname-with-stylename.js @@ -38,11 +38,14 @@ module.exports = { return { "JSXOpeningElement": function (node) { - const hasClassNameWithoutExpr = node.attributes.some((attr) => attr.name.name === "className" && (attr.value === null || attr.value.type !== 'JSXExpressionContainer')) - const hasStyleName = node.attributes.some((attr) => attr.name.name === "styleName"); + const hasClassNameWithoutExpr = node.attributes.some((attr) => ( + attr.type === "JSXIdentifier" && attr.name.name === "className" && + (attr.value === null || attr.value.type !== 'JSXExpressionContainer') + )); + const hasStyleName = node.attributes.some((attr) => attr.type === "JSXIdentifier" && attr.name.name === "styleName"); if (hasClassNameWithoutExpr && hasStyleName) { - const nodeAttrClassName = node.attributes.find((attr) => attr.name.name === "className"); + const nodeAttrClassName = node.attributes.find((attr) => attr.type === "JSXIdentifier" && attr.name.name === "className"); context.report(nodeAttrClassName, reportText); } }