Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix token extraction #188

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cool-waves-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@pandacss/eslint-plugin': patch
---

Fix token extraction
2 changes: 1 addition & 1 deletion plugin/src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export const isColorToken = (value: string | undefined, context: RuleContext<any
const invalidTokensCache = new Map<string, string[]>()

export const extractTokens = (value: string) => {
const regex = /token\(([^"'(),]+)(?:,\s*([^"'(),]+))?\)|\{([^{}]+)\}/g
const regex = /token\(([^"'(),]+)(?:,\s*([^"'(),]+))?\)|\{([^{\r\n}]+)\}/g
const matches = []
let match

Expand Down
5 changes: 5 additions & 0 deletions plugin/tests/_parsing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ const valids5 = [
'const className = css`\n font-size: {fontSizes.md};`',
'const className = styled.h1`\n font-size: {fontSizes.md};`',
'const className = styled(Circle)`\n font-size: {fontSizes.md};`',
`const className = css\`\n
@media (min-width: token(breakpoints.lg)) {
grid-template-columns: auto 450px;
}
\``,
]

const invalids5 = [
Expand Down