Fix JSXAttribute check

This commit is contained in:
Abhas
2018-09-24 20:58:25 +05:30
parent e54c0a47bc
commit 2c80322df6
+3 -5
View File
@@ -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);
}
}