Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,8 +586,8 @@ The mobile app lives in `mobile/` — a Flutter app using Riverpod + Hooks.
over raw `Theme.of(context)` calls.
- **Keep widgets small and composable.** One public widget per file; push
private sub-widgets (`_Foo`) into sibling `part` files under a
`<page>/` folder rather than growing the page file. Hard ceiling:
**1000 lines/file**, enforced across Desktop, Web, and Mobile by the
`<page>/` folder rather than growing the page file. Mobile's hard ceiling is
**1200 lines/file**, enforced with the other surface-specific limits by the
repository-level `just file-size-check` gate (`just check`, CI, and every
pre-push). If the guard trips, **split the file — never bump the limit or add
an override to slip under it.**
Expand Down
25 changes: 15 additions & 10 deletions desktop/scripts/check-file-sizes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,57 @@ import { runFileSizeCheck } from "../../scripts/check-file-sizes-core.mjs";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const projectRoot = path.resolve(__dirname, "..");

const MAX_LINES = 1000;
const DESKTOP_FRONTEND_MAX_LINES = 1200;
const DESKTOP_RUST_MAX_LINES = 1500;

const rules = [
{ root: "src-tauri/src", extensions: new Set([".rs"]), maxLines: MAX_LINES },
{
root: "src-tauri/src",
extensions: new Set([".rs"]),
maxLines: DESKTOP_RUST_MAX_LINES,
},
// Workspace member crates. Without this the ratchet's only Rust root is
// `src-tauri/src`, and a crate under `src-tauri/crates/` is born outside the
// repo's one size discipline -- silently, since the check still exits 0.
{
root: "src-tauri/crates",
extensions: new Set([".rs"]),
maxLines: MAX_LINES,
maxLines: DESKTOP_RUST_MAX_LINES,
},
{
root: "src/app",
extensions: new Set([".ts", ".tsx"]),
maxLines: MAX_LINES,
maxLines: DESKTOP_FRONTEND_MAX_LINES,
},
{
root: "src/features",
extensions: new Set([".ts", ".tsx"]),
maxLines: MAX_LINES,
maxLines: DESKTOP_FRONTEND_MAX_LINES,
},
{
root: "src/shared/api",
extensions: new Set([".ts", ".tsx"]),
maxLines: MAX_LINES,
maxLines: DESKTOP_FRONTEND_MAX_LINES,
},
{
root: "src/shared/context",
extensions: new Set([".ts", ".tsx"]),
maxLines: MAX_LINES,
maxLines: DESKTOP_FRONTEND_MAX_LINES,
},
{
root: "src/shared/lib",
extensions: new Set([".ts", ".tsx"]),
maxLines: MAX_LINES,
maxLines: DESKTOP_FRONTEND_MAX_LINES,
},
{
root: "src/shared/ui",
extensions: new Set([".ts", ".tsx"]),
maxLines: MAX_LINES,
maxLines: DESKTOP_FRONTEND_MAX_LINES,
},
{
root: "src/shared/styles",
extensions: new Set([".css"]),
maxLines: MAX_LINES,
maxLines: DESKTOP_FRONTEND_MAX_LINES,
},
];

Expand Down
2 changes: 1 addition & 1 deletion mobile/scripts/check-file-sizes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { runFileSizeCheck } from "../../scripts/check-file-sizes-core.mjs";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const projectRoot = path.resolve(__dirname, "..");

const MAX_LINES = 1000;
const MAX_LINES = 1200;

const rules = [
{
Expand Down
23 changes: 22 additions & 1 deletion scripts/check-file-sizes-core.test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from "node:assert/strict";
import { execFileSync } from "node:child_process";
import { mkdtempSync } from "node:fs";
import { mkdtempSync, readFileSync } from "node:fs";
import { tmpdir } from "node:os";
import path from "node:path";
import test from "node:test";
Expand Down Expand Up @@ -53,6 +53,27 @@ test("counts empty, LF, and CRLF content with the existing semantics", () => {
assert.equal(countLines("one\r\ntwo"), 2);
});

test("surface entrypoints keep the intended ceilings", () => {
const repoRoot = path.resolve(import.meta.dirname, "..");
const desktop = readFileSync(
path.join(repoRoot, "desktop/scripts/check-file-sizes.mjs"),
"utf8",
);
const mobile = readFileSync(
path.join(repoRoot, "mobile/scripts/check-file-sizes.mjs"),
"utf8",
);
const web = readFileSync(
path.join(repoRoot, "web/scripts/check-file-sizes.mjs"),
"utf8",
);

assert.match(desktop, /DESKTOP_FRONTEND_MAX_LINES = 1200/);
assert.match(desktop, /DESKTOP_RUST_MAX_LINES = 1500/);
assert.match(mobile, /MAX_LINES = 1200/);
assert.match(web, /MAX_LINES = 1000/);
});

test("new files use the configured ceiling", () => {
assert.equal(allowedLineCount(null, 1000), 1000);
assert.deepEqual(
Expand Down
Loading