Skip to content

fix(lint): include .mts and .cts in line-limit checks - #22413

Merged
nwparker merged 3 commits into
mainfrom
nwparker/external-21792-lint-extensions
Sep 25, 2026
Merged

nwparker merged 3 commits into
mainfrom
nwparker/external-21792-lint-extensions

Conversation

@nwparker

@nwparker nwparker commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​140 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​139
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16 $\color{#cf222e}{\Huge{\mathbf{−}}}$​5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​11

ELI5

TypeScript files keep the same size limits regardless of whether their extension is .ts, .mts or .cts.

What Changed

Oxlint applies the existing production and test limits to .mts/.cts. The suppression scanner enumerates those tracked extensions and recognizes their test/spec variants.

Why

Extend the existing limits and scanner together so a TypeScript file cannot escape the rule by switching among .ts, .mts and .cts. No allowances, disables or new budgets are added.

Linked Issue

Related to #21792. Adapted from @DeryFerd.

Visual Proof

N/A — development lint configuration and scanner only; no application UI or behavior changes.

Testing

22 passing focused ratchet tests exercise tracked files and installed oxlint boundary cases. Node typecheck and changed-code quality pass. Executed on macOS; Git options are baseline compatible, but no old-Git or Windows/Linux runtime run is claimed.

  • Native end-to-end flow manually tested
  • Focused automated regression tests added and run with ORCA_BACKGROUND_LAUNCH=1

AI Disclosure

Review

Reviewed production/test glob parity, suppression enumeration and unchanged limits. Existing newline-delimited unusual-filename handling and JavaScript extension budgets are outside this scope. CodeRabbit’s fixture-location finding is addressed: root and mobile fixtures now live below their owning configuration directory and are removed after each test.

Agent skill upstream boundary

  • Not applicable; no upstream skill source is copied.

Notes

No full application build, full lint, or full suite is claimed; CI covers broader validation.

Checklist

  • Small and focused
  • Before/after, mechanism and rationale explained
  • Visual proof attached or N/A explained
  • Reviewed for correctness, security and performance
  • Cross-platform, SSH/remote and compatibility impact considered
  • Required CI checks pass, including the verify aggregate

nwparker and others added 2 commits September 22, 2026 22:39
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

📝 Walkthrough

Walkthrough

The max-lines configuration now applies the 300-line source limit and 800-line test/spec limit to .mts and .cts files. The ratchet script recognizes these extensions when selecting default limits and collecting tracked files. Its failure banner lists the expanded source extensions. Tests cover path matching, mobile overrides, tracked-file collection, and oxlint diagnostics across configured extensions.

Priority: ⬇️ Low

Merge Risk: 🟡 Moderate · up to 68d9b

The line-limit configuration and ratchet updates for .mts and .cts files look correct. However, the new test that checks oxlint's actual limits places its sample files outside the configuration's directory. The limits being tested are therefore never applied to those files. The test will either fail in CI or pass without proving the new limits work. Move the sample files under the configuration directory, or give the test its own equivalent configuration, before merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the primary change: adding .mts and .cts files to line-limit checks.
Description check ✅ Passed The description is mostly complete. It explains the change, rationale, testing, visual proof, scope, and compatibility considerations. It links issue #21792, although it uses “Related to” instead of t…
Full details: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: a8650b62-321d-4323-9ea7-9ea3687230b3

📥 Commits

Reviewing files that changed from the base of the PR and between 9fef7a0 and 68d9bb2.

📒 Files selected for processing (3)
  • .oxlintrc.json
  • config/scripts/check-max-lines-ratchet.mjs
  • config/scripts/check-max-lines-ratchet.test.mjs

Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • oxlint budgets — the production max-lines override now matches **/*.mts and **/*.cts alongside **/*.ts at 300, and the test/spec override grows to eight globs so .test/.spec .mts/.cts get the 800 test budget.
  • Ratchet scanner — defaultLimitForPath learns mts|cts (both source and test/spec forms), collectCurrentSuppressions adds *.mts/*.cts to its git ls-files enumeration, and the failure help text now names .ts/.mts/.cts.
  • Tests — new .mts/.cts cases for defaultLimitForPath and collectMobileBumps, a scratch-repo scanner case (tracked-only, self-file excluded, .mts.backup/.ctsx suffix boundaries), and an installed-oxlint boundary test that pins exact diagnostics for both .oxlintrc.json and mobile/.oxlintrc.json.

Verified locally: the focused suite passes (22 tests), pnpm check:max-lines-ratchet exits 0 with its 7 grandfathered suppressions, installed oxlint 1.80.0 discovers and lints .mts/.cts in both explicit and directory-traversal modes, and oxfmt --check is clean on the three files. The four tracked .mts/.cts files top out at 332 total lines and emit no max-lines diagnostics, so no baseline entry is needed.

ℹ️ .js / .jsx / .cjs remain outside the caps

The diff correctly closes the .mts/.cts hole, but the write-up’s "changing extension is no longer a way around the budget" is broader than what shipped: oxlint still discovers and lints .js/.jsx (and .cjs), yet none has a max-lines override, so an oversized module can still move to one of those. Not a blocker for this PR — flagging only so the residual surface is tracked if the intent is to close extension-switching generally.

Technical details
# `.js`/`.jsx`/`.cjs` have no max-lines budget

## Affected sites
- `.oxlintrc.json:158` — `["**/*.ts", "**/*.mts", "**/*.cts"]`; no `.js`/`.jsx`/`.cjs` entry.
- `config/scripts/check-max-lines-ratchet.mjs:26` — `defaultLimitForPath` has no branch for `.js`/`.jsx`/`.cjs` (they fall through to 300 if ever enumerated, but they are not in `git ls-files` at line 96 either).
- `config/scripts/check-max-lines-ratchet.mjs:96` — enumeration is `['*.ts','*.tsx','*.mts','*.cts','*.mjs']`.

## Evidence
- `pnpm exec oxlint --format json native/windows-registry` → 2 files; `mobile/plugins` → 1; a bare `.cjs` file → 1. oxlint lints these extensions.
- No `max-lines` override exists for any of them, so they are uncapped both in the linter and in the ratchet.

## Required outcome
- None for this PR. If pursued, add matching `max-lines` globs (and any test/spec variants) plus the `git ls-files` patterns in the same change, exactly as this PR did for `.mts`/`.cts`.

## Open questions for the human
- Is closing `.js`/`.jsx`/`.cjs` intended follow-up work, or deliberately out of scope (config/fixture files)?

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Relocated the installed-oxlint boundary fixtures — the two it.each config cases (enforces exact budgets with installed oxlint and %s) now discard the beforeEach tmpdir scratch and recreate it beneath the config under test (dirname(join(repoRoot, config)) — repo root for .oxlintrc.json, mobile/ for mobile/.oxlintrc.json), re-running git init there so the .mts/.cts fixtures sit under the config whose globs they exercise.

Verified locally: ORCA_BACKGROUND_LAUNCH=1 pnpm vitest run config/scripts/check-max-lines-ratchet.test.mjs → 22/22 pass, and git status is clean afterward (the relocated fixtures are removed by afterEach). No production code changed in this delta; the prior review's only note (.js/.jsx/.cjs remain uncapped) is unchanged and intentionally out of scope.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 46079aa into main Sep 25, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant