@@ -79,8 +79,11 @@ const _getImports = (context: RuleContext<any, any>) => {
7979
8080const getImports = ( context : RuleContext < any , any > ) => {
8181 const imports = _getImports ( context )
82-
83- return imports . filter ( ( imp ) => syncAction ( 'matchImports' , getSyncOpts ( context ) , imp ) )
82+ try {
83+ return imports . filter ( ( imp ) => syncAction ( 'matchImports' , getSyncOpts ( context ) , imp ) )
84+ } catch ( error ) {
85+ return [ ]
86+ }
8487}
8588
8689const isValidStyledProp = < T extends Node | string > ( node : T , context : RuleContext < any , any > ) => {
@@ -153,7 +156,7 @@ export const isPandaProp = (node: TSESTree.JSXAttribute, context: RuleContext<an
153156 return true
154157}
155158
156- export const isStyledProperty = ( node : TSESTree . Property , context : RuleContext < any , any > , calleeName ?: string ) => {
159+ export const isStyledNode = ( node : TSESTree . Property , context : RuleContext < any , any > , calleeName ?: string ) => {
157160 if ( ! isIdentifier ( node . key ) && ! isLiteral ( node . key ) && ! isTemplateLiteral ( node . key ) ) return
158161
159162 if ( isIdentifier ( node . key ) && ! isValidProperty ( node . key . name , context , calleeName ) ) return
@@ -168,6 +171,16 @@ export const isStyledProperty = (node: TSESTree.Property, context: RuleContext<a
168171 return true
169172}
170173
174+ export const isStyledProperty = ( node : TSESTree . Property , context : RuleContext < any , any > , calleeName ?: string ) => {
175+ const ancestor = node . parent . parent
176+
177+ const isValidFuncAncestor =
178+ isCallExpression ( ancestor ) && isIdentifier ( ancestor . callee ) && isPandaIsh ( ancestor . callee . name , context )
179+ if ( isValidFuncAncestor ) return isStyledNode ( node , context , calleeName )
180+
181+ return isStyledNode ( ancestor as any , context , calleeName ) && isStyledNode ( node , context , calleeName )
182+ }
183+
171184export const isInPandaFunction = ( node : TSESTree . Property , context : RuleContext < any , any > ) => {
172185 const callAncestor = getAncestor ( isCallExpression , node )
173186 if ( ! callAncestor ) return
0 commit comments