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({
8282 return tokens . length > 0
8383 }
8484
85+ const isCssVariable = ( value : string ) : boolean => {
86+ if ( ! value ) return false
87+ return value . trim ( ) . startsWith ( 'var(' )
88+ }
89+
8590 const isValidColorToken = ( value : string ) : boolean => {
8691 if ( ! value ) return false
8792 const [ colorToken , opacity ] = value . split ( '/' )
@@ -104,6 +109,7 @@ const rule: Rule = createRule({
104109 const checkColorValue = ( node : TSESTree . Node , value : string , attributeName : string ) => {
105110 if ( ! isColorAttribute ( attributeName ) ) return
106111 if ( isTokenFunctionUsed ( value ) ) return
112+ if ( isCssVariable ( value ) ) return
107113 if ( isValidColorToken ( value ) ) return
108114
109115 reportInvalidColor ( node , value )
Original file line number Diff line number Diff line change @@ -33,6 +33,38 @@ import { Circle } from './panda/jsx';
3333
3434function App ( ) {
3535 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)' } ) } /> ;
3668} `,
3769 } ,
3870]
You can’t perform that action at this time.
0 commit comments