optilintFind and fix slow JavaScript and TypeScript
A type-aware linter that only cares about speed. Every fix says what it guarantees, and every fix is benchmarked on V8 and JavaScriptCore.
A type-aware linter that only cares about speed. Every fix says what it guarantees, and every fix is benchmarked on V8 and JavaScriptCore.
$ npx @optilint/cli srcOther ways to install →summary.ts 4:41 high spread-in-accumulator Spreading `acc` copies the accumulator on every step (O(n²)); mutate it instead. typed 5:37 high lookup-in-loop `.find()` scans the array on every iteration (O(n·m)); build a Map keyed by what you match on once outside the loop. 6:22 medium filter-first `.filter(...)[0]` scans the whole array; use `.find(...)`. assumed 7:37 medium regex-to-string-method This regex matches plain text; a string method is faster. typed 8:3 high sequential-await 2 independent awaits run one after another; start them together with `Promise.all`. assumed 10:68 low date-now Allocates a Date just to read the time; use `Date.now()`. exact ✖ 6 findings (3 high, 2 medium, 1 low) · 3 fixable with --fix, 2 more with --tier assumed / --obscure
Real output of optilint 0.0.5, regenerated on every build.
A rewrite is only worth applying if it keeps your program correct. Every fix carries a tier, and --fix applies the first two by default.
Same behaviour for every input.
new Date().getTime() → Date.now()Same behaviour for every input the types allow. The TypeScript checker proves the receiver is an array, a string, a Map.
xs.filter(f).length > 0 → xs.some(f)Correct when the stated assumption holds, such as "these awaits are independent". --fix leaves them out unless you ask.
await a(); await b(); → Promise.allEach fix is benchmarked before and after on Node (V8) and Bun (JavaScriptCore), at every compiler tier from the interpreter up. A fix that measured slower is retired, and rules over your maxSlowdown don't run.
Findings as annotations on the pull request diff, with an optional SARIF upload to code scanning.
Pretty, JSON, SARIF or GitHub output, a cache for unchanged files, and exit codes CI understands.
Diagnostics with quick fixes, fix-all, a sidebar grouped by tier and optilint.json completion.
An MCP server (lint, fix, rules) and an agent skill that teaches the tiers.
optilint --ui lists findings by tier and applies only the fixes you tick.
No config needed: run it in the project root and it lints what git lists, with your tsconfig.