Skip to content

Commit 8062d36

Browse files
authored
refactor: remove unnecessary escape (#18044)
1 parent 7cac03f commit 8062d36

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

eslint.config.js

-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export default tseslint.config(
6767
'no-debugger': ['error'],
6868
'no-empty': ['warn', { allowEmptyCatch: true }],
6969
'no-process-exit': 'off',
70-
'no-useless-escape': 'off',
7170
'prefer-const': [
7271
'warn',
7372
{

packages/vite/src/node/__tests__/plugins/importGlob/parse.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('parse positives', async () => {
2727
it('basic', async () => {
2828
expect(
2929
await run(`
30-
import.meta.glob(\'./modules/*.ts\')
30+
import.meta.glob('./modules/*.ts')
3131
`),
3232
).toMatchInlineSnapshot(`
3333
[
@@ -45,7 +45,7 @@ describe('parse positives', async () => {
4545
it('array', async () => {
4646
expect(
4747
await run(`
48-
import.meta.glob([\'./modules/*.ts\', './dir/*.{js,ts}\'])
48+
import.meta.glob(['./modules/*.ts', './dir/*.{js,ts}'])
4949
`),
5050
).toMatchInlineSnapshot(`
5151
[
@@ -65,7 +65,7 @@ describe('parse positives', async () => {
6565
expect(
6666
await run(`
6767
import.meta.glob([
68-
\'./modules/*.ts\',
68+
'./modules/*.ts',
6969
"!./dir/*.{js,ts}"
7070
], {
7171
eager: true,

packages/vite/src/node/plugins/css.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1653,7 +1653,7 @@ export const cssDataUriRE =
16531653
export const importCssRE = /@import ('[^']+\.css'|"[^"]+\.css"|[^'")]+\.css)/
16541654
// Assuming a function name won't be longer than 256 chars
16551655
// eslint-disable-next-line regexp/no-unused-capturing-group -- doesn't detect asyncReplace usage
1656-
const cssImageSetRE = /(?<=image-set\()((?:[\w\-]{1,256}\([^)]*\)|[^)])*)(?=\))/
1656+
const cssImageSetRE = /(?<=image-set\()((?:[\w-]{1,256}\([^)]*\)|[^)])*)(?=\))/
16571657

16581658
const UrlRewritePostcssPlugin: PostCSS.PluginCreator<{
16591659
replacer: CssUrlReplacer

packages/vite/src/node/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,7 @@ interface ImageCandidate {
725725
descriptor: string
726726
}
727727
const escapedSpaceCharacters = /(?: |\\t|\\n|\\f|\\r)+/g
728-
const imageSetUrlRE = /^(?:[\w\-]+\(.*?\)|'.*?'|".*?"|\S*)/
728+
const imageSetUrlRE = /^(?:[\w-]+\(.*?\)|'.*?'|".*?"|\S*)/
729729
function joinSrcset(ret: ImageCandidate[]) {
730730
return ret
731731
.map(({ url, descriptor }) => url + (descriptor ? ` ${descriptor}` : ''))
@@ -773,7 +773,7 @@ export function processSrcSetSync(
773773
}
774774

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

0 commit comments

Comments
 (0)