11import { Rule } from "eslint" ;
22import { JSXOpeningElement , JSXAttribute } from "estree-jsx" ;
33import { getFromPackage , checkMatchingJSXOpeningElement } from "../../helpers" ;
4+ import { getAttribute , getAttributeValue } from "../../helpers/JSXAttributes" ;
45
56// Rule to add hasAnimations prop to components that support animations
67module . exports = {
@@ -44,12 +45,7 @@ module.exports = {
4445
4546 // Helper function to check if isTree prop exists and isn't explicitly false
4647 function hasValidIsTreeProp ( node : JSXOpeningElement ) : boolean {
47- const isTreeAttribute = node . attributes . find (
48- ( attr ) =>
49- attr . type === "JSXAttribute" &&
50- attr . name . type === "JSXIdentifier" &&
51- attr . name . name === "isTree"
52- ) as JSXAttribute | undefined ;
48+ const isTreeAttribute = getAttribute ( node , "isTree" ) ;
5349
5450 if ( ! isTreeAttribute ) {
5551 return false ; // No isTree prop found
@@ -60,12 +56,12 @@ module.exports = {
6056 return true ;
6157 }
6258
59+ // Get the actual value using the helper
60+ const attributeValue = getAttributeValue ( context , isTreeAttribute . value ) ;
61+
6362 // Check for explicit false: isTree={false}
64- if ( isTreeAttribute . value . type === "JSXExpressionContainer" ) {
65- const expression = isTreeAttribute . value . expression ;
66- if ( expression . type === "Literal" && expression . value === false ) {
67- return false ;
68- }
63+ if ( attributeValue . type === "Literal" && attributeValue . value === false ) {
64+ return false ;
6965 }
7066
7167 // For anything else (including complex expressions), assume it could be truthy
0 commit comments