Skip to content

Commit

Permalink
refactor: remove unnecessary escape (#18044)
Browse files Browse the repository at this point in the history
  • Loading branch information
btea authored Sep 9, 2024
1 parent 7cac03f commit 8062d36
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export default tseslint.config(
'no-debugger': ['error'],
'no-empty': ['warn', { allowEmptyCatch: true }],
'no-process-exit': 'off',
'no-useless-escape': 'off',
'prefer-const': [
'warn',
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('parse positives', async () => {
it('basic', async () => {
expect(
await run(`
import.meta.glob(\'./modules/*.ts\')
import.meta.glob('./modules/*.ts')
`),
).toMatchInlineSnapshot(`
[
Expand All @@ -45,7 +45,7 @@ describe('parse positives', async () => {
it('array', async () => {
expect(
await run(`
import.meta.glob([\'./modules/*.ts\', './dir/*.{js,ts}\'])
import.meta.glob(['./modules/*.ts', './dir/*.{js,ts}'])
`),
).toMatchInlineSnapshot(`
[
Expand All @@ -65,7 +65,7 @@ describe('parse positives', async () => {
expect(
await run(`
import.meta.glob([
\'./modules/*.ts\',
'./modules/*.ts',
"!./dir/*.{js,ts}"
], {
eager: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/plugins/css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1653,7 +1653,7 @@ export const cssDataUriRE =
export const importCssRE = /@import ('[^']+\.css'|"[^"]+\.css"|[^'")]+\.css)/
// Assuming a function name won't be longer than 256 chars
// eslint-disable-next-line regexp/no-unused-capturing-group -- doesn't detect asyncReplace usage
const cssImageSetRE = /(?<=image-set\()((?:[\w\-]{1,256}\([^)]*\)|[^)])*)(?=\))/
const cssImageSetRE = /(?<=image-set\()((?:[\w-]{1,256}\([^)]*\)|[^)])*)(?=\))/

const UrlRewritePostcssPlugin: PostCSS.PluginCreator<{
replacer: CssUrlReplacer
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ interface ImageCandidate {
descriptor: string
}
const escapedSpaceCharacters = /(?: |\\t|\\n|\\f|\\r)+/g
const imageSetUrlRE = /^(?:[\w\-]+\(.*?\)|'.*?'|".*?"|\S*)/
const imageSetUrlRE = /^(?:[\w-]+\(.*?\)|'.*?'|".*?"|\S*)/
function joinSrcset(ret: ImageCandidate[]) {
return ret
.map(({ url, descriptor }) => url + (descriptor ? ` ${descriptor}` : ''))
Expand Down Expand Up @@ -773,7 +773,7 @@ export function processSrcSetSync(
}

const cleanSrcSetRE =
/(?:url|image|gradient|cross-fade)\([^)]*\)|"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'|data:\w+\/[\w.+\-]+;base64,[\w+/=]+|\?\S+,/g
/(?:url|image|gradient|cross-fade)\([^)]*\)|"([^"]|(?<=\\)")*"|'([^']|(?<=\\)')*'|data:\w+\/[\w.+-]+;base64,[\w+/=]+|\?\S+,/g
function splitSrcSet(srcs: string) {
const parts: string[] = []
/**
Expand Down

0 comments on commit 8062d36

Please sign in to comment.