Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

chore: enable derived-state effect lint (#10868)

Shahmir Varqha013e4d96ffc4
diff --git a/frontend/.oxlintrc.json b/frontend/.oxlintrc.json
index 5ca7ae03b1..d9f131141a 100644
--- a/frontend/.oxlintrc.json
+++ b/frontend/.oxlintrc.json
@@ -61,7 +61,6 @@
"react/immutability": "off",
"react/incompatible-library": "off",
"react/jsx-no-literals": "off",
- "react/no-deriving-state-in-effects": "off",
"react/no-unstable-nested-components": ["error", { "allowAsProps": true }],
"react/prefer-function-component": "off",
"react/refs": "off",
diff --git a/frontend/src/components/editor/header/filename-input.tsx b/frontend/src/components/editor/header/filename-input.tsx
index 032855d3f6..bb60d1886c 100644
--- a/frontend/src/components/editor/header/filename-input.tsx
+++ b/frontend/src/components/editor/header/filename-input.tsx
@@ -53,6 +53,8 @@ export const FilenameInput = ({
const skipReset = useRef<boolean>(false);
useEffect(() => {
+ // TODO: Reset the editable draft without synchronizing state in an effect.
+ // oxlint-disable-next-line react/no-deriving-state-in-effects -- Reset the editable draft when the external filename changes.
setSearchValue(initialValue);
}, [initialValue]);
diff --git a/frontend/src/hooks/useDebounce.ts b/frontend/src/hooks/useDebounce.ts
index 98d6856455..cd142c41ba 100644
--- a/frontend/src/hooks/useDebounce.ts
+++ b/frontend/src/hooks/useDebounce.ts
@@ -48,6 +48,8 @@ export function useDebounceControlledState<T>(opts: {
// Handle external changes:
useEffect(() => {
+ // TODO: Replace this synchronization with a controlled-state primitive.
+ // oxlint-disable-next-line react/no-deriving-state-in-effects -- Synchronize the debounced draft when the controlled value changes.
setInternalValue(initialValue);
}, [initialValue]);
diff --git a/frontend/src/plugins/impl/FormPlugin.tsx b/frontend/src/plugins/impl/FormPlugin.tsx
index 67e81a2c55..b5ded59b47 100644
--- a/frontend/src/plugins/impl/FormPlugin.tsx
+++ b/frontend/src/plugins/impl/FormPlugin.tsx
@@ -219,6 +219,8 @@ const Form = ({
// The Form may be rendered before the child plugin is, so after mount
// we lookup the plugin once again.
useEffect(() => {
+ // TODO: Replace the post-mount registry lookup with reactive initialization.
+ // oxlint-disable-next-line react/no-deriving-state-in-effects -- The child registry entry may not exist until after the parent mounts.
setInternalValue(UI_ELEMENT_REGISTRY.lookupValue(elementId));
}, [elementId]);
diff --git a/frontend/src/plugins/impl/MatrixPlugin.tsx b/frontend/src/plugins/impl/MatrixPlugin.tsx
index 92358dc6f2..6d8b8e0a38 100644
--- a/frontend/src/plugins/impl/MatrixPlugin.tsx
+++ b/frontend/src/plugins/impl/MatrixPlugin.tsx
@@ -126,6 +126,8 @@ const MatrixComponent = ({
// which avoids stale-state bugs when the matrix shape changes.
const [draft, setDraft] = useState(value);
useEffect(() => {
+ // TODO: Model the active draft without synchronizing state in an effect.
+ // oxlint-disable-next-line react/no-deriving-state-in-effects -- Synchronize the editable draft when the controlled value changes.
setDraft(value);
}, [value]);
const displayValue = activeCell == null ? value : draft;
diff --git a/frontend/src/plugins/impl/RangeSliderPlugin.tsx b/frontend/src/plugins/impl/RangeSliderPlugin.tsx
index 0509a7db3f..6c596505c7 100644
--- a/frontend/src/plugins/impl/RangeSliderPlugin.tsx
+++ b/frontend/src/plugins/impl/RangeSliderPlugin.tsx
@@ -90,6 +90,8 @@ const RangeSliderComponent = ({
// Update internal value on prop change
useEffect(() => {
+ // TODO: Replace this synchronization with a controlled-state primitive.
+ // oxlint-disable-next-line react/no-deriving-state-in-effects -- Synchronize the editable buffer when the controlled value changes.
setInternalValue(value);
}, [value]);
diff --git a/frontend/src/plugins/impl/SliderPlugin.tsx b/frontend/src/plugins/impl/SliderPlugin.tsx
index 08ecebc6ee..c337ebb478 100644
--- a/frontend/src/plugins/impl/SliderPlugin.tsx
+++ b/frontend/src/plugins/impl/SliderPlugin.tsx
@@ -158,6 +158,8 @@ const SliderComponent = ({
const [internalValue, setInternalValue] = useState(value);
// Update internal value on prop change
useEffect(() => {
+ // TODO: Replace this synchronization with a controlled-state primitive.
+ // oxlint-disable-next-line react/no-deriving-state-in-effects -- Synchronize the editable buffer when the controlled value changes.
setInternalValue(value);
}, [value]);