Skip to content

Commit

Permalink
chore: update eslint rules (#5721)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed May 14, 2024
1 parent aa431f4 commit 77f4af6
Show file tree
Hide file tree
Showing 37 changed files with 284 additions and 410 deletions.
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default antfu(
'test/coverage-test/src/original.ts',
'examples/**/mockServiceWorker.js',
'examples/sveltekit/.svelte-kit',
'packages/browser/**/esm-client-injector.js',
],
},
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"test:browser:playwright": "pnpm -C test/browser run test:playwright"
},
"devDependencies": {
"@antfu/eslint-config": "^2.17.0",
"@antfu/eslint-config": "^2.18.0",
"@antfu/ni": "^0.21.12",
"@playwright/test": "^1.44.0",
"@rollup/plugin-commonjs": "^25.0.7",
Expand Down
2 changes: 1 addition & 1 deletion packages/browser/src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ function wrapConfig(config: ResolvedConfig): ResolvedConfig {
}

function replacer(code: string, values: Record<string, string>) {
return code.replace(/{\s*(\w+)\s*}/g, (_, key) => values[key] ?? '')
return code.replace(/\{\s*(\w+)\s*\}/g, (_, key) => values[key] ?? '')
}

async function formatScripts(scripts: BrowserScript[] | undefined, server: ViteDevServer) {
Expand Down
2 changes: 1 addition & 1 deletion packages/coverage-v8/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const WRAPPER_LENGTH = 185

// Note that this needs to match the line ending as well
const VITE_EXPORTS_LINE_PATTERN = /Object\.defineProperty\(__vite_ssr_exports__.*\n/g
const DECORATOR_METADATA_PATTERN = /_ts_metadata\("design:paramtypes", \[[^\]]*?\]\),*/g
const DECORATOR_METADATA_PATTERN = /_ts_metadata\("design:paramtypes", \[[^\]]*\]\),*/g
const DEFAULT_PROJECT = Symbol.for('default-project')

const debug = createDebug('vitest:coverage')
Expand Down
2 changes: 1 addition & 1 deletion packages/expect/src/jest-asymmetric-matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class Any extends AsymmetricMatcher<any> {

const matches = functionToString
.call(func)
.match(/^(?:async)?\s*function\s*\*?\s*([\w$]+)\s*\(/)
.match(/^(?:async)?\s*function\s*(?:\*\s*)?([\w$]+)\s*\(/)
return matches ? matches[1] : '<anonymous>'
}

Expand Down
2 changes: 1 addition & 1 deletion packages/expect/src/jest-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export function fnNameFor(func: Function) {

const matches = functionToString
.call(func)
.match(/^(?:async)?\s*function\s*\*?\s*([\w$]+)\s*\(/)
.match(/^(?:async)?\s*function\s*(?:\*\s*)?([\w$]+)\s*\(/)
return matches ? matches[1] : '<anonymous>'
}

Expand Down
2 changes: 1 addition & 1 deletion packages/runner/src/fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ function getUsedProps(fn: Function) {

const _first = first.slice(1, -1).replace(/\s/g, '')
const props = splitByComma(_first).map((prop) => {
return prop.replace(/\:.*|\=.*/g, '')
return prop.replace(/:.*|=.*/g, '')
})

const last = props.at(-1)
Expand Down
2 changes: 1 addition & 1 deletion packages/runner/src/suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ function formatTitle(template: string, items: any[], idx: number) {
let formatted = format(template, ...items.slice(0, count))
if (isObject(items[0])) {
formatted = formatted.replace(
/\$([$\w_.]+)/g,
/\$([$\w.]+)/g,
// https://github.com/chaijs/chai/pull/1490
(_, key) => objDisplay(objectAttr(items[0], key), { truncate: runner?.config?.chaiConfig?.truncateThreshold }) as unknown as string,
)
Expand Down
8 changes: 4 additions & 4 deletions packages/snapshot/src/port/inlineSnapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export async function saveInlineSnapshots(
}))
}

const startObjectRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\S\s]*\*\/\s*|\/\/.*\s+)*\s*({)/m
const startObjectRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\s\S]*\*\/\s*|\/\/.*(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))*\{/

function replaceObjectSnap(code: string, s: MagicString, index: number, newSnap: string) {
let _code = code.slice(index)
Expand Down Expand Up @@ -89,11 +89,11 @@ function prepareSnapString(snap: string, source: string, index: number) {
const isOneline = lines.length <= 1
const quote = '`'
if (isOneline)
return `${quote}${lines.join('\n').replace(/`/g, '\\`').replace(/\${/g, '\\${')}${quote}`
return `${quote}\n${lines.map(i => i ? indentNext + i : '').join('\n').replace(/`/g, '\\`').replace(/\${/g, '\\${')}\n${indent}${quote}`
return `${quote}${lines.join('\n').replace(/`/g, '\\`').replace(/\$\{/g, '\\${')}${quote}`
return `${quote}\n${lines.map(i => i ? indentNext + i : '').join('\n').replace(/`/g, '\\`').replace(/\$\{/g, '\\${')}\n${indent}${quote}`
}

const startRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\S\s]*\*\/\s*|\/\/.*\s+)*\s*[\w_$]*(['"`\)])/m
const startRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\s\S]*\*\/\s*|\/\/.*(?:[\n\r\u2028\u2029]\s*|[\t\v\f \xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF]))*[\w$]*(['"`)])/
export function replaceInlineSnap(code: string, s: MagicString, index: number, newSnap: string) {
const codeStartingAtIndex = code.slice(index)

Expand Down
6 changes: 3 additions & 3 deletions packages/snapshot/src/port/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function deserializeString(stringified: string): string {
}

export function escapeBacktickString(str: string): string {
return str.replace(/`|\\|\${/g, '\\$&')
return str.replace(/`|\\|\$\{/g, '\\$&')
}

function printBacktickString(str: string): string {
Expand Down Expand Up @@ -173,7 +173,7 @@ export function prepareExpected(expected?: string) {
function findStartIndent() {
// Attempts to find indentation for objects.
// Matches the ending tag of the object.
const matchObject = /^( +)}\s+$/m.exec(expected || '')
const matchObject = /^( +)\}\s+$/m.exec(expected || '')
const objectIndent = matchObject?.[1]?.length

if (objectIndent)
Expand All @@ -191,7 +191,7 @@ export function prepareExpected(expected?: string) {

if (startIndent) {
expectedTrimmed = expectedTrimmed
?.replace(new RegExp(`^${' '.repeat(startIndent)}`, 'gm'), '').replace(/ +}$/, '}')
?.replace(new RegExp(`^${' '.repeat(startIndent)}`, 'gm'), '').replace(/ +\}$/, '}')
}

return expectedTrimmed
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/diff/cleanupSemantic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ const diff_cleanupSemantic = function (diffs: Array<Diff>) {
}

// Define some regex patterns for matching boundaries.
const nonAlphaNumericRegex_ = /[^a-zA-Z0-9]/
const nonAlphaNumericRegex_ = /[^a-z0-9]/i
const whitespaceRegex_ = /\s/
const linebreakRegex_ = /[\r\n]/
const blanklineEndRegex_ = /\n\r?\n$/
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/display.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface Options {

type LoupeOptions = Partial<Options>

const formatRegExp = /%[sdjifoOcj%]/g
const formatRegExp = /%[sdjifoOc%]/g

export function format(...args: unknown[]) {
if (typeof args[0] !== 'string') {
Expand Down
2 changes: 2 additions & 0 deletions packages/utils/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ export function slash(path: string) {
// convert RegExp.toString to RegExp
export function parseRegexp(input: string): RegExp {
// Parse input
// eslint-disable-next-line regexp/no-misleading-capturing-group
const m = input.match(/(\/?)(.+)\1([a-z]*)/i)

// match nothing
if (!m)
return /$^/

// Invalid flags
// eslint-disable-next-line regexp/optimal-quantifier-concatenation
if (m[3] && !/^(?!.*?(.).*?\1)[gmixXsuUAJ]+$/.test(m[3]))
return RegExp(input)

Expand Down
7 changes: 4 additions & 3 deletions packages/utils/src/source-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export interface StackTraceParserOptions {
frameFilter?: (error: Error, frame: ParsedStack) => boolean | void
}

const CHROME_IE_STACK_REGEXP = /^\s*at .*(\S+:\d+|\(native\))/m
const SAFARI_NATIVE_CODE_REGEXP = /^(eval@)?(\[native code])?$/
const CHROME_IE_STACK_REGEXP = /^\s*at .*(?:\S:\d+|\(native\))/m
const SAFARI_NATIVE_CODE_REGEXP = /^(?:eval@)?(?:\[native code\])?$/

const stackIgnorePatterns = [
'node:internal',
Expand Down Expand Up @@ -64,7 +64,8 @@ export function parseSingleFFOrSafariStack(raw: string): ParsedStack | null {
if (!line.includes('@') && !line.includes(':'))
return null

const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(?:@)/
// eslint-disable-next-line regexp/no-super-linear-backtracking, regexp/optimal-quantifier-concatenation
const functionNameRegex = /((.*".+"[^@]*)?[^@]*)(@)/
const matches = line.match(functionNameRegex)
const functionName = matches && matches[1] ? matches[1] : undefined
const [url, lineNumber, columnNumber] = extractLocation(line.replace(functionNameRegex, ''))
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-node/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export class ViteNodeRunner {

// remove shebang
if (transformed[0] === '#')
transformed = transformed.replace(/^\#\!.*/, s => ' '.repeat(s.length))
transformed = transformed.replace(/^#!.*/, s => ' '.repeat(s.length))

await this.runModule(context, transformed)

Expand Down
4 changes: 2 additions & 2 deletions packages/vite-node/src/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class Debugger {
}

encodeId(id: string) {
return `${id.replace(/[^\w@_-]/g, '_').replace(/_+/g, '_')}-${hashCode(id)}.js`
return `${id.replace(/[^\w@\-]/g, '_').replace(/_+/g, '_')}-${hashCode(id)}.js`
}

async recordExternalize(id: string, path: string) {
Expand Down Expand Up @@ -66,7 +66,7 @@ export class Debugger {
return null
const code = await fs.readFile(path, 'utf-8')
return {
code: code.replace(/^\/\/.*?\n/, ''),
code: code.replace(/^\/\/.*\n/, ''),
map: undefined!,
}
}
Expand Down
6 changes: 3 additions & 3 deletions packages/vite-node/src/externalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { KNOWN_ASSET_TYPES } from './constants'
const BUILTIN_EXTENSIONS = new Set(['.mjs', '.cjs', '.node', '.wasm'])

const ESM_SYNTAX_RE
= /([\s;]|^)(import[\s\w*,{}]*from|import\s*["'*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m
= /(?:[\s;]|^)(?:import[\s\w*,{}]*from|import\s*["'*{]|export\b\s*(?:[*{]|default|class|type|function|const|var|let|async function)|import\.meta\b)/m
const ESM_EXT_RE = /\.(es|esm|esm-browser|esm-bundler|es6|module)\.js$/
const ESM_FOLDER_RE = /\/(es|esm)\/(.*\.js)$/

Expand Down Expand Up @@ -68,7 +68,7 @@ async function isValidNodeImport(id: string) {
if (package_.type === 'module')
return true

if (/\.(\w+-)?esm?(-\w+)?\.js$|\/(esm?)\//.test(id))
if (/\.(?:\w+-)?esm?(?:-\w+)?\.js$|\/esm?\//.test(id))
return false

const code = await fsp.readFile(id, 'utf8').catch(() => '')
Expand Down Expand Up @@ -97,7 +97,7 @@ async function _shouldExternalize(
// data: should be processed by native import,
// since it is a feature of ESM.
// also externalize network imports since nodejs allows it when --experimental-network-imports
if (id.startsWith('data:') || /^(https?:)?\/\//.test(id))
if (id.startsWith('data:') || /^(?:https?:)?\/\//.test(id))
return id

id = patchWindowsImportPath(id)
Expand Down
8 changes: 4 additions & 4 deletions packages/vite-node/src/source-map-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ function supportRelativeURL(file: string, url: string) {
if (!file)
return url
const dir = path.dirname(file)
const match = /^\w+:\/\/[^\/]*/.exec(dir)
const match = /^\w+:\/\/[^/]*/.exec(dir)
let protocol = match ? match[0] : ''
const startPath = dir.slice(protocol.length)
if (protocol && /^\/\w\:/.test(startPath)) {
if (protocol && /^\/\w:/.test(startPath)) {
// handle file:///C:/ paths
protocol += '/'
return protocol + path.resolve(dir.slice(protocol.length), url).replace(/\\/g, '/')
Expand All @@ -95,7 +95,7 @@ function retrieveSourceMapURL(source: string) {
const fileData = retrieveFile(source)
if (!fileData)
return null
const re = /(?:\/\/[@#][\s]*sourceMappingURL=([^\s'"]+)[\s]*$)|(?:\/\*[@#][\s]*sourceMappingURL=([^\s*'"]+)[\s]*(?:\*\/)[\s]*$)/mg
const re = /\/\/[@#]\s*sourceMappingURL=([^\s'"]+)\s*$|\/\*[@#]\s*sourceMappingURL=[^\s*'"]+\s*\*\/\s*$/gm
// Keep executing the search to find the *last* sourceMappingURL to avoid
// picking up sourceMappingURLs from comments, strings, etc.
let lastMatch, match
Expand Down Expand Up @@ -349,7 +349,7 @@ function wrapCallSite(frame: CallSite, state: State) {
// Header removed in node at ^10.16 || >=11.11.0
// v11 is not an LTS candidate, we can just test the one version with it.
// Test node versions for: 10.16-19, 10.20+, 12-19, 20-99, 100+, or 11.11
const noHeader = /^v(10\.1[6-9]|10\.[2-9][0-9]|10\.[0-9]{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/
const noHeader = /^v(?:10\.1[6-9]|10\.[2-9]\d|10\.\d{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/
const headerLength = noHeader.test(globalProcessVersion()) ? 0 : 62
if (line === 1 && column > headerLength && !frame.isEval())
column -= headerLength
Expand Down
2 changes: 1 addition & 1 deletion packages/vite-node/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const internalRequests = [
'@vite/env',
]

const internalRequestRegexp = new RegExp(`^/?(${internalRequests.join('|')})$`)
const internalRequestRegexp = new RegExp(`^/?(?:${internalRequests.join('|')})$`)

export function isInternalRequest(id: string): boolean {
return internalRequestRegexp.test(id)
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default ({ watch }) => defineConfig([
const parts = Array.from(
new Set(relative(process.cwd(), id).split(/\//g)
.map(i => i.replace(/\..*$/, ''))
.filter(i => !['src', 'index', 'dist', 'node_modules'].some(j => i.includes(j)) && i.match(/^[\w_-]+$/))),
.filter(i => !['src', 'index', 'dist', 'node_modules'].some(j => i.includes(j)) && i.match(/^[\w-]+$/))),
)
if (parts.length)
return `chunks/${parts.slice(-2).join('-')}.[hash].js`
Expand Down Expand Up @@ -231,7 +231,7 @@ function licensePlugin() {
+= `\n${
licenseText
.trim()
.replace(/(\r\n|\r)/gm, '\n')
.replace(/(\r\n|\r)/g, '\n')
.split('\n')
.map(line => line ? `> ${line}` : '>')
.join('\n')
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export const EXIT_CODE_RESTART = 43
export const API_PATH = '/__vitest_api__'

export const extraInlineDeps = [
/^(?!.*(?:node_modules)).*\.mjs$/,
/^(?!.*(?:node_modules)).*\.cjs\.js$/,
/^(?!.*node_modules).*\.mjs$/,
/^(?!.*node_modules).*\.cjs\.js$/,
// Vite client
/vite\w*\/dist\/client\/env.mjs/,
// Nuxt
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/cli/cac.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function createCLI(options: CLIOptions = {}) {

const subcommandMarker = '$SUB_COMMAND_MARKER$'

const banner = info.find(current => /^vitest\/[0-9]+\.[0-9]+\.[0-9]+$/.test(current.body))
const banner = info.find(current => /^vitest\/\d+\.\d+\.\d+$/.test(current.body))
function addBannerWarning(warning: string) {
if (typeof banner?.body === 'string') {
if (banner?.body.includes(warning))
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/hoistMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function getBetterEnd(code: string, node: Node) {
return end
}

const regexpHoistable = /\b(vi|vitest)\s*\.\s*(mock|unmock|hoisted|doMock|doUnmock)\(/
const regexpHoistable = /\b(?:vi|vitest)\s*\.\s*(?:mock|unmock|hoisted|doMock|doUnmock)\(/
const hashbangRE = /^#!.*\n/

export function hoistMocks(code: string, id: string, parse: PluginContext['parse'], colors?: Colors) {
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/node/plugins/cssEnabler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { generateCssFilenameHash } from '../../integrations/css/css-modules'
import type { CSSModuleScopeStrategy, ResolvedConfig } from '../../types'
import { toArray } from '../../utils'

const cssLangs = '\\.(css|less|sass|scss|styl|stylus|pcss|postcss)($|\\?)'
const cssLangs = '\\.(?:css|less|sass|scss|styl|stylus|pcss|postcss)(?:$|\\?)'
const cssLangRE = new RegExp(cssLangs)
const cssModuleRE = new RegExp(`\\.module${cssLangs}`)
const cssInlineRE = /[?&]inline(&|$)/
const cssInlineRE = /[?&]inline(?:&|$)/

function isCSS(id: string) {
return cssLangRE.test(id)
Expand Down
3 changes: 1 addition & 2 deletions packages/vitest/src/node/plugins/normalizeURL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ export function NormalizeURLPlugin(): Plugin {
return

const cleanString = stripLiteral(code)
const assetImportMetaUrlRE
= /\bnew\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*(?:,\s*)?\)/g
const assetImportMetaUrlRE = /\bnew\s+URL\s*\(\s*(?:'[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*(?:,\s*)?\)/g

let updatedCode = code
let match: RegExpExecArray | null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function formatFilepath(path: string) {

function formatNumber(number: number) {
const res = String(number.toFixed(number < 100 ? 4 : 2)).split('.')
return res[0].replace(/(?=(?:\d{3})+$)(?!\b)/g, ',')
return res[0].replace(/(?=(?:\d{3})+$)\B/g, ',')
+ (res[1] ? `.${res[1]}` : '')
}

Expand Down
17 changes: 10 additions & 7 deletions packages/vitest/src/node/reporters/junit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,24 @@ function flattenTasks(task: Task, baseName = ''): Task[] {
// https://gist.github.com/john-doherty/b9195065884cdbfd2017a4756e6409cc
function removeInvalidXMLCharacters(value: any, removeDiscouragedChars: boolean): string {
// eslint-disable-next-line no-control-regex
let regex = /((?:[\0-\x08\x0B\f\x0E-\x1F\uFFFD\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))/g
let regex = /([\0-\x08\v\f\x0E-\x1F\uFFFD\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g
value = String(value || '').replace(regex, '')

if (removeDiscouragedChars) {
// remove everything discouraged by XML 1.0 specifications
regex = new RegExp(
'([\\x7F-\\x84]|[\\x86-\\x9F]|[\\uFDD0-\\uFDEF]|(?:\\uD83F[\\uDFFE\\uDFFF])|(?:\\uD87F[\\uDF'
+ 'FE\\uDFFF])|(?:\\uD8BF[\\uDFFE\\uDFFF])|(?:\\uD8FF[\\uDFFE\\uDFFF])|(?:\\uD93F[\\uDFFE\\uD'
+ 'FFF])|(?:\\uD97F[\\uDFFE\\uDFFF])|(?:\\uD9BF[\\uDFFE\\uDFFF])|(?:\\uD9FF[\\uDFFE\\uDFFF])'
+ '|(?:\\uDA3F[\\uDFFE\\uDFFF])|(?:\\uDA7F[\\uDFFE\\uDFFF])|(?:\\uDABF[\\uDFFE\\uDFFF])|(?:\\'
+ 'uDAFF[\\uDFFE\\uDFFF])|(?:\\uDB3F[\\uDFFE\\uDFFF])|(?:\\uDB7F[\\uDFFE\\uDFFF])|(?:\\uDBBF'
+ '[\\uDFFE\\uDFFF])|(?:\\uDBFF[\\uDFFE\\uDFFF])(?:[\\0-\\t\\x0B\\f\\x0E-\\u2027\\u202A-\\uD7FF\\'
/* eslint-disable regexp/prefer-character-class, regexp/no-obscure-range, regexp/no-useless-non-capturing-group */
'([\\x7F-\\x84]|[\\x86-\\x9F]|[\\uFDD0-\\uFDEF]|\\uD83F[\\uDFFE\\uDFFF]|(?:\\uD87F[\\uDF'
+ 'FE\\uDFFF])|\\uD8BF[\\uDFFE\\uDFFF]|\\uD8FF[\\uDFFE\\uDFFF]|(?:\\uD93F[\\uDFFE\\uD'
+ 'FFF])|\\uD97F[\\uDFFE\\uDFFF]|\\uD9BF[\\uDFFE\\uDFFF]|\\uD9FF[\\uDFFE\\uDFFF]'
+ '|\\uDA3F[\\uDFFE\\uDFFF]|\\uDA7F[\\uDFFE\\uDFFF]|\\uDABF[\\uDFFE\\uDFFF]|(?:\\'
+ 'uDAFF[\\uDFFE\\uDFFF])|\\uDB3F[\\uDFFE\\uDFFF]|\\uDB7F[\\uDFFE\\uDFFF]|(?:\\uDBBF'
+ '[\\uDFFE\\uDFFF])|\\uDBFF[\\uDFFE\\uDFFF](?:[\\0-\\t\\v\\f\\x0E-\\u2027\\u202A-\\uD7FF\\'
+ 'uE000-\\uFFFF]|[\\uD800-\\uDBFF][\\uDC00-\\uDFFF]|[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|'
// eslint-disable-next-line regexp/no-useless-assertions
+ '(?:[^\\uD800-\\uDBFF]|^)[\\uDC00-\\uDFFF]))',
'g',
/* eslint-enable */
)

value = value.replace(regex, '')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function formatFilepath(path: string) {

function formatNumber(number: number) {
const res = String(number.toFixed(number < 100 ? 4 : 2)).split('.')
return res[0].replace(/(?=(?:\d{3})+$)(?!\b)/g, ',')
return res[0].replace(/(?=(?:\d{3})+$)\B/g, ',')
+ (res[1] ? `.${res[1]}` : '')
}

Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/runtime/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export interface ContextExecutorOptions {
requestStubs: Record<string, any>
}

const bareVitestRegexp = /^@?vitest(\/|$)/
const bareVitestRegexp = /^@?vitest(?:\/|$)/

const dispose: (() => void)[] = []

Expand Down

0 comments on commit 77f4af6

Please sign in to comment.