refactor: remove unnecessary escape (#18044)

This commit is contained in:
btea 2024-09-09 18:00:40 +08:00 committed by GitHub
parent 7cac03fa51
commit 8062d36773
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 6 additions and 7 deletions

View File

@ -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',
{

View File

@ -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(`
[
@ -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(`
[
@ -65,7 +65,7 @@ describe('parse positives', async () => {
expect(
await run(`
import.meta.glob([
\'./modules/*.ts\',
'./modules/*.ts',
"!./dir/*.{js,ts}"
], {
eager: true,

View File

@ -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

View File

@ -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}` : ''))
@ -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[] = []
/**