Run code quality checks to find duplication and dead code. Install the tools first if they're not in package.json.
First check if jscpd and knip are installed:
cat package.json | grep -E "jscpd|knip"If not installed, install them:
npm install -D jscpd knip
npx knip initAdd scripts to package.json if missing:
{
"scripts": {
"lint:dupes": "jscpd src/",
"lint:dead": "knip",
"lint:quality": "npm run lint:dupes && npm run lint:dead"
}
}Run both tools:
npm run lint:dupes
npm run lint:deadAfter running, report:
- jscpd: Number of duplicate code blocks and duplication percentage
- knip: Unused files, unused dependencies, unused exports, unused types
For each issue found:
- Duplicate code: Extract to shared utility or component
- Unused files: Delete them
- Unused dependencies: Remove from package.json
- Unused exports: Remove the export or delete if truly unused
Commit the cleanup changes when done.