Repository navigation
perf(lint): keep JS plugins out of default oxlint and adopt ast-grep - #33430
Conversation
Any jsPlugin makes Oxlint hand every file's AST to Node, so the seven custom plugins cost the default `oxlint` run several times its native time. - Move app-store-performance, quadratic-buffer-concat, renderer-scrollbar-style and ime-enter-guard (scope- or dataflow-aware) to config/oxlint-js-plugins.json, run by `pnpm lint:js-plugins`, CI, lint-staged and the changed-lines gate. - Port sort-comparator-performance, mobile-pairing and native-chat-design-tokens to ast-grep rules with rule tests, and delete the plugins. - Add @ast-grep/cli, config/sgconfig.yml, `pnpm lint:ast-grep` / `test:ast-grep`, a CI step, and an ast-grep pass in check-changed-code-quality. - Add flaky-test rules (wall-clock reads, real-time waits, polling loops, unquarantined skips, unexplained timeout bumps), baselined by a count ratchet.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 19 seconds. View limit details
No actionable comments were generated in the recent review.
|
Point the imports of persistence-test-harness, persistence-session-fixtures and pty-host-bindings at the paths main moved them to (stablyai#33233, stablyai#33566), and say above each 420 s timeout why the relaunch journey needs it, as main's test-timeout-needs-reason rule (stablyai#33430) asks.
Point the imports of persistence-test-harness, persistence-session-fixtures and pty-host-bindings at the paths main moved them to (stablyai#33233, stablyai#33566), and say above each 420 s timeout why the relaunch journey needs it, as main's test-timeout-needs-reason rule (stablyai#33430) asks.
Why
Default
oxlinttook 21–27s on the whole repo, against ~3.6s with the seven custom JS plugins removed. Most of that cost doesn't come from the rule logic. Once anyjsPluginsrule applies to a file, Oxlint has to hand that file's AST to Node. A 29-line import check (mobile-pairing) cost as much on its own as the 380-lineapp-store-performanceplugin. The only way to make defaultoxlintfast is to have no JS plugin in the root config.What changed
.oxlintrc.jsonnow uses native rules only. Defaultoxlint, the CI root lint step and the first lint-staged step no longer load any JS plugin.config/oxlint-js-plugins.json. It runs throughpnpm lint:js-plugins, thepnpm lintchain, a new background CI step, lint-staged, and a newJS pluginsscan incheck-changed-code-quality.mjs. The gate now treats suppressions naming those plugins as owned by that scan.@ast-grep/[email protected]. Each platform package holds a prebuilt binary for macOS x64/arm64, Linux x64/arm64 (gnu) and Windows x64/arm64/ia32.supportedArchitectureslimits installs to the host binary, about 53 MB unpacked. The postinstall only hardlinks that binary over the JS launcher, so it is allowed inallowBuilds.config/sgconfig.yml, because new root entries are blocked. Rules are inconfig/ast-grep/rules/and checked-in rule tests inconfig/ast-grep/rule-tests/.pnpm lint:ast-grepandpnpm test:ast-grep(ast-grep test).pnpm lintchain, a CI step (test+scan --format github), lint-staged, and anast-greppass in the changed-lines gate.<id>-tsx)..js/.mjs/.cjsare parsed with the TypeScript grammar.sort-comparator-performancesuppressions, all parity oracles in tests or a benchmark, become// ast-grep-ignore: no-repeated-collator -- <reason>.audit:perfno longer carries the collator rule, since ast-grep now enforces it as an error everywhere.*.test.ts(x)andtests/e2e/**. They run atinfoseverity, so the main scan stays quiet.config/scripts/check-flaky-test-pattern-ratchet.mjsreusesrunCountRatchetwith one row per rule and file, so fixing one pattern can't pay for adding another.run-ratchets.mjspicks the ratchet up automatically.Per-plugin decisions
The solo cost is
oxlintwith only that plugin enabled versus none. It was measured on a heavily loaded 16-core machine (load average 30–50), so read the numbers as relative: with no plugins the run took 6.2s wall / 18.2s CPU, and with all seven 25.1s / 39.5s.sort-comparator-performanceno-repeated-collator(warn)audit:perfmobile-pairingno-eager-qrcode-importno-restricted-importsalso flags the lazyawait import('qrcode'), so it can't be used; ast-grep fitsnative-chat-design-tokensapp-store-performancerequire-selector,no-identity-selector,no-fresh-selector-resultaudit:perfquadratic-buffer-concatno-loop-carried-concataudit:perfrenderer-scrollbar-stylerequire-styled-vertical-scrollbarime-enter-guardrequire-ime-guardNo protection is dropped. Every rule still runs on the full tree in CI, on changed lines in the gate, and on staged files before commit.
Flaky-test rules and baseline
test-no-wall-clockDate.now()/new Date()in unit tests. Skips files that usevi.useFakeTimers/vi.setSystemTime/vi.spyOn(Date, …), and${Date.now()}used for unique namestest-no-real-time-waitnew Promise(r => setTimeout(r, N))in any of its forms (only when the timer resolves the executor's own promise, never a timeout guard),await sleep/delay/wait/pause(N),await setTimeout(N),*.waitForTimeout(N). Zero-delay yields are allowedtest-no-polling-loopwhile/do/for(;;)bodies containing such a sleeptest-skip-needs-quarantine.skip/.only/.fixmewith no// quarantine: #<issue> <reason>in the comment block directly above. ConditionalskipIfand Playwrighttest.skip(cond, reason)are environment guards and aren't flaggedtest-timeout-needs-reasonit(name, fn, N),{ timeout }test options,test.setTimeout,test.slow,testInfo.setTimeoutwith no comment above or beside the timeoutEscape hatch for any rule:
// ast-grep-ignore: <rule-id> -- <reason>on the line above.pnpm lint:ast-grep:flaky-testslists every finding.Timings
All runs were on the same loaded machine; each figure is the minimum over five interleaved runs.
oxlint: 23.8s → 7.8s wall (CPU 37.7s → 19.9s). On a quiet machine the "after" figure is the ~3.6s native-only run.pnpm lint:js-plugins, which now runs only in gates: 17.3s wall.ast-grep scanwith the enforced rules: 5.0s wall (27.5s CPU). With the flaky rules included: 7.9s wall.ast-grep test: under 0.1s.Found but not changed
Override
filesglobs andignorePatternsin configs underconfig/resolve relative toconfig/. So inconfig/oxlint-code-quality-native-plugins.json, thesrc/renderer/src/**,tests/**andmobile/**overrides never match: the jsx-a11y rules, thetests/vitest rules and the mobileexhaustive-depsrule silently never run. I confirmed this with an<img>fixture. The new config uses**/src/renderer/src/**. Fixing the existing configs would surface unknown findings, so it's left for a follow-up.Validation
pnpm tcpnpm test:ast-grep: 11 rule suitespnpm lint:ast-grep,pnpm lint:js-plugins, defaultoxlint,oxfmt --check .pnpm check:flaky-test-pattern-ratchetpnpm check:code-quality:changed: passes. I also checked it against a scratch file with IME, native-chat and qrcode violations, and it reported all three.