Skip to content

Commit 9523fd8

Browse files
committed
Lint nits
1 parent ba89205 commit 9523fd8

File tree

3 files changed

+41
-28
lines changed

3 files changed

+41
-28
lines changed

scripts/get-coverage-percentage.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import colors from 'yoctocolors-cjs'
77
import constants from '@socketsecurity/registry/lib/constants'
88
import { logger } from '@socketsecurity/registry/lib/logger'
99

10-
import { getCodeCoverage } from './utils/get-code-coverage.mjs'
11-
import { getTypeCoverage } from './utils/get-type-coverage.mjs'
10+
import { getCodeCoverage } from './utils/get-code-coverage'
11+
import { getTypeCoverage } from './utils/get-type-coverage'
1212

1313
const indent = ' '
1414

src/purl-type.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ const getNpmBuiltinNames = (() => {
2323
try {
2424
// Try to use Node.js builtinModules first.
2525
builtinNames = (module.constructor as any)?.builtinModules
26-
} catch {
27-
}
26+
} catch {}
2827
/* c8 ignore stop */
2928
if (!builtinNames) {
3029
// Fallback to hardcoded list

test/package-url.test.mts

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {
4040
encodeQualifierParam,
4141
encodeQualifiers,
4242
encodeSubpath,
43-
encodeVersion
43+
encodeVersion,
4444
} from '../src/encode.js'
4545
import { PurlError, formatPurlErrorMessage } from '../src/error.js'
4646
import {
@@ -49,7 +49,7 @@ import {
4949
normalizeQualifiers,
5050
normalizeSubpath,
5151
normalizeType,
52-
normalizeVersion
52+
normalizeVersion,
5353
} from '../src/normalize.js'
5454
import { recursiveFreeze } from '../src/objects.js'
5555
import { PackageURL } from '../src/package-url.js'
@@ -59,7 +59,7 @@ import {
5959
PurlComponentStringNormalizer,
6060
PurlComponentValidator,
6161
componentComparator,
62-
componentSortOrder
62+
componentSortOrder,
6363
} from '../src/purl-component.js'
6464
import { PurlQualifierNames } from '../src/purl-qualifier-names.js'
6565
import { PurlType } from '../src/purl-type.js'
@@ -72,7 +72,7 @@ import {
7272
validateStartsWithoutNumber,
7373
validateStrings,
7474
validateSubpath,
75-
validateType
75+
validateType,
7676
} from '../src/validate.js'
7777

7878
function getNpmId(purl: any) {
@@ -1309,7 +1309,6 @@ describe('PackageURL', () => {
13091309

13101310
// Test recursiveFreeze edge cases
13111311
it('should handle recursiveFreeze with various inputs', () => {
1312-
13131312
// Already frozen object
13141313
const frozen = Object.freeze({ a: 1 })
13151314
expect(recursiveFreeze(frozen)).toBe(frozen)
@@ -1336,7 +1335,6 @@ describe('PackageURL', () => {
13361335

13371336
// Test validation functions with throws parameter
13381337
it('should handle validation errors with throws parameter', () => {
1339-
13401338
// validateRequired
13411339
expect(() => validateRequired('field', null, true)).toThrow(
13421340
'"field" is a required component',
@@ -1365,7 +1363,6 @@ describe('PackageURL', () => {
13651363

13661364
// Test index.js exports
13671365
it('should export PackageURL correctly from index.js', () => {
1368-
13691366
// The index.js exports PackageURL
13701367
expect(PackageURL).toBeDefined()
13711368

@@ -1418,7 +1415,6 @@ describe('PackageURL', () => {
14181415

14191416
// Test recursiveFreeze infinite loop detection
14201417
it('should detect infinite loops in recursiveFreeze', () => {
1421-
14221418
// Create a large array to trigger loop detection
14231419
const obj = { arr: [] }
14241420
// Add exactly LOOP_SENTINEL items to trigger the check
@@ -1432,7 +1428,6 @@ describe('PackageURL', () => {
14321428

14331429
// Test purl-component functions
14341430
it('should handle PurlComponent edge cases', () => {
1435-
14361431
// Test PurlComponent exports
14371432
expect(PurlComponent).toBeDefined()
14381433
expect(PurlComponent.name).toBeDefined()
@@ -1475,8 +1470,6 @@ describe('PackageURL', () => {
14751470

14761471
// Test validate.js uncovered lines
14771472
it('should validate empty component edge cases', () => {
1478-
1479-
14801473
// Test line 12 - return false without throwing
14811474
expect(
14821475
validateEmptyByType('swift', 'namespace', 'not-empty', false),
@@ -2298,14 +2291,14 @@ describe('PackageURL', () => {
22982291
expect(validateSubpath('valid/path', false)).toBe(true)
22992292

23002293
// Test validateStartsWithoutNumber edge case (line 121)
2301-
expect(
2302-
validateStartsWithoutNumber('qualifier', 'valid', false),
2303-
).toBe(true)
2294+
expect(validateStartsWithoutNumber('qualifier', 'valid', false)).toBe(
2295+
true,
2296+
)
23042297

23052298
// Test validateRequiredByType with non-empty value (line 156)
2306-
expect(
2307-
validateRequiredByType('swift', 'version', '1.0.0', false),
2308-
).toBe(true)
2299+
expect(validateRequiredByType('swift', 'version', '1.0.0', false)).toBe(
2300+
true,
2301+
)
23092302
})
23102303

23112304
// Final tests for 100% coverage
@@ -2795,36 +2788,57 @@ describe('PackageURL', () => {
27952788
describe('Type-specific validation non-throwing mode', () => {
27962789
it('should reject invalid npm package names without throwing errors', () => {
27972790
// Test npm name starting with period (line 324-325 in purl-type.ts)
2798-
const result1 = PurlType.npm.validate({ name: '.hidden', namespace: '' }, false)
2791+
const result1 = PurlType.npm.validate(
2792+
{ name: '.hidden', namespace: '' },
2793+
false,
2794+
)
27992795
expect(result1).toBe(false)
28002796

28012797
// Test npm name starting with underscore
2802-
const result2 = PurlType.npm.validate({ name: '_private', namespace: '' }, false)
2798+
const result2 = PurlType.npm.validate(
2799+
{ name: '_private', namespace: '' },
2800+
false,
2801+
)
28032802
expect(result2).toBe(false)
28042803

28052804
// Test npm name that is a core module (line 424-425 in purl-type.ts)
28062805
// Note: fs and path are legacy names, so they don't trigger the builtin check
28072806
// Use a non-legacy builtin like worker_threads
2808-
const result3 = PurlType.npm.validate({ name: 'worker_threads', namespace: '' }, false)
2807+
const result3 = PurlType.npm.validate(
2808+
{ name: 'worker_threads', namespace: '' },
2809+
false,
2810+
)
28092811
expect(result3).toBe(false)
28102812

28112813
// Test npm name that's too long (line 397-398 in purl-type.ts)
28122814
const longName = 'a'.repeat(215)
2813-
const result4 = PurlType.npm.validate({ name: longName, namespace: '' }, false)
2815+
const result4 = PurlType.npm.validate(
2816+
{ name: longName, namespace: '' },
2817+
false,
2818+
)
28142819
expect(result4).toBe(false)
28152820
})
28162821

28172822
it('should reject invalid pub package names without throwing errors', () => {
28182823
// Test pub name with invalid characters (line 456-457 in purl-type.ts)
2819-
const result = PurlType.pub.validate({ name: 'invalid-name', namespace: '' }, false)
2824+
const result = PurlType.pub.validate(
2825+
{ name: 'invalid-name', namespace: '' },
2826+
false,
2827+
)
28202828
expect(result).toBe(false)
28212829

28222830
// Test with special characters
2823-
const result2 = PurlType.pub.validate({ name: 'invalid!name', namespace: '' }, false)
2831+
const result2 = PurlType.pub.validate(
2832+
{ name: 'invalid!name', namespace: '' },
2833+
false,
2834+
)
28242835
expect(result2).toBe(false)
28252836

28262837
// Test with uppercase
2827-
const result3 = PurlType.pub.validate({ name: 'InvalidName', namespace: '' }, false)
2838+
const result3 = PurlType.pub.validate(
2839+
{ name: 'InvalidName', namespace: '' },
2840+
false,
2841+
)
28282842
expect(result3).toBe(false)
28292843
})
28302844

0 commit comments

Comments
 (0)