@@ -2,6 +2,7 @@ import type { TSESTree } from '@typescript-eslint/utils'
22import { type Rule , createRule } from '../utils'
33import { isInPandaFunction , isPandaAttribute , isPandaProp , isRecipeVariant } from '../utils/helpers'
44import {
5+ isArrayExpression ,
56 isIdentifier ,
67 isJSXExpressionContainer ,
78 isLiteral ,
@@ -44,6 +45,9 @@ const rule: Rule = createRule({
4445
4546 // Don't warn for objects. Those are conditions
4647 if ( isObjectExpression ( node . value . expression ) ) return
48+ if ( isArrayExpression ( node . value . expression ) ) {
49+ return checkElements ( node . value . expression , context )
50+ }
4751
4852 if ( ! isPandaProp ( node , context ) ) return
4953
@@ -53,6 +57,7 @@ const rule: Rule = createRule({
5357 } )
5458 } ,
5559
60+ // Dynamic properties
5661 'Property[computed=true]' ( node : TSESTree . Property ) {
5762 if ( ! isInPandaFunction ( node , context ) ) return
5863
@@ -71,6 +76,9 @@ const rule: Rule = createRule({
7176
7277 // Don't warn for objects. Those are conditions
7378 if ( isObjectExpression ( node . value ) ) return
79+ if ( isArrayExpression ( node . value ) ) {
80+ return checkElements ( node . value , context )
81+ }
7482
7583 if ( ! isPandaAttribute ( node , context ) ) return
7684
@@ -83,4 +91,17 @@ const rule: Rule = createRule({
8391 } ,
8492} )
8593
94+ function checkElements ( array : TSESTree . ArrayExpression , context : Parameters < ( typeof rule ) [ 'create' ] > [ 0 ] ) {
95+ array . elements . forEach ( ( node ) => {
96+ if ( ! node ) return
97+ if ( isLiteral ( node ) ) return
98+ if ( isTemplateLiteral ( node ) && node . expressions . length === 0 ) return
99+
100+ context . report ( {
101+ node : node ,
102+ messageId : 'dynamic' ,
103+ } )
104+ } )
105+ }
106+
86107export default rule
0 commit comments