From ea9b523ef11d39deae402ffafc15f85d0743b0e6 Mon Sep 17 00:00:00 2001 From: anubra266 Date: Mon, 25 Nov 2024 17:01:53 -0800 Subject: [PATCH] fix token extraction --- .changeset/cool-waves-enjoy.md | 5 +++++ plugin/src/utils/helpers.ts | 2 +- plugin/tests/_parsing.test.ts | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/cool-waves-enjoy.md diff --git a/.changeset/cool-waves-enjoy.md b/.changeset/cool-waves-enjoy.md new file mode 100644 index 0000000..20312dd --- /dev/null +++ b/.changeset/cool-waves-enjoy.md @@ -0,0 +1,5 @@ +--- +'@pandacss/eslint-plugin': patch +--- + +Fix token extraction diff --git a/plugin/src/utils/helpers.ts b/plugin/src/utils/helpers.ts index 2f4104a..62232f9 100644 --- a/plugin/src/utils/helpers.ts +++ b/plugin/src/utils/helpers.ts @@ -248,7 +248,7 @@ export const isColorToken = (value: string | undefined, context: RuleContext() export const extractTokens = (value: string) => { - const regex = /token\(([^"'(),]+)(?:,\s*([^"'(),]+))?\)|\{([^{}]+)\}/g + const regex = /token\(([^"'(),]+)(?:,\s*([^"'(),]+))?\)|\{([^{\r\n}]+)\}/g const matches = [] let match diff --git a/plugin/tests/_parsing.test.ts b/plugin/tests/_parsing.test.ts index 9bf5525..581a43d 100644 --- a/plugin/tests/_parsing.test.ts +++ b/plugin/tests/_parsing.test.ts @@ -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 = [