Skip to content

Commit 9308eb7

Browse files
committed
Update dev-dependencies
1 parent 411516a commit 9308eb7

File tree

4 files changed

+59
-60
lines changed

4 files changed

+59
-60
lines changed

lib/errors.js

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111

1212
/**
13-
* @typedef {(...args: Array<any>) => string} MessageFunction
13+
* @typedef {(...parameters: Array<any>) => string} MessageFunction
1414
*/
1515

1616
// Manually “tree shaken” from:
@@ -187,14 +187,14 @@ codes.ERR_INVALID_PACKAGE_CONFIG = createError(
187187
codes.ERR_INVALID_PACKAGE_TARGET = createError(
188188
'ERR_INVALID_PACKAGE_TARGET',
189189
/**
190-
* @param {string} pkgPath
190+
* @param {string} packagePath
191191
* @param {string} key
192192
* @param {unknown} target
193193
* @param {boolean} [isImport=false]
194194
* @param {string} [base]
195195
*/
196-
(pkgPath, key, target, isImport = false, base = undefined) => {
197-
const relError =
196+
(packagePath, key, target, isImport = false, base = undefined) => {
197+
const relatedError =
198198
typeof target === 'string' &&
199199
!isImport &&
200200
target.length > 0 &&
@@ -203,19 +203,19 @@ codes.ERR_INVALID_PACKAGE_TARGET = createError(
203203
assert(isImport === false)
204204
return (
205205
`Invalid "exports" main target ${JSON.stringify(target)} defined ` +
206-
`in the package config ${pkgPath}package.json${
206+
`in the package config ${packagePath}package.json${
207207
base ? ` imported from ${base}` : ''
208-
}${relError ? '; targets must start with "./"' : ''}`
208+
}${relatedError ? '; targets must start with "./"' : ''}`
209209
)
210210
}
211211

212212
return `Invalid "${
213213
isImport ? 'imports' : 'exports'
214214
}" target ${JSON.stringify(
215215
target
216-
)} defined for '${key}' in the package config ${pkgPath}package.json${
216+
)} defined for '${key}' in the package config ${packagePath}package.json${
217217
base ? ` imported from ${base}` : ''
218-
}${relError ? '; targets must start with "./"' : ''}`
218+
}${relatedError ? '; targets must start with "./"' : ''}`
219219
},
220220
Error
221221
)
@@ -259,16 +259,16 @@ codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
259259
codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
260260
'ERR_PACKAGE_PATH_NOT_EXPORTED',
261261
/**
262-
* @param {string} pkgPath
262+
* @param {string} packagePath
263263
* @param {string} subpath
264264
* @param {string} [base]
265265
*/
266-
(pkgPath, subpath, base = undefined) => {
266+
(packagePath, subpath, base = undefined) => {
267267
if (subpath === '.')
268-
return `No "exports" main defined in ${pkgPath}package.json${
268+
return `No "exports" main defined in ${packagePath}package.json${
269269
base ? ` imported from ${base}` : ''
270270
}`
271-
return `Package subpath '${subpath}' is not defined by "exports" in ${pkgPath}package.json${
271+
return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${
272272
base ? ` imported from ${base}` : ''
273273
}`
274274
},
@@ -285,11 +285,11 @@ codes.ERR_UNSUPPORTED_DIR_IMPORT = createError(
285285
codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
286286
'ERR_UNKNOWN_FILE_EXTENSION',
287287
/**
288-
* @param {string} ext
288+
* @param {string} extension
289289
* @param {string} path
290290
*/
291-
(ext, path) => {
292-
return `Unknown file extension "${ext}" for ${path}`
291+
(extension, path) => {
292+
return `Unknown file extension "${extension}" for ${path}`
293293
},
294294
TypeError
295295
)
@@ -322,15 +322,15 @@ codes.ERR_INVALID_ARG_VALUE = createError(
322322
* *only* to allow for testing.
323323
* @param {string} sym
324324
* @param {MessageFunction | string} value
325-
* @param {ErrorConstructor} def
326-
* @returns {new (...args: Array<any>) => Error}
325+
* @param {ErrorConstructor} constructor
326+
* @returns {new (...parameters: Array<any>) => Error}
327327
*/
328-
function createError(sym, value, def) {
328+
function createError(sym, value, constructor) {
329329
// Special case for SystemError that formats the error message differently
330330
// The SystemErrors only have SystemError as their base classes.
331331
messages.set(sym, value)
332332

333-
return makeNodeErrorWithCode(def, sym)
333+
return makeNodeErrorWithCode(constructor, sym)
334334
}
335335

336336
/**
@@ -342,15 +342,15 @@ function makeNodeErrorWithCode(Base, key) {
342342
// @ts-expect-error It’s a Node error.
343343
return NodeError
344344
/**
345-
* @param {Array<unknown>} args
345+
* @param {Array<unknown>} parameters
346346
*/
347-
function NodeError(...args) {
347+
function NodeError(...parameters) {
348348
const limit = Error.stackTraceLimit
349349
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0
350350
const error = new Base()
351351
// Reset the limit and setting the name property.
352352
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit
353-
const message = getMessage(key, args, error)
353+
const message = getMessage(key, parameters, error)
354354
Object.defineProperties(error, {
355355
// Note: no need to implement `kIsNodeError` symbol, would be hard,
356356
// probably.
@@ -385,7 +385,6 @@ function isErrorStackTraceLimitWritable() {
385385
// Do no touch Error.stackTraceLimit as V8 would attempt to install
386386
// it again during deserialization.
387387
try {
388-
// @ts-expect-error: not in types?
389388
if (v8.startupSnapshot.isBuildingSnapshot()) {
390389
return false
391390
}
@@ -403,16 +402,16 @@ function isErrorStackTraceLimitWritable() {
403402

404403
/**
405404
* This function removes unnecessary frames from Node.js core errors.
406-
* @template {(...args: unknown[]) => unknown} T
407-
* @param {T} fn
405+
* @template {(...parameters: unknown[]) => unknown} T
406+
* @param {T} wrappedFunction
408407
* @returns {T}
409408
*/
410-
function hideStackFrames(fn) {
409+
function hideStackFrames(wrappedFunction) {
411410
// We rename the functions that will be hidden to cut off the stacktrace
412411
// at the outermost one
413-
const hidden = nodeInternalPrefix + fn.name
414-
Object.defineProperty(fn, 'name', {value: hidden})
415-
return fn
412+
const hidden = nodeInternalPrefix + wrappedFunction.name
413+
Object.defineProperty(wrappedFunction, 'name', {value: hidden})
414+
return wrappedFunction
416415
}
417416

418417
const captureLargerStackTrace = hideStackFrames(
@@ -439,35 +438,35 @@ const captureLargerStackTrace = hideStackFrames(
439438

440439
/**
441440
* @param {string} key
442-
* @param {Array<unknown>} args
441+
* @param {Array<unknown>} parameters
443442
* @param {Error} self
444443
* @returns {string}
445444
*/
446-
function getMessage(key, args, self) {
445+
function getMessage(key, parameters, self) {
447446
const message = messages.get(key)
448447
assert(message !== undefined, 'expected `message` to be found')
449448

450449
if (typeof message === 'function') {
451450
assert(
452-
message.length <= args.length, // Default options do not count.
453-
`Code: ${key}; The provided arguments length (${args.length}) does not ` +
451+
message.length <= parameters.length, // Default options do not count.
452+
`Code: ${key}; The provided arguments length (${parameters.length}) does not ` +
454453
`match the required ones (${message.length}).`
455454
)
456-
return Reflect.apply(message, self, args)
455+
return Reflect.apply(message, self, parameters)
457456
}
458457

459458
const regex = /%[dfijoOs]/g
460459
let expectedLength = 0
461460
while (regex.exec(message) !== null) expectedLength++
462461
assert(
463-
expectedLength === args.length,
464-
`Code: ${key}; The provided arguments length (${args.length}) does not ` +
462+
expectedLength === parameters.length,
463+
`Code: ${key}; The provided arguments length (${parameters.length}) does not ` +
465464
`match the required ones (${expectedLength}).`
466465
)
467-
if (args.length === 0) return message
466+
if (parameters.length === 0) return message
468467

469-
args.unshift(message)
470-
return Reflect.apply(format, null, args)
468+
parameters.unshift(message)
469+
return Reflect.apply(format, null, parameters)
471470
}
472471

473472
/**

lib/get-format.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ function extname(url) {
102102
* @type {ProtocolHandler}
103103
*/
104104
function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
105-
const ext = extname(url)
105+
const value = extname(url)
106106

107-
if (ext === '.js') {
107+
if (value === '.js') {
108108
const packageType = getPackageType(url)
109109

110110
if (packageType !== 'none') {
@@ -114,7 +114,7 @@ function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
114114
return 'commonjs'
115115
}
116116

117-
if (ext === '') {
117+
if (value === '') {
118118
const packageType = getPackageType(url)
119119

120120
// Legacy behavior
@@ -127,7 +127,7 @@ function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
127127
return 'module'
128128
}
129129

130-
const format = extensionFormatMap[ext]
130+
const format = extensionFormatMap[value]
131131
if (format) return format
132132

133133
// Explicit undefined return indicates load hook should rerun format check
@@ -136,7 +136,7 @@ function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
136136
}
137137

138138
const filepath = fileURLToPath(url)
139-
throw new ERR_UNKNOWN_FILE_EXTENSION(ext, filepath)
139+
throw new ERR_UNKNOWN_FILE_EXTENSION(value, filepath)
140140
}
141141

142142
function getHttpProtocolModuleFormat() {

lib/resolve.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const deprecatedInvalidSegmentRegEx =
4040
/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i
4141
const invalidPackageNameRegEx = /^\.|%|\\/
4242
const patternRegEx = /\*/g
43-
const encodedSepRegEx = /%2f|%5c/i
43+
const encodedSeparatorRegEx = /%2f|%5c/i
4444
/** @type {Set<string>} */
4545
const emittedPackageWarnings = new Set()
4646

@@ -104,21 +104,21 @@ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
104104
const format = defaultGetFormatWithoutErrors(url, {parentURL: base.href})
105105
if (format !== 'module') return
106106
const urlPath = fileURLToPath(url.href)
107-
const pkgPath = fileURLToPath(new URL('.', packageJsonUrl))
107+
const packagePath = fileURLToPath(new URL('.', packageJsonUrl))
108108
const basePath = fileURLToPath(base)
109109
if (!main) {
110110
process.emitWarning(
111-
`No "main" or "exports" field defined in the package.json for ${pkgPath} resolving the main entry point "${urlPath.slice(
112-
pkgPath.length
111+
`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(
112+
packagePath.length
113113
)}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`,
114114
'DeprecationWarning',
115115
'DEP0151'
116116
)
117-
} else if (path.resolve(pkgPath, main) !== urlPath) {
117+
} else if (path.resolve(packagePath, main) !== urlPath) {
118118
process.emitWarning(
119-
`Package ${pkgPath} has a "main" field set to "${main}", ` +
119+
`Package ${packagePath} has a "main" field set to "${main}", ` +
120120
`excluding the full filename and extension to the resolved file at "${urlPath.slice(
121-
pkgPath.length
121+
packagePath.length
122122
)}", imported from ${basePath}.\n Automatic extension resolution of the "main" field is ` +
123123
'deprecated for ES modules.',
124124
'DeprecationWarning',
@@ -227,7 +227,7 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
227227
* @returns {URL}
228228
*/
229229
function finalizeResolution(resolved, base, preserveSymlinks) {
230-
if (encodedSepRegEx.exec(resolved.pathname) !== null) {
230+
if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) {
231231
throw new ERR_INVALID_MODULE_SPECIFIER(
232232
resolved.pathname,
233233
'must not include encoded "/" or "\\" characters',
@@ -644,13 +644,13 @@ function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
644644
const keys = Object.getOwnPropertyNames(exports)
645645
let isConditionalSugar = false
646646
let i = 0
647-
let j = -1
648-
while (++j < keys.length) {
649-
const key = keys[j]
650-
const curIsConditionalSugar = key === '' || key[0] !== '.'
647+
let keyIndex = -1
648+
while (++keyIndex < keys.length) {
649+
const key = keys[keyIndex]
650+
const currentIsConditionalSugar = key === '' || key[0] !== '.'
651651
if (i++ === 0) {
652-
isConditionalSugar = curIsConditionalSugar
653-
} else if (isConditionalSugar !== curIsConditionalSugar) {
652+
isConditionalSugar = currentIsConditionalSugar
653+
} else if (isConditionalSugar !== currentIsConditionalSugar) {
654654
throw new ERR_INVALID_PACKAGE_CONFIG(
655655
fileURLToPath(packageJsonUrl),
656656
base,

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
"devDependencies": {
3232
"@types/node": "^20.0.0",
3333
"@types/semver": "^7.0.0",
34-
"c8": "^8.0.0",
34+
"c8": "^9.0.0",
3535
"prettier": "^3.0.0",
3636
"remark-cli": "^11.0.0",
3737
"remark-preset-wooorm": "^9.0.0",
3838
"semver": "^7.0.0",
3939
"type-coverage": "^2.0.0",
4040
"typescript": "^5.0.0",
41-
"xo": "^0.56.0"
41+
"xo": "^0.58.0"
4242
},
4343
"scripts": {
4444
"prepack": "npm run generate && npm run build && npm run format",

0 commit comments

Comments
 (0)