Skip to content

Commit cd4a6d2

Browse files
refactor: dedupe dual hazard diagnostics. (#43)
1 parent 2f8e2f1 commit cd4a6d2

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@knighted/module",
3-
"version": "1.4.0-rc.1",
3+
"version": "1.4.0-rc.2",
44
"description": "Bidirectional transform for ES modules and CommonJS.",
55
"type": "module",
66
"main": "dist/module.js",

src/format.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,12 @@ const dualPackageHazardDiagnostics = async (params: {
348348
const diagFile = origin?.filePath ?? filePath
349349

350350
if (hasImport && hasRequire) {
351-
const importSpecs = usage.imports.map(u =>
352-
u.subpath ? `${pkg}/${u.subpath}` : pkg,
351+
const uniq = <T>(items: T[]) => [...new Set(items)]
352+
const importSpecs = uniq(
353+
usage.imports.map(u => (u.subpath ? `${pkg}/${u.subpath}` : pkg)),
353354
)
354-
const requireSpecs = usage.requires.map(u =>
355-
u.subpath ? `${pkg}/${u.subpath}` : pkg,
355+
const requireSpecs = uniq(
356+
usage.requires.map(u => (u.subpath ? `${pkg}/${u.subpath}` : pkg)),
356357
)
357358

358359
diags.push({

0 commit comments

Comments
 (0)