Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/react-doctor/src/oxlint-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ const BUILTIN_A11Y_RULES: Record<string, RuleSeverity> = {
export const GLOBAL_REACT_DOCTOR_RULES: Record<string, RuleSeverity> = {
"react-doctor/no-derived-state-effect": "warn",
"react-doctor/no-fetch-in-effect": "warn",
"react-doctor/no-mirror-prop-effect": "warn",
"react-doctor/no-mutable-in-deps": "error",
"react-doctor/no-cascading-set-state": "warn",
"react-doctor/no-effect-chain": "warn",
"react-doctor/no-effect-event-handler": "warn",
Expand All @@ -247,6 +249,7 @@ export const GLOBAL_REACT_DOCTOR_RULES: Record<string, RuleSeverity> = {
"react-doctor/rerender-state-only-in-handlers": "warn",
"react-doctor/rerender-defer-reads-hook": "warn",
"react-doctor/advanced-event-handler-refs": "warn",
"react-doctor/effect-needs-cleanup": "error",

"react-doctor/no-giant-component": "warn",
"react-doctor/no-render-in-render": "warn",
Expand Down
15 changes: 15 additions & 0 deletions packages/react-doctor/src/plugin/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,21 @@ export const MUTATING_ROUTE_SEGMENTS = new Set([
export const EFFECT_HOOK_NAMES = new Set(["useEffect", "useLayoutEffect"]);
export const HOOKS_WITH_DEPS = new Set(["useEffect", "useLayoutEffect", "useMemo", "useCallback"]);

// Globals whose values mutate outside the React data flow. Listing
// them as deps doesn't trigger a re-run when they change because
// React compares deps with `Object.is` during render — and the read
// happens during render, before the mutation. From "Lifecycle of
// Reactive Effects" — Can global or mutable values be dependencies?
export const MUTABLE_GLOBAL_ROOTS = new Set([
"location",
"window",
"document",
"navigator",
"history",
"screen",
"performance",
]);

// Used by `no-effect-chain` to decide whether an effect is doing
// "real" external-system synchronization (in which case effects on
// either side of the chain are exempt, per the article's own caveat
Expand Down
6 changes: 6 additions & 0 deletions packages/react-doctor/src/plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ import {
} from "./rules/tanstack-start.js";
import {
advancedEventHandlerRefs,
effectNeedsCleanup,
noCascadingSetState,
noDerivedStateEffect,
noDerivedUseState,
Expand All @@ -185,6 +186,8 @@ import {
noEffectEventInDeps,
noEventTriggerState,
noFetchInEffect,
noMirrorPropEffect,
noMutableInDeps,
noPropCallbackInEffect,
noSetStateInRender,
preferUseReducer,
Expand All @@ -203,6 +206,8 @@ const plugin: RulePlugin = {
rules: {
"no-derived-state-effect": noDerivedStateEffect,
"no-fetch-in-effect": noFetchInEffect,
"no-mirror-prop-effect": noMirrorPropEffect,
"no-mutable-in-deps": noMutableInDeps,
"no-cascading-set-state": noCascadingSetState,
"no-effect-chain": noEffectChain,
"no-effect-event-handler": noEffectEventHandler,
Expand All @@ -220,6 +225,7 @@ const plugin: RulePlugin = {
"rerender-state-only-in-handlers": rerenderStateOnlyInHandlers,
"rerender-defer-reads-hook": rerenderDeferReadsHook,
"advanced-event-handler-refs": advancedEventHandlerRefs,
"effect-needs-cleanup": effectNeedsCleanup,

"no-generic-handler-names": noGenericHandlerNames,
"no-giant-component": noGiantComponent,
Expand Down
Loading
Loading