Code Quality Check
Run comprehensive code quality verification: formatting, linting, type checking, and tests.
Quick Start
1. Detect Project Tools
node scripts/detect-tools.js [project-path]
Returns JSON with detected tools (Prettier, ESLint, TypeScript, test runners) and their configurations.
2. Run All Checks
# Check only (no modifications)
node scripts/check-all.js [project-path]
# Check and auto-fix where possible
node scripts/check-all.js --fix [project-path]
# Skip tests
node scripts/check-all.js --skip-tests [project-path]
Workflow
Step 1: Detection
Run detect-tools.js to identify what's configured in the project. Check for:
package.jsonexistence- Prettier config files (
.prettierrc,prettier.config.js, etc.) - ESLint config files (
eslint.config.jsfor flat config,.eslintrc.*for legacy) - TypeScript (
tsconfig.json) - Test runners (Jest, Vitest, Mocha, Playwright, Cypress)
Step 2: Execution Order
Execute checks in this order (each step depends on previous):
- Prettier - Fix formatting first
- ESLint - Then fix linting (may depend on formatting)
- TypeScript - Type check (requires valid syntax from steps 1-2)
- Tests - Run test suite (requires all above passing)
Step 3: Report Results
Format output as:
[OK] Prettier - All files formatted
[X] ESLint - 3 errors, 5 warnings
[OK] TypeScript - No type errors
[-] Tests - Skipped (no runner configured)
SUMMARY: 1 check failed - fix issues before deploy
Manual Commands Reference
Prettier
# Check formatting
npx prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}"
# Fix formatting
npx prettier --write "**/*.{js,jsx,ts,tsx,json,css,md}"
# List unformatted files
npx prettier --list-different "**/*.{js,jsx,ts,tsx}"
ESLint
# Check for issues
npx eslint .
# Auto-fix issues
npx eslint . --fix
# Check specific file types
npx eslint "**/*.{ts,tsx}"
# Inspect config (debug)
npx @eslint/config-inspector
TypeScript
# Type check without emitting
npx tsc --noEmit
# Type check with pretty output
npx tsc --noEmit --pretty
# Watch mode
npx tsc --noEmit --watch
# Build mode (monorepos)
npx tsc --build --noEmit
Tests
# Jest
npx jest
npx jest --coverage
# Vitest
npx vitest run
npx vitest run --coverage
# npm script
npm test
Handling Issues
When issues are found:
- Auto-fixable issues: Run with
--fixflag - Manual fixes needed: Show specific errors and suggest fixes
- Missing tool: Report as skipped, don't fail
For common issues and solutions, see references/common-issues.md.
For recommended configurations, see references/config-examples.md.
Output Format
Use these status indicators:
[OK]- Check passed[X]- Check failed (errors found)[!]- Check passed with warnings[-]- Check skipped (tool not configured)
CI/CD Integration
Recommended npm scripts for package.json:
{
"scripts": {
"quality": "prettier --check . && eslint . && tsc --noEmit",
"quality:fix": "prettier --write . && eslint --fix . && tsc --noEmit"
}
}
Exit codes:
0- All checks passed1- One or more checks failed