Skip to content

Commit

Permalink
perf: regexp perf issues, refactor regexp stylistic issues (#10905)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Nov 14, 2022
1 parent 50f55fd commit 086dc36
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
9 changes: 6 additions & 3 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ module.exports = defineConfig({
extends: [
'eslint:recommended',
'plugin:node/recommended',
'plugin:@typescript-eslint/recommended'
'plugin:@typescript-eslint/recommended',
'plugin:regexp/recommended'
],
plugins: ['import'],
plugins: ['import', 'regexp'],
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
Expand Down Expand Up @@ -97,7 +98,9 @@ module.exports = defineConfig({
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: false
}
]
],

'regexp/no-contradiction-with-assertion': 'error'
},
overrides: [
{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"eslint-define-config": "^1.11.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-regexp": "^1.10.0",
"execa": "^6.1.0",
"fast-glob": "^3.2.12",
"fs-extra": "^10.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-vue/src/handleHotUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { ResolvedOptions } from '.'

const debug = _debug('vite:hmr')

const directRequestRE = /(\?|&)direct\b/
const directRequestRE = /(?:\?|&)direct\b/

/**
* Vite-specific HMR handling
Expand Down Expand Up @@ -148,7 +148,7 @@ export async function handleHotUpdate(
affectedModules.add(mainModule)
} else if (mainModule && !affectedModules.has(mainModule)) {
const styleImporters = [...mainModule.importers].filter((m) =>
/\.css($|\?)/.test(m.url)
/\.css(?:$|\?)/.test(m.url)
)
styleImporters.forEach((m) => affectedModules.add(m))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { isBuild, page } from '~utils'

test('should render', async () => {
const expected = isBuild
? /assets\/asset\.[0-9a-f]+\.png/
? /assets\/asset\.[\da-f]+\.png/
: 'http://localhost/server-origin/test/assets/asset.png'

expect(await page.getAttribute('img', 'src')).toMatch(expected)
Expand Down
2 changes: 1 addition & 1 deletion scripts/rollupLicensePlugin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ function licensePlugin(licenseFilePath, licenseTitle, packageName) {
'\n' +
licenseText
.trim()
.replace(/(\r\n|\r)/gm, '\n')
.replace(/(\r\n|\r)/g, '\n')
.split('\n')
.map((line) => `> ${line}`)
.join('\n') +
Expand Down
2 changes: 1 addition & 1 deletion scripts/verifyCommit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const msg = readFileSync(msgPath, 'utf-8').trim()

const releaseRE = /^v\d/
const commitRE =
/^(revert: )?(feat|fix|docs|dx|refactor|perf|test|workflow|build|ci|chore|types|wip|release|deps)(\(.+\))?: .{1,50}/
/^(?:revert: )?(?:feat|fix|docs|dx|refactor|perf|test|workflow|build|ci|chore|types|wip|release|deps)(?:\(.+\))?: .{1,50}/

if (!releaseRE.test(msg) && !commitRE.test(msg)) {
console.log()
Expand Down

0 comments on commit 086dc36

Please sign in to comment.