Skip to content

Commit faa5e88

Browse files
authored
Cleanup inconsistencies related to (regex) escapes (#19804)
This PR does some generic cleanup to the codebase. I'm playing with oxfmt and oxlint and noticed some unnecessary escapes. Might add these dependencies to the project later (and rolldown for building). But baby steps for now. ## Test plan 1. All tests should still pass
1 parent a4be983 commit faa5e88

12 files changed

Lines changed: 18 additions & 20 deletions

File tree

integrations/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ export async function fetchStyles(base: string, path = '/'): Promise<string> {
569569
let index = await fetch(`${base}${path}`)
570570
let html = await index.text()
571571

572-
let linkRegex = /<link rel="stylesheet" href="([a-zA-Z0-9\/_\.\?=%-]+)"/gi
572+
let linkRegex = /<link rel="stylesheet" href="([a-zA-Z0-9/_.?=%-]+)"/gi
573573
let styleRegex = /<style\b[^>]*>([\s\S]*?)<\/style>/gi
574574

575575
let stylesheets: string[] = []

integrations/vite/react-router.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ test('build mode', { fs: WORKSPACE }, async ({ spawn, exec, expect }) => {
196196

197197
let url = ''
198198
await process.onStdout((m) => {
199-
let match = /\[react-router-serve\]\s*(http.*)\ \/?/.exec(m)
199+
let match = /\[react-router-serve\]\s*(http.*) \/?/.exec(m)
200200
if (match) url = match[1]
201201
return url != ''
202202
})

integrations/vite/svelte.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ test(
101101
await fs.expectFileToContain(files[0][0], [
102102
candidate`underline`,
103103
'.global{color:var(--color-green-500,oklch(72.3% .219 149.579));animation:2s ease-in-out infinite globalKeyframes}',
104-
/\.local.svelte-.*\{color:var\(--color-red-500\,oklch\(63\.7% \.237 25\.331\)\);animation:2s ease-in-out infinite svelte-.*-localKeyframes\}/,
104+
/\.local.svelte-.*\{color:var\(--color-red-500,oklch\(63\.7% \.237 25\.331\)\);animation:2s ease-in-out infinite svelte-.*-localKeyframes\}/,
105105
/@keyframes globalKeyframes\{/,
106106
/@keyframes svelte-.*-localKeyframes\{/,
107107
])

packages/@tailwindcss-node/src/urls.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ function skipUrlReplacer(rawUrl: string, aliases?: string[]) {
154154
return (
155155
isExternalUrl(rawUrl) ||
156156
isDataUrl(rawUrl) ||
157-
!rawUrl[0].match(/[\.a-zA-Z0-9_]/) ||
157+
!rawUrl[0].match(/[.a-zA-Z0-9_]/) ||
158158
functionCallRE.test(rawUrl)
159159
)
160160
}

packages/@tailwindcss-postcss/src/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ test("`@import 'tailwindcss'` is replaced with the generated CSS", async () => {
4343
})
4444
expect(result.messages).toContainEqual({
4545
type: 'dir-dependency',
46-
dir: expect.stringMatching(/example-project[\/|\\]src$/g),
46+
dir: expect.stringMatching(/example-project[/|\\]src$/g),
4747
glob: expect.stringMatching(/^\*\*\/\*/g),
4848
parent: expect.any(String),
4949
plugin: expect.any(String),

packages/@tailwindcss-upgrade/src/codemods/config/migrate-postcss.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,16 @@ async function migratePostCSSJSConfig(configPath: string): Promise<{
136136
didRemovePostCSSImport: boolean
137137
} | null> {
138138
function isTailwindCSSPlugin(line: string) {
139-
return /['"]?tailwindcss['"]?\: ?\{\}/.test(line)
139+
return /['"]?tailwindcss['"]?: ?\{\}/.test(line)
140140
}
141141
function isPostCSSImportPlugin(line: string) {
142-
return /['"]?postcss-import['"]?\: ?\{\}/.test(line)
142+
return /['"]?postcss-import['"]?: ?\{\}/.test(line)
143143
}
144144
function isAutoprefixerPlugin(line: string) {
145-
return /['"]?autoprefixer['"]?\: ?\{\}/.test(line)
145+
return /['"]?autoprefixer['"]?: ?\{\}/.test(line)
146146
}
147147
function isTailwindCSSNestingPlugin(line: string) {
148-
return /['"]tailwindcss\/nesting['"]\: ?(\{\}|['"]postcss-nesting['"])/.test(line)
148+
return /['"]tailwindcss\/nesting['"]: ?(\{\}|['"]postcss-nesting['"])/.test(line)
149149
}
150150

151151
info('Migrating PostCSS configuration…')

packages/@tailwindcss-vite/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import * as vite from 'vite'
2424
const DEBUG = env.DEBUG
2525
const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/
2626
const COMMON_JS_PROXY_RE = /\?commonjs-proxy/
27-
const INLINE_STYLE_ID_RE = /[?&]index\=\d+\.css$/
27+
const INLINE_STYLE_ID_RE = /[?&]index=\d+\.css$/
2828

2929
export type PluginOptions = {
3030
/**
@@ -415,7 +415,7 @@ class Root {
415415
// crash Vite. We work around this for now by ignoring updates to them.
416416
//
417417
// https://github.com/tailwindlabs/tailwindcss/issues/16877
418-
if (/[\#\?].*\.svg$/.test(file)) {
418+
if (/[#?].*\.svg$/.test(file)) {
419419
return
420420
}
421421
_addWatchFile(file)

packages/tailwindcss/src/candidate.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2043,8 +2043,6 @@ const candidates = [
20432043
['bg-[var(--spacing)_-_1px]', 'bg-[var(--spacing)-1px]'],
20442044
['bg-[var(--_spacing)]', 'bg-(--_spacing)'],
20452045
['bg-(--_spacing)', 'bg-(--_spacing)'],
2046-
['bg-[var(--\_spacing)]', 'bg-(--_spacing)'],
2047-
['bg-(--\_spacing)', 'bg-(--_spacing)'],
20482046
['bg-[-1px_-1px]', 'bg-[-1px_-1px]'],
20492047
['p-[round(to-zero,1px)]', 'p-[round(to-zero,1px)]'],
20502048
['w-1/2', 'w-1/2'],

packages/tailwindcss/src/canonicalize-candidates.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ interface DesignSystem extends BaseDesignSystem {
9292
[CANONICALIZE_UTILITY_KEY]: DefaultMap<InternalCanonicalizeOptions, DefaultMap<string, string>>
9393
[CONVERTER_KEY]: (input: string, options?: Convert) => [string, CandidateModifier | null]
9494
[SPACING_KEY]: DefaultMap<string, number | null> | null
95-
[UTILITY_SIGNATURE_KEY]: DefaultMap<SignatureOptions, DefaultMap<string, string | Symbol>>
95+
[UTILITY_SIGNATURE_KEY]: DefaultMap<SignatureOptions, DefaultMap<string, string | symbol>>
9696
[STATIC_UTILITIES_KEY]: DefaultMap<
9797
SignatureOptions,
9898
DefaultMap<string, DefaultMap<string, Set<string>>>
@@ -102,7 +102,7 @@ interface DesignSystem extends BaseDesignSystem {
102102
DefaultMap<string, DefaultMap<string, Set<string>>>
103103
>
104104
[PRE_COMPUTED_UTILITIES_KEY]: DefaultMap<SignatureOptions, DefaultMap<string, string[]>>
105-
[VARIANT_SIGNATURE_KEY]: DefaultMap<string, string | Symbol>
105+
[VARIANT_SIGNATURE_KEY]: DefaultMap<string, string | symbol>
106106
[PRE_COMPUTED_VARIANTS_KEY]: DefaultMap<string, string[]>
107107
}
108108
}
@@ -2095,7 +2095,7 @@ function createUtilitySignatureCache(
20952095
designSystem: DesignSystem,
20962096
): DesignSystem['storage'][typeof UTILITY_SIGNATURE_KEY] {
20972097
return new DefaultMap((options: SignatureOptions) => {
2098-
return new DefaultMap<string, string | Symbol>((utility) => {
2098+
return new DefaultMap<string, string | symbol>((utility) => {
20992099
try {
21002100
// Ensure the prefix is added to the utility if it is not already present.
21012101
utility =
@@ -2463,7 +2463,7 @@ export const VARIANT_SIGNATURE_KEY = Symbol()
24632463
function createVariantSignatureCache(
24642464
designSystem: DesignSystem,
24652465
): DesignSystem['storage'][typeof VARIANT_SIGNATURE_KEY] {
2466-
return new DefaultMap<string, string | Symbol>((variant) => {
2466+
return new DefaultMap<string, string | symbol>((variant) => {
24672467
try {
24682468
// Ensure the prefix is added to the utility if it is not already present.
24692469
variant =

packages/tailwindcss/src/compat/apply-config-to-theme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ const OLD_TO_NEW_NAMESPACE: Record<string, string> = {
172172
transitionTimingFunction: 'ease',
173173
}
174174

175-
const IS_VALID_KEY = /^[a-zA-Z0-9-_%/\.]+$/
175+
const IS_VALID_KEY = /^[a-zA-Z0-9-_%/.]+$/
176176

177177
export function keyPathToCssProperty(path: string[]) {
178178
// In some special cases the `DEFAULT` key did not map to a "default" utility

0 commit comments

Comments
 (0)