React rules
These 4 rules layer on top of SAFE-TS's core rules, which also apply inside .tsx/.jsx components and custom hooks (.ts files importing react). All React rules default to errors in the oxlint preset.
react-async-raceerrorAsync
An effect that sets state after its async work finishes (after an await, or in .then), and neither aborts that work nor returns a cleanup.
react-split-stateerrorAsync
A function sets a state to true before an await and back after it (a loading flag), and sets other states after the await (the data, the error).
react-uncached-promiseerrorAsync
use(...) given a promise made while rendering: use(fetch(...)), use(load(id)) where load is an async function, use(new Promise(...)), use(Promise.all(...)), use(x.then(...)).
react-dangerous-htmlerrorSecurity
dangerouslySetInnerHTML with a value that isn't a constant string, an Html or the result of a known sanitizer: the same values markup-sink accepts at innerHTML, and vue-v-html at v-html.
Not duplicated here because eslint-plugin-react-hooks and standard JSX lint rules already cover them: rules of hooks, effect dependency arrays, state updates during render, and list key props. Reading potentially undefined values in JSX is already type-checked by tsc, and React 19 blocks javascript: URLs in href and src directly (Security).
Core rules you'll meet in React components
| Rule | In a component |
|---|---|
must-use-result | a Result returned to an event prop (onClick={save}) (Errors) |
uncaught-propagation | a PropagateError leaving an event handler (Errors) |
floating-rejection | an async handler that can reject (Errors) |
no-param-mutation | changing props (State) |
no-mutable-global | state at the top of a module (State) |
unhandled-failure | JSON.parse in JSX (Setup) |
listener-cleanup | listeners, intervals and observers an effect starts and never stops (Cleanup) |