Skip to content
Open
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
4 changes: 2 additions & 2 deletions packages/plugin-utils/src/regexes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export const regexClassSplitter = /[\s'"`{}]/g
export const regexClassGroup = /([!\w+-<@][\w+:_/-]*?\w):\(((?:[!\w\s:/\\,%#.$-]|\[.*?\])*?)\)/gm
export const regexAttributifyItem = /(?:\s|^)([\w+:_/-]+)\s?=\s?(['"{])((?:\\\2|\\\\|\n|\r|.)*?)(?:\2|\})/gm

export const regexClassCheck1 = /^!?[a-z\d@<>.+-](?:\([\w,.%#\(\)+-]*\)|[\w:/\\,%#\[\].$-])*$/
export const regexClassCheck2 = /[a-z].*[\w)\]]$/
export const regexClassCheck1 = /^!?[a-zA-Z\d@<>.+-](?:\([\w,.%#\(\)+-]*\)|[\w:/\\,%#\[\].$-])*$/
export const regexClassCheck2 = /[a-zA-Z].*[\w)\]]$/
export const regexClassChecks = [
regexClassCheck1,
regexClassCheck2,
Expand Down
18 changes: 18 additions & 0 deletions test/__snapshots__/examples.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Set {
"select-none",
"<html",
"<meta",
"UTF-8",
"viewport",
"<div",
"app",
Expand All @@ -36,9 +37,13 @@ Set {
"module",
"setup",
"import",
"Foo",
"from",
"./Foo.vue",
"Windi",
"CSS",
"with",
"Vite",
"px-5",
"p-1",
"text-white",
Expand All @@ -47,15 +52,21 @@ Set {
"bg-teal-100",
"hover:w-1/3",
"true",
"Hello",
"World",
"<h2",
"btn",
"Button",
"bar",
"Bar",
"<Foo",
"<router-link",
"bg-black",
"bg-blue-200",
"bg-red-200",
"Without",
"!bg-blue-200",
"With",
"<style",
"postcss",
".bar",
Expand All @@ -66,9 +77,13 @@ Set {
"stylus",
"pl-100px",
"bg-yellow-200",
"Should",
"Yellow",
"mt-2",
"None",
"createApp",
"vue",
"App",
"./App.vue",
"virtual:windi-base.css",
"virtual:windi-components.css",
Expand All @@ -80,8 +95,11 @@ Set {
"path",
"defineConfig",
"vite",
"Vue",
"@vitejs/plugin-vue",
"WindiCSS",
"vite-plugin-windicss",
"Restart",
"vite-plugin-restart",
"export",
"default",
Expand Down
1 change: 1 addition & 0 deletions test/regex.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('regex', () => {
expect(validClassName('!-sm:w-full')).toBeTruthy()
expect(validClassName('!@sm:w-full')).toBeTruthy()
expect(validClassName('p-[calc(10px+12rem)]')).toBeTruthy()
expect(validClassName('Uppercase-Class-Name')).toBeTruthy()

// falsy
expect(validClassName('')).toBeFalsy()
Expand Down