Skip to content

chore: enforce file size limits with oxlint - #3804

Merged
thymikee merged 3 commits into
mainfrom
chore/oxlint-file-size
Oct 19, 2026
Merged

thymikee merged 3 commits into
mainfrom
chore/oxlint-file-size

Conversation

@thymikee

@thymikee thymikee commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Replace the 200-line git-history test-file size ratchet with oxlint max-lines. 22 files changed: net production 0 lines, tooling/config/tests −192 lines, contributor docs +6 lines (total −186).

Enforce 1,000 lines, including comments/blanks, for **/*.test.{ts,tsx,mjs} and root/package production .ts, .tsx, .mjs sources, excluding test support. Editors, affected lint, and CI use the same rule.

One LEGACY_FILE_LINE_CAPS map caps 13 oversized tests and four production modules at their recorded lengths. Growth beyond those caps fails; other lint rules remain active. Caps require explicit lowering/removal when files shrink: automatic history-based shrink ratcheting is dropped. Review follow-up removes stale size-policy headers and the deleted-guard reference, documents exact extensions, and shares the default limit constant.

Closes #3787.

Validation

  • Base 8369106dbfb93ea0d43dba2e9f8737e1c2cb1ad2; tested/pushed head 7363fca7e56833d8be3b4c1058f29b7e72ac3f32.
  • pnpm check:affected --run --head 7363fca7e56833d8be3b4c1058f29b7e72ac3f32: 36 runnable checks passed, exactCommit=true; receipt .tmp/validation/run-IulDXN/receipt.json. Unit run: 1,922 files, 16,144 tests passed, one skipped.
  • Disposable head checkout: all 17 legacy files pass unchanged and fail with +1 line. Five file shapes pass at 1,000/fail at 1,001. Adding 500 lines to cli-config.test.ts makes affected lint fail: File has too many lines (1782). Maximum allowed is 1282. Scratch checkout removed.
  • Independent review: no findings. Rebase range-diff preserves original patch. CI must rerun at this head; no device behavior changed.

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Size Report

Metric Base Current Diff
Installed (including dependencies) 5.42 MB 5.42 MB 0 B
Package (unpacked) 5.41 MB 5.41 MB 0 B
Package (download) 1.63 MB 1.63 MB -16 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 34.9 ms 37.3 ms +2.4 ms
CLI --help 64.3 ms 65.5 ms +1.3 ms

@thymikee

Copy link
Copy Markdown
Member Author

The lint config change at b3b1538 looks right, and nothing in the code blocks merge. All 20 checks pass on this head, and there are no conflicts. Before it is ready, please answer the design question at the end and fix the stale reference in test/integration/provider-scenarios/android-settings-contract.ts:10.

Not blocking, take or leave: (1) The two legacy overrides in oxlint.config.ts:104 set max-lines to off for 13 test files and 4 production files, so the removed ratchet's no-growth rule is gone. I grew src/tests/cli-config.test.ts from 1282 to 1782 lines in a scratch copy of the head, and oxlint 1.79.0 passed it. A listed file that shrinks below 1000 also keeps its exemption and can regrow to any size. (2) android-settings-contract.ts:10 cites scripts/tests/test-file-size-ratchet.test.ts, which this PR deletes. About a dozen test headers also say the parent "may not grow (docs/agents/testing.md)", for example src/tests/remote-connection-platform-axis.test.ts:11 and packages/remote/src/tests/upload-client-cancellation.test.ts:7. That rule no longer exists, and testing.md does not contain it. My search was keyword based, so there may be more. (3) CONTRIBUTING.md:221 says the limit covers production TypeScript/JavaScript files, but the globs only match ts, tsx and mjs. A planted 1001-line .mts file passed. Either name the extensions in the text or widen the glob to cover mts, cts, cjs and js. The 1000 literal also appears in two override blocks, which could be hoisted.

Would it be simpler to replace "off" on the 17 legacy files with a per-file cap equal to its current length, generated from one {path: max} map in oxlint.config.ts? That keeps the no-growth rule with no git history lookup. The map would also be the single list of debt. Is dropping the no-growth rule acceptable, as the PR documents, or should the legacy entries become caps?

@thymikee
thymikee force-pushed the chore/oxlint-file-size branch from b3b1538 to 7363fca Compare October 19, 2026 10:34
@thymikee

Copy link
Copy Markdown
Member Author

Addressed in 7363fca7e56833d8be3b4c1058f29b7e72ac3f32, rebased on current main.

I agree with the proposed caps: preserving the legacy no-growth ceiling is preferable to turning enforcement off. One LEGACY_FILE_LINE_CAPS map now generates each per-file max-lines override. All 17 values match their files. This keeps growth protection without git-history reads. The remaining tradeoff is explicit: caps do not shrink automatically; contributors must lower/remove an entry when splitting or shrinking its file. CONTRIBUTING documents that requirement.

Also addressed the take-or-leave notes:

  • Removed the deleted-ratchet reference in android-settings-contract.ts and obsolete size-policy/extraction headers across the related tests and fixtures.
  • Documented exactly .ts, .tsx, and .mjs coverage rather than claiming all TypeScript/JavaScript extensions.
  • Hoisted the shared 1,000-line default.

Evidence from a disposable checkout: all 17 files pass at their cap and fail with one added line. Your cli-config.test.ts example now fails through check:affected: 1,782 lines, maximum 1,282. Default test .ts/.tsx/.mjs and root/package source probes pass at 1,000 and fail at 1,001. Scratch checkout removed.

All 36 runnable checks passed on the pushed head with exactCommit=true (.tmp/validation/run-IulDXN/receipt.json); independent review found no issues. CI is rerunning. The PR body now reflects the final policy and line delta.

@thymikee

Copy link
Copy Markdown
Member Author

Thanks, 7363fca answers the design question. LEGACY_FILE_LINE_CAPS keeps the no-growth rule, and all 17 caps match the current length of their files. No other file in the covered globs is over 1000 lines, and the stale ratchet references are gone. The extension wording now matches the globs.

CI was still running when I checked, and there are no conflicts. This is ready for human review.

@thymikee thymikee added the ready-for-human Valid work that needs human implementation, judgment, or maintainer merge label Oct 19, 2026
@thymikee
thymikee merged commit 2b8dc2c into main Oct 19, 2026
34 checks passed
@thymikee
thymikee deleted the chore/oxlint-file-size branch October 19, 2026 10:52
@github-actions

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-19 10:53 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-human Valid work that needs human implementation, judgment, or maintainer merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

check:affected: a changed test file must run the test-file size ratchet

1 participant