Skip to content

Commit 92a1200

Browse files
committed
chore: update panda
1 parent 1aae388 commit 92a1200

File tree

8 files changed

+812
-478
lines changed

8 files changed

+812
-478
lines changed

fixture/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
"deps": "pnpm up '@pandacss/*' --latest"
1111
},
1212
"devDependencies": {
13-
"@pandacss/config": "^0.31.0",
14-
"@pandacss/core": "^0.31.0",
15-
"@pandacss/generator": "^0.31.0",
16-
"@pandacss/node": "^0.31.0",
17-
"@pandacss/preset-base": "^0.31.0",
18-
"@pandacss/preset-panda": "^0.31.0",
19-
"@pandacss/shared": "^0.31.0",
20-
"@pandacss/token-dictionary": "^0.31.0",
21-
"@pandacss/types": "^0.31.0",
13+
"@pandacss/config": "^0.39.1",
14+
"@pandacss/core": "^0.39.1",
15+
"@pandacss/generator": "^0.39.1",
16+
"@pandacss/node": "^0.39.1",
17+
"@pandacss/preset-base": "^0.39.1",
18+
"@pandacss/preset-panda": "^0.39.1",
19+
"@pandacss/shared": "^0.39.1",
20+
"@pandacss/token-dictionary": "^0.39.1",
21+
"@pandacss/types": "^0.39.1",
2222
"postcss": "^8.4.33"
2323
}
2424
}

plugin/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
"dist"
3434
],
3535
"dependencies": {
36-
"@pandacss/config": "^0.31.0",
37-
"@pandacss/generator": "^0.31.0",
38-
"@pandacss/node": "^0.31.0",
39-
"@pandacss/shared": "^0.31.0",
36+
"@pandacss/config": "^0.39.1",
37+
"@pandacss/generator": "^0.39.1",
38+
"@pandacss/node": "^0.39.1",
39+
"@pandacss/shared": "^0.39.1",
4040
"@typescript-eslint/utils": "^6.19.1",
4141
"hookable": "^5.5.3",
4242
"synckit": "^0.9.0"

plugin/src/rules/no-invalid-token-paths.ts

Lines changed: 25 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
import { getInvalidTokens, isPandaAttribute, isPandaIsh, isPandaProp } from '../utils/helpers'
1+
import { getInvalidTokens, getTaggedTemplateCaller, isPandaAttribute, isPandaIsh, isPandaProp } from '../utils/helpers'
22
import { type Rule, createRule } from '../utils'
33
import { AST_NODE_TYPES } from '@typescript-eslint/utils'
44
import { isNodeOfTypes } from '@typescript-eslint/utils/ast-utils'
5-
import {
6-
isCallExpression,
7-
isIdentifier,
8-
isJSXExpressionContainer,
9-
isLiteral,
10-
isMemberExpression,
11-
isTemplateLiteral,
12-
type Node,
13-
} from '../utils/nodes'
5+
import { isIdentifier, isJSXExpressionContainer, isLiteral, isTemplateLiteral, type Node } from '../utils/nodes'
146

157
export const RULE_NAME = 'no-invalid-token-paths'
168

@@ -78,51 +70,35 @@ const rule: Rule = createRule({
7870
},
7971

8072
TaggedTemplateExpression(node) {
81-
const handleExpression = (caller: string) => {
82-
if (!isPandaIsh(caller, context)) return
73+
const caller = getTaggedTemplateCaller(node)
74+
if (!caller) return
8375

84-
const quasis = node.quasi.quasis[0]
85-
const styles = quasis.value.raw
86-
const tokens = getInvalidTokens(styles, context)
76+
if (!isPandaIsh(caller, context)) return
8777

88-
tokens.forEach((token, i, arr) => {
89-
// Avoid duplicate reports on the same token
90-
if (arr.indexOf(token) < i) return
78+
const quasis = node.quasi.quasis[0]
79+
const styles = quasis.value.raw
80+
const tokens = getInvalidTokens(styles, context)
9181

92-
let index = styles.indexOf(token)
82+
tokens.forEach((token, i, arr) => {
83+
// Avoid duplicate reports on the same token
84+
if (arr.indexOf(token) < i) return
9385

94-
while (index !== -1) {
95-
const start = quasis.range[0] + 1 + index
96-
const end = start + token.length
86+
let index = styles.indexOf(token)
9787

98-
context.report({
99-
loc: { start: context.sourceCode.getLocFromIndex(start), end: context.sourceCode.getLocFromIndex(end) },
100-
messageId: 'noInvalidTokenPaths',
101-
data: { token },
102-
})
88+
while (index !== -1) {
89+
const start = quasis.range[0] + 1 + index
90+
const end = start + token.length
10391

104-
// Check for other occurences of the invalid token
105-
index = styles.indexOf(token, index + 1)
106-
}
107-
})
108-
}
109-
110-
// css``
111-
if (isIdentifier(node.tag)) {
112-
handleExpression(node.tag.name)
113-
}
114-
115-
// styled.h1``
116-
if (isMemberExpression(node.tag)) {
117-
if (!isIdentifier(node.tag.object)) return
118-
handleExpression(node.tag.object.name)
119-
}
120-
121-
// styled(Comp)``
122-
if (isCallExpression(node.tag)) {
123-
if (!isIdentifier(node.tag.callee)) return
124-
handleExpression(node.tag.callee.name)
125-
}
92+
context.report({
93+
loc: { start: context.sourceCode.getLocFromIndex(start), end: context.sourceCode.getLocFromIndex(end) },
94+
messageId: 'noInvalidTokenPaths',
95+
data: { token },
96+
})
97+
98+
// Check for other occurences of the invalid token
99+
index = styles.indexOf(token, index + 1)
100+
}
101+
})
126102
},
127103
}
128104
},

plugin/src/utils/helpers.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,22 @@ export const getTokenImport = (context: RuleContext<any, any>) => {
266266
const imports = _getImports(context)
267267
return imports.find((imp) => imp.name === 'token')
268268
}
269+
270+
export const getTaggedTemplateCaller = (node: TSESTree.TaggedTemplateExpression) => {
271+
// css``
272+
if (isIdentifier(node.tag)) {
273+
return node.tag.name
274+
}
275+
276+
// styled.h1``
277+
if (isMemberExpression(node.tag)) {
278+
if (!isIdentifier(node.tag.object)) return
279+
return node.tag.object.name
280+
}
281+
282+
// styled(Comp)``
283+
if (isCallExpression(node.tag)) {
284+
if (!isIdentifier(node.tag.callee)) return
285+
return node.tag.callee.name
286+
}
287+
}

0 commit comments

Comments
 (0)