Skip to content

Commit 3551e7d

Browse files
committed
Fix message port error
1 parent 72bfeb5 commit 3551e7d

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

.changeset/strange-beers-care.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pandacss/eslint-plugin": patch
3+
---
4+
5+
Fix messagePort error

plugin/src/utils/helpers.ts

+16-3
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,11 @@ const _getImports = (context: RuleContext<any, any>) => {
7979

8080
const 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

8689
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
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+
171184
export const isInPandaFunction = (node: TSESTree.Property, context: RuleContext<any, any>) => {
172185
const callAncestor = getAncestor(isCallExpression, node)
173186
if (!callAncestor) return

0 commit comments

Comments
 (0)