Skip to content

Commit 86d8aab

Browse files
committed
Ignore no-unsafe-token-fn-usage rule in css variables
Closes #68
1 parent 09dc585 commit 86d8aab

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

.changeset/slimy-cougars-press.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@pandacss/eslint-plugin": patch
3+
---
4+
5+
Ignore `no-unsafe-token-fn-usage` rule in css variables

plugin/src/rules/no-unsafe-token-fn-usage.ts

+2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ const rule: Rule = createRule({
107107
},
108108

109109
Property(node) {
110+
// Ignore css variables
111+
if (isLiteral(node.key) && node.key.value?.toString().startsWith('--')) return
110112
if (!isCallExpression(node.value) && !isLiteral(node.value) && !isTemplateLiteral(node.value)) return
111113
if (!isPandaAttribute(node, context)) return
112114

plugin/src/utils/helpers.ts

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ const isValidStyledProp = <T extends Node | string>(node: T, context: RuleContex
9898

9999
export const isPandaIsh = (name: string, context: RuleContext<any, any>) => {
100100
const imports = getImports(context)
101+
if (imports.length === 0) return false
101102
return syncAction('matchFile', getSyncOpts(context), name, imports)
102103
}
103104

plugin/tests/no-unsafe-token-fn-usage.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ function App(){
2929
return <Circle _hover={{ border: 'solid 1px {colors.blue.400}' }} />;
3030
}`,
3131
},
32+
{
33+
code: javascript`
34+
import { css } from './panda/css';
35+
36+
const styles = css({ '--my-var': '{spacing.8}' })`,
37+
},
3238
]
3339

3440
const invalids = [

0 commit comments

Comments
 (0)