A comprehensive code quality analysis tool that runs multiple linters and analyzers to generate a unified health report for your codebase.
Runs 9 different checks on your codebase:
- Linting: oxlint (fast Rust-based linter) + ESLint (import/complexity rules)
- Dead Code: knip (unused files, exports, dependencies)
- Duplicates: jscpd (code duplication detection)
- Dependencies: madge (orphan files, circular dependencies)
- Types: TypeScript type checking via turbo
- Complexity: File size, hook usage, component patterns
- Architecture: dependency-cruiser (module boundaries)
- Structure: Folder organization, naming, depth analysis
- Bun (required - script uses Bun APIs)
curl -fsSL https://bun.sh/install | bash - Node.js (for the various npm packages)
- Turbo (for type checking - part of your monorepo)
Install these packages in your project:
# Core linters and analyzers
bun add -D oxlint knip jscpd madge dependency-cruiser
# ESLint with plugins
bun add -D eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser
# TypeScript
bun add -D typescript @types/node
# For React projects (if applicable)
bun add -D @types/react @types/react-domThe script expects these config files in your project root:
- ESLint:
.eslintrc.jsor similar with import/complexity rules - Knip:
knip.jsonorknip.ts - dependency-cruiser:
.dependency-cruiser.cjs(for architecture checks) - TypeScript:
tsconfig.jsonin each package/app - Turbo:
turbo.jsonwithcheck-typespipeline
knip.json:
{
"entry": ["src/index.ts"],
"project": ["src/**/*.{ts,tsx}"],
"ignore": ["**/*.test.ts", "**/*.spec.ts"]
}.dependency-cruiser.cjs:
module.exports = {
forbidden: [
{
name: 'no-circular',
severity: 'error',
from: {},
to: { circular: true }
}
]
};# Full report (all checks)
bun code-health.ts
# Quick mode (skip slow checks: jscpd, madge, architecture)
bun code-health.ts --quick
# Auto-fix what can be fixed (oxlint --fix)
bun code-health.ts --fixGenerates two files in logs/ directory:
code-health-report.md- Human-readable markdown report with grades and action itemscode-health-report.json- Compact JSON data for programmatic use
- A: 0 errors, 0 warnings
- B: 0 errors, ≤5 warnings
- C: ≤2 errors, ≤15 warnings
- D: ≤5 errors
- F: >5 errors
The script assumes:
- Monorepo with
apps/andpackages/directories - Frontend code in
apps/web/src/ - Backend code in
packages/backend/convex/ - TypeScript/React codebase
- Turbo for build orchestration
Adjust paths in the script if your structure differs.