3 Commits

Author SHA1 Message Date
Aiden Bai 914e5f3aee feat: leaderboard in README + dedicated /leaderboard page (#176)
* docs(readme): add leaderboard section with top 10 from benchmarks repo

Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>

* ci(leaderboard): refresh README leaderboard from benchmarks json on schedule

Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>

* feat(website): add /leaderboard page driven by react-doctor-benchmarks

Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>

* chore(scripts): drop bench:scores in favor of leaderboard.json

Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>

* docs(readme): trim leaderboard table to repo + score

Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>

* docs(readme): drop raw-results link from leaderboard section

Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>

* fix(scripts): make update-leaderboard idempotent against formatter

Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>

* refactor(website): extract score thresholds, color, label, doctor face to shared utils

Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Aiden Bai <aidenybai@users.noreply.github.com>
2026-05-08 05:58:36 -07:00
Aiden Bai 4fb4d27e85 fix(react-doctor): forward reactMajorVersion in programmatic diagnose() + cleanups (#174)
* fix(react-doctor): forward reactMajorVersion in programmatic diagnose() + cleanups

H1 (regression introduced by #172) — `diagnose()` in `src/index.ts`
forgot to forward `reactMajorVersion` to `runOxlint`. After the
directional version-gating change in #172, that meant every
"prefer-newer-api" rule (today: `prefer-use-effect-event`) was silently
skipped for every programmatic API consumer, even on React 19+
projects. The CLI (`scan.ts`) was unaffected because it always passed
the version explicitly.

Fix is one line + one import — mirror what `scan.ts` already does.
Added `tests/diagnose.test.ts` with a regression test that asserts
`prefer-use-effect-event` fires on a React 19 fixture, plus a
symmetric guard that it stays skipped when the React version can't
be parsed (e.g. a github: range).

H2 — updated the stale docstring on `runOxlint`'s `reactMajorVersion`
field. The doc still claimed "`null` means unknown — leave those
rules enabled" but after #172 the null branch is directional
(deprecation-warning rules stay on, prefer-newer-api rules go off).

M1 — `SUB_HANDLER_DIRECT_CALLEE_NAMES` was just an alias of
`TIMER_AND_SCHEDULER_DIRECT_CALLEE_NAMES`. Both names existed for
narrative reasons in different files; knip flagged the duplicate
export. Collapsed to the canonical name and updated the one consumer
(`isCallExpressionWithSubHandlerCallee` in state-and-effects).

L1 — moved `walkInsideStatementBlocks` from inline in
`state-and-effects.ts` to `plugin/helpers.ts` next to its sibling
`walkAst`. It already had four call sites and is the natural
"synchronous-only" walker for any rule asking what runs inside an
effect's own body — colocating with `walkAst` makes future rules
discover it.

L2 (audit finding) — proposed receiver-gating
`post`/`put`/`patch` in `EVENT_TRIGGERED_SIDE_EFFECT_CALLEES`
INTENTIONALLY NOT TAKEN. The canonical "You Might Not Need an Effect"
§6 example is `post(jsonToSubmit)` as a bare callee, so removing
those names breaks textbook detection (3 existing tests / fixtures).
Documented the trade-off in the constants.ts docstring.

Validation
- 642 tests passing (640 baseline + 2 new diagnose-API regressions)
- typecheck / lint / format clean

Co-authored-by: Cursor <cursoragent@cursor.com>

* chore: format scripts/benchmark-scores.ts

Pre-existing formatting issue introduced in 6afdc04 — the script was
committed unformatted, breaking `pnpm format:check` on every PR
branched off main since. Picked up by rebasing this PR.

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 03:53:18 -07:00
Nisarg Patel 6afdc04ba7 chore(package): add benchmark scores script to package.json 2026-05-08 03:39:21 -07:00