Code quality toolkit with git hooks for JavaScript/TypeScript projects. Automatically checks syntax, formatting, and dead code on commit and push.
- ESLint - Syntax checking and code quality
- Prettier - Consistent code formatting
- knip - Dead code and unused dependency detection
- Husky - Git hooks (pre-commit, pre-push)
- lint-staged - Run checks only on staged files (fast commits)
# From GitHub
npm install -D github:tedin7/code-guardian
# Install peer dependencies
npm install -D eslint prettier knip husky lint-staged typescript-eslint @eslint/js globals# Initialize in your project
npx code-guardian initThis will:
- Create ESLint, Prettier, and knip configs
- Set up Husky git hooks
- Configure lint-staged for pre-commit
- ESLint with auto-fix
- Prettier formatting
- TypeScript type checking
- Dead code detection (knip)
- Full ESLint scan
# Run all checks
npx code-guardian check
# Auto-fix issues
npx code-guardian fix
# Individual tools
npx eslint . --fix # Lint and fix
npx prettier --write . # Format
npx knip # Find dead codenpm install -D eslint prettier knip husky lint-staged @eslint/js globals typescript-eslintimport js from "@eslint/js";
import tseslint from "typescript-eslint";
import globals from "globals";
export default tseslint.config(
js.configs.recommended,
...tseslint.configs.recommended,
{
languageOptions: {
globals: { ...globals.node, ...globals.browser },
},
rules: {
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
},
},
{ ignores: ["node_modules", "dist", ".next"] }
);{
"$schema": "https://unpkg.com/knip@5/schema.json",
"next": true,
"ignoreDependencies": ["sharp", "autoprefixer"]
}{
"scripts": {
"lint": "eslint . --fix",
"format": "prettier --write .",
"typecheck": "tsc --noEmit",
"deadcode": "knip",
"check": "tsc --noEmit && eslint . && knip"
},
"lint-staged": {
"*.{js,jsx,ts,tsx}": ["eslint --fix", "prettier --write"],
"*.{json,md,yml}": ["prettier --write"]
}
}npx husky initnpx lint-staged#!/bin/sh
echo "Running pre-push checks..."
npx tsc --noEmit || exit 1
npx knip --no-exit-code || echo "Dead code found (warning)"
npx eslint . --max-warnings 0 || exit 1
echo "All checks passed!"For monorepos, initialize Husky at the root where .git lives:
# At monorepo root
npm install -D husky lint-staged
npx husky initThen in .husky/pre-commit:
cd apps/web && npx lint-stagedMIT