chore(web): no-restyle fails lint, and the ceiling gate goes (#13210)

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Julius MarmingeandClaude Opus 5.5 authored and GitHub committed 2026-09-22 21:33:03 -07:00
1 parent 0e512db34d
commit 10882bea73
6 files changed
+4 -98

No files matched your search

-3
View File
@@ -52,9 +52,6 @@ jobs:
- name: Check
run: vp check
- name: Check className overrides on components/ui do not grow
run: vp run lint:restyle-ceiling
- name: Typecheck
run: vpr typecheck
+1 -1
View File
@@ -158,7 +158,7 @@ Full glossary with file links: `docs/internals/glossary.md`
## Taste
- Complexity belongs at the adapter boundary. Orchestration stays pure, UI stays dumb.
- `apps/web/src/components/ui` exports own their look. Pick a `variant` or `size`; do not restyle one with `className`. If none fits, add a variant to the component, not classes at the call site. Layout classes (width, flex, margin, position) belong on the parent. `shadcn/no-restyle` reports violations and CI caps their count.
- `apps/web/src/components/ui` exports own their look. Pick a `variant` or `size`; do not restyle one with `className`. If none fits and the look is a generic concept, add a variant to the component; a look that belongs to one feature stays in that feature's own component, not in `components/ui`. Layout classes (width, flex, margin, position) belong on the parent. `shadcn/no-restyle` fails lint on violations.
- Inferred types over annotations. `any` is the enemy.
- Comments describe how a thing is used, and move when the code moves. To be used mostly to describe functions, not to annotate every line of behavior.
- Our users drive agents all day and notice a dropped frame, a lying spinner, and a stale label. No continuously repainting animations; they peg the GPU on high-refresh displays.
-1
View File
@@ -31,7 +31,6 @@
"knip:check": "knip --include files,dependencies --no-config-hints && knip --workspace apps/server --workspace apps/desktop --workspace apps/web --workspace packages/client-runtime --workspace packages/contracts --workspace packages/effect-acp --workspace packages/effect-codex-app-server --workspace packages/shared --workspace packages/ssh --workspace packages/tailscale --exports --preprocessor ./scripts/knip-schemas.ts --no-config-hints",
"knip:production": "knip --production --preprocessor ./scripts/knip-schemas.ts",
"lint:mobile": "node scripts/mobile-native-static-check.ts",
"lint:restyle-ceiling": "node scripts/lint-restyle-ceiling.ts",
"test": "vp run -r test",
"test:resource-monitor": "cargo test --locked --manifest-path native/resource-monitor/Cargo.toml",
"test:desktop-smoke": "vp run --filter @t3tools/desktop smoke-test",
-24
View File
@@ -1,24 +0,0 @@
import { assert, describe, it } from "@effect/vitest";
import { countRestyleFindings, evaluateCeiling } from "./lint-restyle-ceiling.ts";
describe("lint-restyle-ceiling", () => {
it("counts only no-restyle diagnostics", () => {
const count = countRestyleFindings({
diagnostics: [
{ code: "shadcn(no-restyle)" },
{ code: "react(refs)" },
{ code: "shadcn(no-restyle)" },
],
});
assert.strictEqual(count, 2);
});
it("fails above the ceiling and passes at or below it", () => {
assert.isFalse(evaluateCeiling(11, 10).ok);
assert.isTrue(evaluateCeiling(10, 10).ok);
const below = evaluateCeiling(7, 10);
assert.isTrue(below.ok);
assert.include(below.message, "Lower RESTYLE_CEILING");
});
});
-66
View File
@@ -1,66 +0,0 @@
#!/usr/bin/env node
// @effect-diagnostics nodeBuiltinImport:off - one-shot CI gate over a child process.
import * as NodeChildProcess from "node:child_process";
import * as NodePath from "node:path";
import * as NodeURL from "node:url";
// `shadcn/no-restyle` stays a warning while the existing className overrides on
// components/ui exports are migrated to variants (see vite.config.ts). This gate keeps the
// count from growing: CI fails when findings exceed the ceiling. Lower the ceiling when you
// migrate a file, and delete this script when the rule becomes an error.
export const RESTYLE_CEILING = 0;
const RULE = "shadcn(no-restyle)";
const repoRoot = NodePath.resolve(NodePath.dirname(NodeURL.fileURLToPath(import.meta.url)), "..");
interface LintReport {
readonly diagnostics: ReadonlyArray<{ readonly code: string }>;
}
export function countRestyleFindings(report: LintReport): number {
return report.diagnostics.filter((diagnostic) => diagnostic.code === RULE).length;
}
export function evaluateCeiling(
count: number,
ceiling: number,
): { readonly ok: boolean; readonly message: string } {
if (count > ceiling) {
return {
ok: false,
message:
`${RULE}: ${count} findings exceed the ceiling of ${ceiling}. ` +
"Use a variant or size on the components/ui export instead of a className override " +
"(run `vp lint apps/web/src` for the list).",
};
}
const slack = ceiling - count;
return {
ok: true,
message:
slack === 0
? `${RULE}: ${count} findings, at the ceiling.`
: `${RULE}: ${count} findings, ${slack} below the ceiling of ${ceiling}. Lower RESTYLE_CEILING in scripts/lint-restyle-ceiling.ts to ${count}.`,
};
}
function main() {
const result = NodeChildProcess.spawnSync("vp", ["lint", "--format", "json", "apps/web/src"], {
cwd: repoRoot,
encoding: "utf8",
maxBuffer: 256 * 1024 * 1024,
});
if (result.error) throw result.error;
const report = JSON.parse(result.stdout) as LintReport;
const verdict = evaluateCeiling(countRestyleFindings(report), RESTYLE_CEILING);
process.stdout.write(`${verdict.message}\n`);
process.exitCode = verdict.ok ? 0 : 1;
}
if (
process.argv[1] !== undefined &&
NodePath.resolve(process.argv[1]) === NodeURL.fileURLToPath(import.meta.url)
) {
main();
}
+3 -3
View File
@@ -200,13 +200,13 @@ export default defineConfig({
{
// components/ui exports own their look. App code picks a variant or size instead
// of restyling with className; layout classes (width, flex, margin, position) stay
// allowed because placement belongs to the parent. Warn-only until the existing
// overrides are migrated to variants; the ceiling below stops the count growing.
// allowed because placement belongs to the parent. components/ui is for generic
// primitives: a look that belongs to one feature stays in that feature's component.
files: ["apps/web/src/**"],
excludeFiles: ["apps/web/src/components/ui/**"],
rules: {
"shadcn/no-restyle": [
"warn",
"error",
{
allow: ["layout"],
contracts: [