File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,11 @@ const rule: Rule = createRule({
82
82
return tokens . length > 0
83
83
}
84
84
85
+ const isCssVariable = ( value : string ) : boolean => {
86
+ if ( ! value ) return false
87
+ return value . trim ( ) . startsWith ( 'var(' )
88
+ }
89
+
85
90
const isValidColorToken = ( value : string ) : boolean => {
86
91
if ( ! value ) return false
87
92
const [ colorToken , opacity ] = value . split ( '/' )
@@ -104,6 +109,7 @@ const rule: Rule = createRule({
104
109
const checkColorValue = ( node : TSESTree . Node , value : string , attributeName : string ) => {
105
110
if ( ! isColorAttribute ( attributeName ) ) return
106
111
if ( isTokenFunctionUsed ( value ) ) return
112
+ if ( isCssVariable ( value ) ) return
107
113
if ( isValidColorToken ( value ) ) return
108
114
109
115
reportInvalidColor ( node , value )
Original file line number Diff line number Diff line change @@ -33,6 +33,38 @@ import { Circle } from './panda/jsx';
33
33
34
34
function App ( ) {
35
35
return < Circle _hover = { { borderColor : 'gray.100' } } /> ;
36
+ } `,
37
+ } ,
38
+
39
+ {
40
+ code : javascript `
41
+ import { css } from './panda/css' ;
42
+
43
+ const styles = css ( { color : 'var(--my-color)' } ) `,
44
+ } ,
45
+
46
+ {
47
+ code : javascript `
48
+ import { css } from './panda/css' ;
49
+
50
+ const styles = css ( { backgroundColor : 'var(--bg-color)' } ) `,
51
+ } ,
52
+
53
+ {
54
+ code : javascript `
55
+ import { Circle } from './panda/jsx' ;
56
+
57
+ function App ( ) {
58
+ return < Circle borderColor = 'var(--border-color)' /> ;
59
+ } `,
60
+ } ,
61
+
62
+ {
63
+ code : javascript `
64
+ import { css } from './panda/css' ;
65
+
66
+ function App ( ) {
67
+ return < div className = { css ( { color : 'var(--text-primary)' } ) } /> ;
36
68
} `,
37
69
} ,
38
70
]
You can’t perform that action at this time.
0 commit comments