From edf39d0a869a1bbca423283f8c1ad58fa37e6c6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D8=A7=D9=84=D8=AE=D8=A7=D8=B3=D8=B1?= <53134489+mubarakx01@users.noreply.github.com> Date: Tue, 27 Jan 2026 08:30:36 +0530 Subject: [PATCH] chore: relax loc check defaults --- package.json | 2 +- scripts/check-ts-max-loc.ts | 26 +++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 0c63d5d69..1310d9ebf 100644 --- a/package.json +++ b/package.json @@ -140,7 +140,7 @@ "protocol:gen:swift": "node --import tsx scripts/protocol-gen-swift.ts", "protocol:check": "pnpm protocol:gen && pnpm protocol:gen:swift && git diff --exit-code -- dist/protocol.schema.json apps/macos/Sources/ClawdbotProtocol/GatewayModels.swift", "canvas:a2ui:bundle": "bash scripts/bundle-a2ui.sh", - "check:loc": "node --import tsx scripts/check-ts-max-loc.ts --max 500" + "check:loc": "node --import tsx scripts/check-ts-max-loc.ts --max 3000" }, "keywords": [], "author": "", diff --git a/scripts/check-ts-max-loc.ts b/scripts/check-ts-max-loc.ts index a1272f491..8459fb74c 100644 --- a/scripts/check-ts-max-loc.ts +++ b/scripts/check-ts-max-loc.ts @@ -4,10 +4,13 @@ import { execFileSync } from "node:child_process"; type ParsedArgs = { maxLines: number; + exclude: RegExp[]; }; function parseArgs(argv: string[]): ParsedArgs { let maxLines = 500; + const excludePatterns: string[] = []; + const defaultExcludePatterns = ["^(vendor|dist|docs|extensions|ui|apps)/"]; for (let index = 0; index < argv.length; index++) { const arg = argv[index]; @@ -18,9 +21,25 @@ function parseArgs(argv: string[]): ParsedArgs { index++; continue; } + if (arg === "--exclude") { + const next = argv[index + 1]; + if (!next) throw new Error("Missing --exclude value"); + excludePatterns.push(next); + index++; + continue; + } } - return { maxLines }; + const combinedPatterns = [...defaultExcludePatterns, ...excludePatterns]; + const exclude = combinedPatterns.map((pattern) => { + try { + return new RegExp(pattern); + } catch { + throw new Error(`Invalid --exclude regex: ${pattern}`); + } + }); + + return { maxLines, exclude }; } function gitLsFilesAll(): string[] { @@ -47,10 +66,11 @@ async function main() { throw error; }); - const { maxLines } = parseArgs(process.argv.slice(2)); + const { maxLines, exclude } = parseArgs(process.argv.slice(2)); const files = gitLsFilesAll() .filter((filePath) => existsSync(filePath)) - .filter((filePath) => filePath.endsWith(".ts") || filePath.endsWith(".tsx")); + .filter((filePath) => filePath.endsWith(".ts") || filePath.endsWith(".tsx")) + .filter((filePath) => !exclude.some((pattern) => pattern.test(filePath))); const results = await Promise.all( files.map(async (filePath) => ({ filePath, lines: await countLines(filePath) })),