Skip to content

Commit a9b9abb

Browse files
committed
Fix checking non styled props in panda dotted components
1 parent ab7a4f1 commit a9b9abb

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

plugin/src/utils/helpers.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,20 +145,17 @@ export const isPandaProp = (node: TSESTree.JSXAttribute, context: RuleContext<an
145145

146146
if (!jsxAncestor) return
147147

148-
if (
149-
isJSXMemberExpression(jsxAncestor.name) &&
150-
isJSXIdentifier(jsxAncestor.name.object) &&
151-
isPandaIsh(jsxAncestor.name.object.name, context)
152-
)
153-
return true
154-
else if (!isJSXIdentifier(jsxAncestor.name)) return
148+
// <styled.div /> && <Box />
149+
if (!isJSXMemberExpression(jsxAncestor.name) && !isJSXIdentifier(jsxAncestor.name)) return
150+
151+
const name = isJSXMemberExpression(jsxAncestor.name) ? (jsxAncestor.name.object as any).name : jsxAncestor.name.name
152+
const prop = node.name.name
155153

156154
// Ensure component is a panda component
157-
if (!isPandaIsh(jsxAncestor.name.name, context) && !isLocalStyledFactory(jsxAncestor, context)) return
155+
if (!isPandaIsh(name, context) && !isLocalStyledFactory(jsxAncestor, context)) return
158156

159157
// Ensure prop is a styled prop
160-
const prop = node.name.name
161-
if (typeof prop !== 'string' || !isValidProperty(prop, context, jsxAncestor.name.name)) return
158+
if (typeof prop !== 'string' || !isValidProperty(prop, context, name)) return
162159

163160
return true
164161
}

0 commit comments

Comments
 (0)