Skip to content

Commit a398b46

Browse files
committed
chore: update config paths and clean up imports
Update references to relocated config files and remove unused imports
1 parent 6df5c8d commit a398b46

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

.config/eslint.config.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const nodeGlobalsConfig = Object.fromEntries(
2626
Object.entries(globals.node).map(([k]) => [k, 'readonly']),
2727
)
2828

29-
const biomeConfigPath = path.join(rootPath, 'biome.json')
29+
const biomeConfigPath = path.join(rootPath, '.config', 'biome.json')
3030
const biomeConfig = require(biomeConfigPath)
3131
const biomeIgnores = {
3232
name: `Imported biome.json ignore patterns`,

scripts/build.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ async function buildTypes(options = {}) {
9494
}
9595

9696
commands.push({
97-
args: ['exec', 'tsgo', '--project', 'tsconfig.dts.json'],
97+
args: ['exec', 'tsgo', '--project', '.config/tsconfig.dts.json'],
9898
command: 'pnpm',
9999
})
100100

scripts/cover.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Collects both code coverage and type coverage.
44
*
55
* Usage:
6-
* node scripts/cover.mjs [--code-only|--type-only|--percent]
6+
* node scripts/cover.mjs [--code-only|--type-only|--percent|--summary]
77
*/
88

99
import { parseArgs } from 'node:util'
@@ -18,13 +18,14 @@ async function main() {
1818
options: {
1919
'code-only': { type: 'boolean', default: false },
2020
percent: { type: 'boolean', default: false },
21+
summary: { type: 'boolean', default: false },
2122
'type-only': { type: 'boolean', default: false },
2223
},
2324
strict: false,
2425
})
2526

26-
if (values.percent) {
27-
// Just get coverage percentage
27+
if (values.percent || values.summary) {
28+
// Display coverage summary
2829
const exitCode = await runSequence([
2930
{ args: ['scripts/coverage-percent.mjs'], command: 'node' },
3031
])

scripts/lint.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ const CONFIG_PATTERNS = [
3535
'pnpm-lock.yaml',
3636
'tsconfig*.json',
3737
'eslint.config.*',
38-
'biome.json',
3938
]
4039

4140
/**

scripts/utils/get-type-coverage.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { spawn } from '@socketsecurity/registry/lib/spawn'
44

55
/**
66
* Executes the type-coverage command and extracts the percentage from its output.
7-
* This runs 'pnpm run coverage:type' which internally executes the type-coverage tool.
7+
* This runs 'pnpm exec type-coverage' which executes the type-coverage tool.
88
* @returns {Promise<number|null>} The type coverage percentage as a float, or null if not found.
99
*/
1010
export async function getTypeCoverage() {
1111
// Run the type-coverage command and capture its output.
12-
const result = await spawn('pnpm', ['run', 'coverage:type'], {
12+
const result = await spawn('pnpm', ['exec', 'type-coverage'], {
1313
stdio: 'pipe',
1414
// Use shell on Windows for proper command execution.
1515
shell: constants.WIN32,

src/package-url.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ class PackageURL {
267267
)
268268
}
269269

270-
let parsed
270+
let parsed: unknown
271271
try {
272272
parsed = JSON.parse(json)
273273
} catch (e) {
@@ -282,15 +282,18 @@ class PackageURL {
282282
throw new Error('JSON must parse to an object')
283283
}
284284

285+
// Cast to record type for safe property access
286+
const parsedRecord = parsed as Record<string, unknown>
287+
285288
// Create a safe object without prototype chain to prevent prototype pollution.
286289
const safeObject: PackageURLObject = {
287290
__proto__: null,
288-
type: parsed.type,
289-
namespace: parsed.namespace,
290-
name: parsed.name,
291-
version: parsed.version,
292-
qualifiers: parsed.qualifiers,
293-
subpath: parsed.subpath,
291+
type: parsedRecord['type'] as string | undefined,
292+
namespace: parsedRecord['namespace'] as string | undefined,
293+
name: parsedRecord['name'] as string | undefined,
294+
version: parsedRecord['version'] as string | undefined,
295+
qualifiers: parsedRecord['qualifiers'] as Record<string, string> | undefined,
296+
subpath: parsedRecord['subpath'] as string | undefined,
294297
} as PackageURLObject
295298

296299
return PackageURL.fromObject(safeObject)

test/integration.test.mts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ describe('Integration tests', () => {
1818
const { pkgPath } = await isolatePackage(packagePath)
1919

2020
// Test that we can import the package
21-
const { PackageURL } = await import(`${pkgPath}/dist/package-url.js`)
21+
const { PackageURL } = await import(`${pkgPath}/dist/index.js`)
2222
expect(PackageURL).toBeDefined()
2323
expect(typeof PackageURL).toBe('function')
2424

@@ -46,8 +46,7 @@ describe('Integration tests', () => {
4646
it('should load UrlConverter and work correctly', async () => {
4747
const { pkgPath } = await isolatePackage(packagePath)
4848

49-
const { UrlConverter } = await import(`${pkgPath}/dist/url-converter.js`)
50-
const { PackageURL } = await import(`${pkgPath}/dist/package-url.js`)
49+
const { PackageURL, UrlConverter } = await import(`${pkgPath}/dist/index.js`)
5150

5251
expect(UrlConverter).toBeDefined()
5352
expect(typeof UrlConverter.toRepositoryUrl).toBe('function')
@@ -64,9 +63,7 @@ describe('Integration tests', () => {
6463
it('should have all entry points working together', async () => {
6564
const { pkgPath } = await isolatePackage(packagePath)
6665

67-
const { PackageURL } = await import(`${pkgPath}/dist/package-url.js`)
68-
const { PackageURLBuilder } = await import(`${pkgPath}/dist/index.js`)
69-
const { UrlConverter } = await import(`${pkgPath}/dist/url-converter.js`)
66+
const { PackageURL, PackageURLBuilder, UrlConverter } = await import(`${pkgPath}/dist/index.js`)
7067

7168
// Build a purl
7269
const purl = PackageURLBuilder.create()

0 commit comments

Comments
 (0)