@@ -2,6 +2,7 @@ import type { TSESTree } from '@typescript-eslint/utils'
2
2
import { type Rule , createRule } from '../utils'
3
3
import { isInPandaFunction , isPandaAttribute , isPandaProp , isRecipeVariant } from '../utils/helpers'
4
4
import {
5
+ isArrayExpression ,
5
6
isIdentifier ,
6
7
isJSXExpressionContainer ,
7
8
isLiteral ,
@@ -44,6 +45,9 @@ const rule: Rule = createRule({
44
45
45
46
// Don't warn for objects. Those are conditions
46
47
if ( isObjectExpression ( node . value . expression ) ) return
48
+ if ( isArrayExpression ( node . value . expression ) ) {
49
+ return checkElements ( node . value . expression , context )
50
+ }
47
51
48
52
if ( ! isPandaProp ( node , context ) ) return
49
53
@@ -53,6 +57,7 @@ const rule: Rule = createRule({
53
57
} )
54
58
} ,
55
59
60
+ // Dynamic properties
56
61
'Property[computed=true]' ( node : TSESTree . Property ) {
57
62
if ( ! isInPandaFunction ( node , context ) ) return
58
63
@@ -71,6 +76,9 @@ const rule: Rule = createRule({
71
76
72
77
// Don't warn for objects. Those are conditions
73
78
if ( isObjectExpression ( node . value ) ) return
79
+ if ( isArrayExpression ( node . value ) ) {
80
+ return checkElements ( node . value , context )
81
+ }
74
82
75
83
if ( ! isPandaAttribute ( node , context ) ) return
76
84
@@ -83,4 +91,17 @@ const rule: Rule = createRule({
83
91
} ,
84
92
} )
85
93
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
+
86
107
export default rule
0 commit comments