Get the jscpd report — primary source is the GitHub PR MegaLinter workflow log.
The authoritative findings live in the MegaLinter run for the PR associated with the current branch. Pull them with gh (no need to open the browser):
gh pr view --json number,url,headRefName,state
gh run list --branch "$(git rev-parse --abbrev-ref HEAD)" --workflow mega-linter.yml \
--limit 5 --json databaseId,status,conclusion,createdAt,event,headSha
gh run view <runId> --json jobs --jq '.jobs[] | {name, databaseId, conclusion}'
gh run view --job <jobId> --log > megalinter.log
The log is long (~1k+ lines). Locate the jscpd section by grepping for JSCPD / jscpd — the relevant block starts at ❌ Linted [COPYPASTE] files with [jscpd] and lists each clone as:
Clone found (typescript):
- <file> [<start>:<col> - <end>:<col>] (<n> lines, <n> tokens)
<file> [<start>:<col> - <end>:<col>]
Each block is a pair of (file, line range) → (file, line range) with the duplicated token count. Note that the two sides can be in the same file (intra-file duplication).
Clean up after: delete the temporary megalinter.log (do not commit it).
Fallbacks if the PR / workflow log is unavailable:
- Read a local MegaLinter report under
megalinter-reports/ (only present if MegaLinter was run locally).
- Run jscpd locally:
npx jscpd . (uses .jscpd.json).