@@ -79,8 +79,11 @@ const _getImports = (context: RuleContext<any, any>) => {
79
79
80
80
const getImports = ( context : RuleContext < any , any > ) => {
81
81
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
+ }
84
87
}
85
88
86
89
const isValidStyledProp = < T extends Node | string > ( node : T , context : RuleContext < any , any > ) => {
@@ -153,7 +156,7 @@ export const isPandaProp = (node: TSESTree.JSXAttribute, context: RuleContext<an
153
156
return true
154
157
}
155
158
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 ) => {
157
160
if ( ! isIdentifier ( node . key ) && ! isLiteral ( node . key ) && ! isTemplateLiteral ( node . key ) ) return
158
161
159
162
if ( isIdentifier ( node . key ) && ! isValidProperty ( node . key . name , context , calleeName ) ) return
@@ -168,6 +171,16 @@ export const isStyledProperty = (node: TSESTree.Property, context: RuleContext<a
168
171
return true
169
172
}
170
173
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
+
171
184
export const isInPandaFunction = ( node : TSESTree . Property , context : RuleContext < any , any > ) => {
172
185
const callAncestor = getAncestor ( isCallExpression , node )
173
186
if ( ! callAncestor ) return
0 commit comments