@@ -125,6 +125,10 @@ export const isValidFile = (context: RuleContext<any, any>) => {
125125 return syncAction ( 'isValidFile' , getSyncOpts ( context ) )
126126}
127127
128+ export const isConfigFile = ( context : RuleContext < any , any > ) => {
129+ return syncAction ( 'isConfigFile' , getSyncOpts ( context ) )
130+ }
131+
128132export const isValidProperty = ( name : string , context : RuleContext < any , any > ) => {
129133 return syncAction ( 'isValidProperty' , getSyncOpts ( context ) , name )
130134}
@@ -134,7 +138,11 @@ export const isPandaImport = (node: TSESTree.ImportDeclaration, context: RuleCon
134138 return imports . some ( ( imp ) => imp . mod === node . source . value )
135139}
136140
137- export const isPandaProp = < T extends Node > ( node : T , context : RuleContext < any , any > ) => {
141+ export const isPandaProp = ( node : TSESTree . JSXAttribute , context : RuleContext < any , any > ) => {
142+ // Ensure prop is a styled prop
143+ const prop = node . name . name
144+ if ( typeof prop !== 'string' || ! isValidProperty ( prop , context ) ) return
145+
138146 const jsxAncestor = getAncestor ( isJSXOpeningElement , node )
139147
140148 if ( ! jsxAncestor ) return
@@ -149,10 +157,11 @@ export const isPandaProp = <T extends Node>(node: T, context: RuleContext<any, a
149157
150158 // Ensure component is a panda component
151159 if ( ! isPandaIsh ( jsxAncestor . name . name , context ) && ! isLocalStyledFactory ( jsxAncestor , context ) ) return
160+
152161 return true
153162}
154163
155- export const isPandaAttribute = < T extends Node > ( node : T , context : RuleContext < any , any > ) => {
164+ export const isPandaAttribute = ( node : TSESTree . Property , context : RuleContext < any , any > ) => {
156165 const callAncestor = getAncestor ( isCallExpression , node )
157166
158167 // Object could be in JSX prop value i.e css prop or a pseudo
@@ -161,12 +170,17 @@ export const isPandaAttribute = <T extends Node>(node: T, context: RuleContext<a
161170 const jsxAttrAncestor = getAncestor ( isJSXAttribute , node )
162171
163172 if ( ! jsxExprAncestor || ! jsxAttrAncestor ) return
164- if ( ! isPandaProp ( jsxAttrAncestor . name , context ) ) return
173+ if ( ! isPandaProp ( jsxAttrAncestor , context ) ) return
165174 if ( ! isValidStyledProp ( jsxAttrAncestor . name , context ) ) return
166175
167176 return true
168177 }
169178
179+ // Ensure attribute is a styled attribute
180+ if ( ! isIdentifier ( node . key ) ) return
181+ const attr = node . key . name
182+ if ( ! isValidProperty ( attr , context ) ) return
183+
170184 // E.g. css({...})
171185 if ( isIdentifier ( callAncestor . callee ) ) {
172186 return isPandaIsh ( callAncestor . callee . name , context )
@@ -224,6 +238,10 @@ export const getInvalidTokens = (value: string, context: RuleContext<any, any>)
224238 return syncAction ( 'filterInvalidTokenz' , getSyncOpts ( context ) , tokens )
225239}
226240
241+ export const getExtendWarnings = ( context : RuleContext < any , any > ) => {
242+ return syncAction ( 'getExtendWarnings' , getSyncOpts ( context ) )
243+ }
244+
227245export const getTokenImport = ( context : RuleContext < any , any > ) => {
228246 const imports = _getImports ( context )
229247 return imports . find ( ( imp ) => imp . name === 'token' )
0 commit comments