Implement the 015-add-jscpd-gate feature that adds copy-paste detection to the quality gate using jscpd with a 5% duplication threshold integrated into pnpm check
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
36
specs/015-add-jscpd-gate/quickstart.md
Normal file
36
specs/015-add-jscpd-gate/quickstart.md
Normal file
@@ -0,0 +1,36 @@
|
||||
# Quickstart: Copy-Paste Detection Quality Gate
|
||||
|
||||
## What This Feature Does
|
||||
|
||||
Adds automated copy-paste detection to the project's quality gates. When a developer commits code, jscpd scans for duplicated code blocks and blocks the commit if duplication exceeds the configured threshold. Developers can also run the scan on-demand.
|
||||
|
||||
## Key Commands
|
||||
|
||||
```bash
|
||||
# Run copy-paste detection standalone
|
||||
pnpm jscpd
|
||||
|
||||
# Run full quality gate (includes jscpd)
|
||||
pnpm check
|
||||
|
||||
# Commit triggers the check automatically via Lefthook
|
||||
git commit -m "my changes"
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
The jscpd configuration lives in `.jscpd.json` at the repo root. Key settings:
|
||||
|
||||
- **threshold**: Max allowed duplication percentage (default: 5%)
|
||||
- **minLines**: Minimum lines for a duplicate block (default: 5)
|
||||
- **minTokens**: Minimum tokens for a duplicate block (default: 50)
|
||||
- **pattern**: File globs to scan (TypeScript/TSX)
|
||||
- **ignore**: Directories/files to skip (node_modules, dist, etc.)
|
||||
|
||||
## How It Integrates
|
||||
|
||||
```
|
||||
git commit → Lefthook pre-commit → pnpm check → knip + biome + tsc + vitest + jscpd
|
||||
```
|
||||
|
||||
The `pnpm check` script is the single merge gate. jscpd is added to this chain, so it automatically runs as part of pre-commit hooks and any CI that uses `pnpm check`.
|
||||
Reference in New Issue
Block a user