diff --git a/lib/rules/no-classname-with-stylename.js b/lib/rules/no-classname-with-stylename.js
index 188b99e..1c20fcf 100644
--- a/lib/rules/no-classname-with-stylename.js
+++ b/lib/rules/no-classname-with-stylename.js
@@ -38,14 +38,16 @@ module.exports = {
return {
"JSXOpeningElement": function (node) {
+ console.log(node.attributes);
+
const hasClassNameWithoutExpr = node.attributes.some((attr) => (
- attr.type === "JSXIdentifier" && attr.name.name === "className" &&
+ attr.name.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");
+ const hasStyleName = node.attributes.some((attr) => attr.name.type === "JSXIdentifier" && attr.name.name === "styleName");
if (hasClassNameWithoutExpr && hasStyleName) {
- const nodeAttrClassName = node.attributes.find((attr) => attr.type === "JSXIdentifier" && attr.name.name === "className");
+ const nodeAttrClassName = node.attributes.find((attr) => attr.name.type === "JSXIdentifier" && attr.name.name === "className");
context.report(nodeAttrClassName, reportText);
}
}
diff --git a/tests/lib/rules/no-classname-with-stylename.js b/tests/lib/rules/no-classname-with-stylename.js
index 39a5e07..624fca0 100644
--- a/tests/lib/rules/no-classname-with-stylename.js
+++ b/tests/lib/rules/no-classname-with-stylename.js
@@ -21,7 +21,8 @@ var ruleTester = new RuleTester({
parserOptions: {
"ecmaFeatures": {
"jsx": true
- }
+ },
+ ecmaVersion: 7,
}
});
ruleTester.run("no-classname-with-stylename", rule, {
@@ -30,6 +31,8 @@ ruleTester.run("no-classname-with-stylename", rule, {
"",
"",
"",
+ "",
+ "",
"",
""
// give me some code that won't trigger a warning
@@ -53,6 +56,19 @@ ruleTester.run("no-classname-with-stylename", rule, {
errors: [{
// message: "Disallow string className alongwith styleName in the same JSX tag",
}]
+ },
+ {
+ code: "",
+ errors: [{
+ // message: "Disallow string className alongwith styleName in the same JSX tag",
+ }]
+ },
+ {
+ code: "",
+ errors: [{
+ // message: "Disallow string className alongwith styleName in the same JSX tag",
+ }]
}
+
]
});