From 18216a329589943f65b44fbbca927b21d83f59e9 Mon Sep 17 00:00:00 2001 From: zbeyens Date: Fri, 2 Feb 2024 14:49:36 +0100 Subject: [PATCH 1/3] fix --- packages/cli/src/utils/templates.ts | 4 +- .../utils/transformers/transform-tw-prefix.ts | 50 +++++++++---------- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/packages/cli/src/utils/templates.ts b/packages/cli/src/utils/templates.ts index eaa9bf3c94..80f2126b7c 100644 --- a/packages/cli/src/utils/templates.ts +++ b/packages/cli/src/utils/templates.ts @@ -17,7 +17,7 @@ module.exports = { './app/**/*.{ts,tsx}', './src/**/*.{ts,tsx}', ], - prefix: "<%- prefix %>", + prefix: '<%- prefix %>', theme: { container: { center: true, @@ -55,7 +55,7 @@ module.exports = { './app/**/*.{ts,tsx}', './src/**/*.{ts,tsx}', ], - prefix: "<%- prefix %>", + prefix: '<%- prefix %>', theme: { container: { center: true, diff --git a/packages/cli/src/utils/transformers/transform-tw-prefix.ts b/packages/cli/src/utils/transformers/transform-tw-prefix.ts index ad0738ebee..20d2ab697c 100644 --- a/packages/cli/src/utils/transformers/transform-tw-prefix.ts +++ b/packages/cli/src/utils/transformers/transform-tw-prefix.ts @@ -21,10 +21,10 @@ export const transformTwPrefixes: Transformer = async ({ const defaultClassNames = node.getArguments()[0]; if (defaultClassNames) { defaultClassNames.replaceWithText( - `"${applyPrefix( - defaultClassNames.getText()?.replace(/"/g, ''), + `'${applyPrefix( + defaultClassNames.getText()?.replace(/'/g, ''), config.tailwind.prefix - )}"` + )}'` ); } } @@ -45,10 +45,10 @@ export const transformTwPrefixes: Transformer = async ({ ); if (classNames) { classNames?.replaceWithText( - `"${applyPrefix( - classNames.getText()?.replace(/"/g, ''), + `'${applyPrefix( + classNames.getText()?.replace(/'/g, ''), config.tailwind.prefix - )}"` + )}'` ); } }); @@ -59,15 +59,15 @@ export const transformTwPrefixes: Transformer = async ({ // Find all jsx attributes with the name className. sourceFile.getDescendantsOfKind(SyntaxKind.JsxAttribute).forEach((node) => { if (node.getName() === 'className') { - // className="..." + // className='...' if (node.getInitializer()?.isKind(SyntaxKind.StringLiteral)) { const value = node.getInitializer(); if (value) { value.replaceWithText( - `"${applyPrefix( - value.getText()?.replace(/"/g, ''), + `'${applyPrefix( + value.getText()?.replace(/'/g, ''), config.tailwind.prefix - )}"` + )}'` ); } } @@ -90,20 +90,20 @@ export const transformTwPrefixes: Transformer = async ({ .getChildrenOfKind(SyntaxKind.StringLiteral) .forEach((node) => { node.replaceWithText( - `"${applyPrefix( - node.getText()?.replace(/"/g, ''), + `'${applyPrefix( + node.getText()?.replace(/'/g, ''), config.tailwind.prefix - )}"` + )}'` ); }); } if (node.isKind(SyntaxKind.StringLiteral)) { node.replaceWithText( - `"${applyPrefix( - node.getText()?.replace(/"/g, ''), + `'${applyPrefix( + node.getText()?.replace(/'/g, ''), config.tailwind.prefix - )}"` + )}'` ); } }); @@ -131,20 +131,20 @@ export const transformTwPrefixes: Transformer = async ({ .getChildrenOfKind(SyntaxKind.StringLiteral) .forEach((node) => { node.replaceWithText( - `"${applyPrefix( - node.getText()?.replace(/"/g, ''), + `'${applyPrefix( + node.getText()?.replace(/'/g, ''), config.tailwind.prefix - )}"` + )}'` ); }); } if (arg.isKind(SyntaxKind.StringLiteral)) { arg.replaceWithText( - `"${applyPrefix( - arg.getText()?.replace(/"/g, ''), + `'${applyPrefix( + arg.getText()?.replace(/'/g, ''), config.tailwind.prefix - )}"` + )}'` ); } }); @@ -158,10 +158,10 @@ export const transformTwPrefixes: Transformer = async ({ const classNames = node.getInitializer(); if (classNames) { classNames.replaceWithText( - `"${applyPrefix( - classNames.getText()?.replace(/"/g, ''), + `'${applyPrefix( + classNames.getText()?.replace(/'/g, ''), config.tailwind.prefix - )}"` + )}'` ); } } From 2f0af40c66eb146c8570ec151ed70a907d0f98ab Mon Sep 17 00:00:00 2001 From: Ziad Beyens Date: Fri, 2 Feb 2024 14:50:15 +0100 Subject: [PATCH 2/3] Create chatty-rocks-think.md --- .changeset/chatty-rocks-think.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/chatty-rocks-think.md diff --git a/.changeset/chatty-rocks-think.md b/.changeset/chatty-rocks-think.md new file mode 100644 index 0000000000..4a46070b85 --- /dev/null +++ b/.changeset/chatty-rocks-think.md @@ -0,0 +1,5 @@ +--- +"@udecode/plate-ui": patch +--- + +fix tw prefix From 5d98e0c7edb586af4582aee5cd524dcfae627325 Mon Sep 17 00:00:00 2001 From: zbeyens Date: Fri, 2 Feb 2024 14:56:16 +0100 Subject: [PATCH 3/3] fix --- .../utils/transformers/transform-tw-prefix.ts | 16 ++++++++-------- .../transform-tw-prefix.test.ts.snap | 6 +++--- .../cli/test/utils/transform-tw-prefix.test.ts | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/cli/src/utils/transformers/transform-tw-prefix.ts b/packages/cli/src/utils/transformers/transform-tw-prefix.ts index 20d2ab697c..b93ed33d62 100644 --- a/packages/cli/src/utils/transformers/transform-tw-prefix.ts +++ b/packages/cli/src/utils/transformers/transform-tw-prefix.ts @@ -22,7 +22,7 @@ export const transformTwPrefixes: Transformer = async ({ if (defaultClassNames) { defaultClassNames.replaceWithText( `'${applyPrefix( - defaultClassNames.getText()?.replace(/'/g, ''), + defaultClassNames.getText()?.replace(/'/g, '').replace(/"/g, ''), config.tailwind.prefix )}'` ); @@ -46,7 +46,7 @@ export const transformTwPrefixes: Transformer = async ({ if (classNames) { classNames?.replaceWithText( `'${applyPrefix( - classNames.getText()?.replace(/'/g, ''), + classNames.getText()?.replace(/'/g, '').replace(/"/g, ''), config.tailwind.prefix )}'` ); @@ -65,7 +65,7 @@ export const transformTwPrefixes: Transformer = async ({ if (value) { value.replaceWithText( `'${applyPrefix( - value.getText()?.replace(/'/g, ''), + value.getText()?.replace(/'/g, '').replace(/"/g, ''), config.tailwind.prefix )}'` ); @@ -91,7 +91,7 @@ export const transformTwPrefixes: Transformer = async ({ .forEach((node) => { node.replaceWithText( `'${applyPrefix( - node.getText()?.replace(/'/g, ''), + node.getText()?.replace(/'/g, '').replace(/"/g, ''), config.tailwind.prefix )}'` ); @@ -101,7 +101,7 @@ export const transformTwPrefixes: Transformer = async ({ if (node.isKind(SyntaxKind.StringLiteral)) { node.replaceWithText( `'${applyPrefix( - node.getText()?.replace(/'/g, ''), + node.getText()?.replace(/'/g, '').replace(/"/g, ''), config.tailwind.prefix )}'` ); @@ -132,7 +132,7 @@ export const transformTwPrefixes: Transformer = async ({ .forEach((node) => { node.replaceWithText( `'${applyPrefix( - node.getText()?.replace(/'/g, ''), + node.getText()?.replace(/'/g, '').replace(/"/g, ''), config.tailwind.prefix )}'` ); @@ -142,7 +142,7 @@ export const transformTwPrefixes: Transformer = async ({ if (arg.isKind(SyntaxKind.StringLiteral)) { arg.replaceWithText( `'${applyPrefix( - arg.getText()?.replace(/'/g, ''), + arg.getText()?.replace(/'/g, '').replace(/"/g, ''), config.tailwind.prefix )}'` ); @@ -159,7 +159,7 @@ export const transformTwPrefixes: Transformer = async ({ if (classNames) { classNames.replaceWithText( `'${applyPrefix( - classNames.getText()?.replace(/'/g, ''), + classNames.getText()?.replace(/'/g, '').replace(/"/g, ''), config.tailwind.prefix )}'` ); diff --git a/packages/cli/test/utils/__snapshots__/transform-tw-prefix.test.ts.snap b/packages/cli/test/utils/__snapshots__/transform-tw-prefix.test.ts.snap index 02f520133b..f9050118bc 100644 --- a/packages/cli/test/utils/__snapshots__/transform-tw-prefix.test.ts.snap +++ b/packages/cli/test/utils/__snapshots__/transform-tw-prefix.test.ts.snap @@ -3,7 +3,7 @@ exports[`transform tailwind prefix 1`] = ` "import * as React from \\"react\\" export function Foo() { - return
foo
+ return
foo
} " `; @@ -11,7 +11,7 @@ exports[`transform tailwind prefix 1`] = ` exports[`transform tailwind prefix 2`] = ` "import * as React from 'react' export function Foo() { - return
foo
+ return
foo
} " `; @@ -19,7 +19,7 @@ export function Foo() { exports[`transform tailwind prefix 3`] = ` "import * as React from 'react' export function Foo() { - return
foo
+ return
foo
} " `; diff --git a/packages/cli/test/utils/transform-tw-prefix.test.ts b/packages/cli/test/utils/transform-tw-prefix.test.ts index 8c994ed2e0..f630afa454 100644 --- a/packages/cli/test/utils/transform-tw-prefix.test.ts +++ b/packages/cli/test/utils/transform-tw-prefix.test.ts @@ -53,7 +53,7 @@ export function Foo() { filename: 'test.ts', raw: `import * as React from "react" export function Foo() { - return
foo
+ return
foo
} `, config: {