Skip to content

oxlint: configure react rules - #4155

Merged
nstepien merged 10 commits into
mainfrom
reactrules
Aug 27, 2026
Merged

nstepien merged 10 commits into
mainfrom
reactrules

Conversation

@nstepien

@nstepien nstepien commented Aug 26, 2026 •

Copy link
Copy Markdown
Collaborator

Comment thread .oxlintrc.json Outdated
"react/react-in-jsx-scope": "off",
"react/refs": "warn",
"react/require-render-return": "off",
"react/rule-suppression": "off",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Should we enable this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Enabled all three

Comment thread .oxlintrc.json Outdated
"react/jsx-pascal-case": "off",
"react/jsx-props-no-spread-multi": "off",
"react/jsx-props-no-spreading": "off",
"react/memo-dependencies": "off",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same here?

Comment thread .oxlintrc.json Outdated
"react/display-name": ["warn", { "checkContextObjects": true }],
"react/error-boundaries": "warn",
"react/exhaustive-deps": "warn",
"react/exhaustive-effect-dependencies": "off",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

And this?

Base automatically changed from oxrules to main August 26, 2026 23:23
@codecov-commenter

codecov-commenter commented Aug 27, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.79%. Comparing base (a6e576d) to head (6f75bb6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4155      +/-   ##
==========================================
- Coverage   97.79%   97.79%   -0.01%     
==========================================
  Files          39       39              
  Lines        1589     1587       -2     
  Branches      515      514       -1     
==========================================
- Hits         1554     1552       -2     
  Misses         35       35              
Files with missing lines Coverage Δ
src/EditCell.tsx 96.29% <ø> (-0.14%) ⬇️
src/hooks/useViewportColumns.ts 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nstepien
nstepien marked this pull request as ready for review August 27, 2026 01:18
@nstepien
nstepien requested a review from amanmahajan7 August 27, 2026 01:18
}, [
rowOverscanStartIdx,
rowOverscanEndIdx,
// oxlint-disable-next-line react/memo-dependencies

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this an actual issue?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It's a bug, seems like the rules don't support generator functions well, if at all.

@nstepien
nstepien merged commit 985eda8 into main Aug 27, 2026
3 checks passed
@nstepien
nstepien deleted the reactrules branch August 27, 2026 14:38
nstepien added a commit that referenced this pull request Oct 25, 2026
`vp pack` compiles `src/` with React Compiler, which skips every
component or hook it can't compile. On `main`, it skips `DataGrid`,
`EditCell`, `GroupedRow`, `useCalculatedColumns`, `useColumnWidths`, and
`useViewportRows`. After this PR, all of them are compiled, and if a
bail-out comes back, oxlint reports it and `vp pack` fails in CI.

### Unsupported syntax

- **`useColumnWidths`**: replace `||=` with an `if` statement.
`hasChanges = hasChanges || …` would trip
`eslint/logical-assignment-operators`.
- **`useCalculatedColumns`** / **`useViewportRows`**: replace `x++` on
variables captured by nested functions with `x += 1`.
- Enable `react/todo`, which reports both. It was turned off in #4155,
before React Compiler was set up, while the generators couldn't be
compiled either. #4225 removed them.

### Immutability

- **`GroupedRow`**: `let idx` was incremented in the
`mapViewportColumns` callback when the first rendered column was the
select column, and `GroupCell` compared it with `column.idx`. The
group-by columns follow the select column in `groupBy` order, so
`GroupedRow` now compares each column's key with `groupBy[row.level]`
and passes the result to `GroupCell` as `isLevelMatching`.

### Hoisted functions

- **`DataGrid`**: the `useImperativeHandle` callback read `setPosition`,
which is declared further down. The handle now exposes
`setPositionLatest`, which also keeps its `setActivePosition` stable
across renders, and the `react/immutability` suppression is gone.
- **`EditCell`**: the `useLayoutEffect` cleanup called `cancelTask`,
which was declared after the effect. It's now declared before the
effect, and the cleanup calls it through `useEffectEvent`, like
`commitOnOutsideMouseDown`. A plain call would make it an effect
dependency, and the effect must not clean up between re-renders, as the
comment there explains. `onClose` also moves above the `useEffectEvent`
that calls it. The `TODO: report React Compiler bug` note and its
`react/invariant` suppression are gone.

### Build

- `compiler: { reportDiagnostics: true }` turns the code React Compiler
skips into plugin warnings. `vp pack` already fails on warnings in CI
and agent sessions (`failOnWarn: isAgent || 'ci-only'`), and `vp dev`,
`vp build`, and `vp test` log them. Unlike lint, a suppression comment
doesn't hide them. `panicThreshold: 'all_errors'` would fail every
build, including the dev server and tests while code is being edited,
and `'critical_errors'` misses unsupported syntax like `x++`.
- One `react()` instance now serves both Vite and `vp pack`. It produces
identical `lib/` and website builds, and the same dev-server modules.
`vp pack` can't use `lazyPlugins`, so its plugins were already created
on every config load. The plugin keeps some per-run state, like whether
to emit development JSX, which is fine because Vite and `vp pack` never
run in the same process.
- `.d.ts` files stay excluded: `vp pack` passes the declaration files it
generates through the plugin, and without the exclusion,
`lib/index.d.ts` becomes `export {}`, which publint doesn't catch.
`node_modules` stays excluded too, as setting `exclude` replaces the
plugin's default.
- AGENTS.md mentions that `vp pack` fails on code React Compiler can't
compile.

### Performance

The differences are small, and only a few hold in at least 4 of the 5
rounds:

- Compared to `main`, this PR makes typing in an editor about 10% faster
(4 of 5 rounds) and collapsing or expanding a group about 8% faster (5
of 5). `EditCell` and `GroupedRow` are among the components it now
compiles. Moving the active cell is about 9% slower (5 of 5).
- Without React Compiler, mounting `DataGrid` is about 7% faster (5 of
5) and re-rendering it with the same props about 11% faster (4 of 5).
Mounting `TreeDataGrid` is about 8% slower (5 of 5), and typing in an
editor about 11% slower (4 of 5).
- The other differences go both ways between rounds.

| Update (ms) | `main` | This PR | This PR, no compiler |
| ------------------------------------------ | ------------------ |
------------------ | -------------------- |
| `DataGrid`: mount | 2.26 (2.16–2.32) | 2.26 (2.16–2.34) | 2.09
(1.96–2.18) |
| `DataGrid`: parent re-render, same props | 0.102 (0.095–0.110) | 0.103
(0.094–0.118) | 0.091 (0.084–0.101) |
| `DataGrid`: toggle row selection | 0.216 (0.191–0.251) | 0.224
(0.203–0.235) | 0.222 (0.206–0.242) |
| `DataGrid`: move the active cell | 0.325 (0.314–0.344) | 0.354
(0.334–0.376) | 0.346 (0.307–0.405) |
| `DataGrid`: type in an editor | 0.223 (0.209–0.236) | 0.201
(0.182–0.218) | 0.223 (0.208–0.243) |
| `DataGrid`: scroll down by 4px | 0.171 (0.161–0.182) | 0.160
(0.146–0.176) | 0.170 (0.143–0.192) |
| `DataGrid`: scroll down by one row | 0.329 (0.301–0.362) | 0.327
(0.283–0.414) | 0.319 (0.290–0.364) |
| `DataGrid`: scroll right by 4px | 0.149 (0.140–0.162) | 0.144
(0.127–0.178) | 0.144 (0.124–0.159) |
| `DataGrid`: scroll right by one column | 0.752 (0.672–0.821) | 0.700
(0.601–0.798) | 0.686 (0.623–0.725) |
| `TreeDataGrid`: mount | 3.62 (3.39–3.74) | 3.46 (3.26–3.75) | 3.74
(3.45–4.03) |
| `TreeDataGrid`: scroll down by one row | 0.367 (0.314–0.411) | 0.337
(0.304–0.387) | 0.345 (0.286–0.403) |
| `TreeDataGrid`: collapse or expand a group | 2.40 (2.29–2.52) | 2.21
(1.91–2.39) | 2.17 (1.79–2.47) |

- The grid has 10,000 rows and 41 columns: `SelectColumn`, then 40
columns with `renderTextEditor`, the first of which is frozen.
`TreeDataGrid` also has two columns that group the rows, with all 110
groups expanded. The app around the grid isn't compiled, so each of its
re-renders passes a new `style` object.
- Chromium, React's production build (`NODE_ENV=production`,
`react-dom/client`).
- Each value is the mean of 5 runs, alternating between the three
builds, and the range of the 5 run means is in parentheses. Each run
times 200 updates, one per frame, and 10 mounts.
- Each update is timed with `performance.now()` around a `flushSync`
call. That covers React's render and commit, including layout effects.
It doesn't cover the browser's layout and paint after the commit, and
the scroll scenarios lay out before starting the timer. Chromium rounds
`performance.now()` to 0.1 ms, hence the means.
- Without React Compiler, the grid already memoizes by hand (`memo`,
`useMemo`, `useLatestFunc`). React Compiler adds a memo cache to each
component, which a mount allocates and fills. In `DataGrid`, most
memoized values still change on every render, so its cache mostly adds
comparisons. #4236 fixes that.

`vp run ci` passes.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.

3 participants