Skip to content

Commit 0960674

Browse files
committed
Fix ESLint comment position issue
1 parent 352ec14 commit 0960674

File tree

5 files changed

+27
-14
lines changed

5 files changed

+27
-14
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
66

7+
## [1.1.3](https://github.com/SocketDev/socket-packageurl-js/releases/tag/v1.1.3) - 2025-09-29
8+
9+
### Fixed
10+
- Fixed tsgo transpilation bug that produced incorrect `exports.encodeComponent = void 0;` output
11+
712
## [1.1.2](https://github.com/SocketDev/socket-packageurl-js/releases/tag/v1.1.2) - 2025-09-27
813

914
### Changed

src/package-url.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ class PackageURL {
324324
const afterColon = purlStr.slice(colonIndex + 1)
325325
const trimmedAfterColon = trimLeadingSlashes(afterColon)
326326
url = new URL(`${beforeColon}:${trimmedAfterColon}`)
327-
/* c8 ignore next 4 -- V8 coverage sees multiple branch paths in ternary that can't all be tested. */maybeUrlWithAuth =
327+
/* c8 ignore next 4 -- V8 coverage sees multiple branch paths in ternary that can't all be tested. */ maybeUrlWithAuth =
328328
afterColon.length === trimmedAfterColon.length
329329
? url
330330
: new URL(purlStr)
@@ -335,7 +335,9 @@ class PackageURL {
335335
}
336336
}
337337
// The scheme is a constant with the value "pkg".
338-
/* c8 ignore next -- Tested: colonIndex === -1 (url undefined) case, but V8 can't see both branches. */if (url?.protocol !== 'pkg:') {
338+
/* c8 ignore next -- Tested: colonIndex === -1 (url undefined) case, but V8 can't see both branches. */ if (
339+
url?.protocol !== 'pkg:'
340+
) {
339341
throw new PurlError('missing required "pkg" scheme component')
340342
/* c8 ignore next -- Unreachable code after throw. */
341343
}
@@ -361,12 +363,11 @@ class PackageURL {
361363
let rawVersion: string | undefined
362364
// Both branches of this ternary are tested, but V8 reports phantom branch combinations
363365
/* c8 ignore start -- npm vs non-npm path logic both tested but V8 sees extra branches. */
366+
// Deviate from the specification to handle a special npm purl type case for
367+
364368
let atSignIndex =
365369
rawType === 'npm'
366-
// Deviate from the specification to handle a special npm purl type case for
367-
?
368-
369-
pathname.indexOf('@', firstSlashIndex + 2)
370+
? pathname.indexOf('@', firstSlashIndex + 2)
370371
: pathname.lastIndexOf('@')
371372
/* c8 ignore stop */
372373
// When a forward slash ('/') is directly preceding an '@' symbol,
@@ -418,7 +419,10 @@ class PackageURL {
418419
const value = decodePurlComponent('qualifiers', pairs.at(1) ?? '')
419420
// Use URLSearchParams#append to preserve plus signs.
420421
// https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams#preserving_plus_signs
421-
/* c8 ignore next -- URLSearchParams.append has internal V8 branches we can't control. */searchParams.append(pairs[0]!, value)
422+
/* c8 ignore next -- URLSearchParams.append has internal V8 branches we can't control. */ searchParams.append(
423+
pairs[0]!,
424+
value,
425+
)
422426
}
423427
// Split the remainder once from right on '?'.
424428
rawQualifiers = searchParams

src/purl-type.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,9 +423,11 @@ const PurlType = createHelpersNamespaceObject(
423423
}
424424
return false
425425
}
426-
if (/[~'!()*]/.test(name)) {if (throws) {
426+
if (/[~'!()*]/.test(name)) {
427+
if (throws) {
427428
throw new PurlError(
428-
`npm "name" component can not contain special characters ("~'!()*")`,)
429+
`npm "name" component can not contain special characters ("~'!()*")`,
430+
)
429431
}
430432
return false
431433
}

src/validate.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ function validateStrings(
158158
return true
159159
}
160160
if (throws) {
161-
throw new PurlError(`"'${name}" must be a string`)}
161+
throw new PurlError(`"'${name}" must be a string`)
162+
}
162163
return false
163164
}
164165

test/package-url.test.mts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,8 @@ describe('PackageURL', () => {
771771
const isBuiltin = npmBuiltinNames.includes(id)
772772
const isMixedCased = /[A-Z]/.test(id)
773773
const containsIllegalCharacters = /[~'!()*]/.test(id)
774-
expect(isBuiltin || isMixedCased || containsIllegalCharacters,
774+
expect(
775+
isBuiltin || isMixedCased || containsIllegalCharacters,
775776
`assert for ${legacyName}`,
776777
)
777778
}
@@ -1924,7 +1925,7 @@ describe('PackageURL', () => {
19241925
name: 'パッケージ',
19251926
expectedError:
19261927
/npm "name" component can only contain URL-friendly characters/,
1927-
// Non-ASCII characters
1928+
// Non-ASCII characters
19281929
},
19291930
]
19301931

@@ -2628,11 +2629,11 @@ describe('PackageURL', () => {
26282629
)
26292630
expect(formatPurlErrorMessage('[ message')).toBe(
26302631
'Invalid purl: [ message',
2631-
// After Z
2632+
// After Z
26322633
)
26332634
expect(formatPurlErrorMessage('@ message')).toBe(
26342635
'Invalid purl: @ message',
2635-
// Before A
2636+
// Before A
26362637
)
26372638

26382639
// Test normalize.js line 7 - namespace filter

0 commit comments

Comments
 (0)