mirror of
https://github.com/bendtherules/eslint-plugin-no-classname-with-stylename.git
synced 2026-08-18 13:53:24 +00:00
Fix issue with attr of type JSXSpreadAttribute
This commit is contained in:
@@ -38,11 +38,14 @@ module.exports = {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
"JSXOpeningElement": function (node) {
|
"JSXOpeningElement": function (node) {
|
||||||
const hasClassNameWithoutExpr = node.attributes.some((attr) => attr.name.name === "className" && (attr.value === null || attr.value.type !== 'JSXExpressionContainer'))
|
const hasClassNameWithoutExpr = node.attributes.some((attr) => (
|
||||||
const hasStyleName = node.attributes.some((attr) => attr.name.name === "styleName");
|
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) {
|
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);
|
context.report(nodeAttrClassName, reportText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user