feat: Enable strict lint enforcement on pre-commit
Strict enforcement now active: - Format all changed files (auto-fix) - Lint entire packages that have changed files - Type-check affected packages - Block commit if ANY warnings or errors Impact: If you touch a file in a package with existing violations, you must clean up the entire package before committing. This forces incremental cleanup while preventing new violations. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,42 @@
|
||||
// Monorepo-aware lint-staged configuration
|
||||
// NOTE: Strict enforcement is disabled until existing violations are fixed.
|
||||
// See docs/quality-rails-status.md for current status.
|
||||
// STRICT ENFORCEMENT ENABLED: Blocks commits if affected packages have violations
|
||||
//
|
||||
// IMPORTANT: This lints ENTIRE packages, not just changed files.
|
||||
// If you touch ANY file in a package with violations, you must fix the whole package.
|
||||
// This forces incremental cleanup - work in a package = clean up that package.
|
||||
//
|
||||
export default {
|
||||
// TypeScript files - format only for now
|
||||
// TypeScript files - lint and typecheck affected packages
|
||||
'**/*.{ts,tsx}': (filenames) => {
|
||||
return [
|
||||
`prettier --write ${filenames.join(' ')}`,
|
||||
];
|
||||
const commands = [];
|
||||
|
||||
// 1. Format first (auto-fixes what it can)
|
||||
commands.push(`prettier --write ${filenames.join(' ')}`);
|
||||
|
||||
// 2. Extract affected packages
|
||||
const packages = [...new Set(filenames.map(f => {
|
||||
const match = f.match(/^(apps|packages)\/([^/]+)\//);
|
||||
if (!match) return null;
|
||||
// Return package name format for turbo (e.g., "@mosaic/api")
|
||||
return `@mosaic/${match[2]}`;
|
||||
}))].filter(Boolean);
|
||||
|
||||
if (packages.length === 0) {
|
||||
return commands;
|
||||
}
|
||||
|
||||
// 3. Lint entire affected packages via turbo
|
||||
// --max-warnings=0 means ANY warning blocks the commit
|
||||
packages.forEach(pkg => {
|
||||
commands.push(`pnpm turbo run lint --filter=${pkg} -- --max-warnings=0`);
|
||||
});
|
||||
|
||||
// 4. Type-check affected packages
|
||||
packages.forEach(pkg => {
|
||||
commands.push(`pnpm turbo run typecheck --filter=${pkg}`);
|
||||
});
|
||||
|
||||
return commands;
|
||||
},
|
||||
|
||||
// Format all other files
|
||||
|
||||
Reference in New Issue
Block a user