Skip to content

Commit 7c29a16

Browse files
chore(lint): enforce react/immutability
1 parent 2760bc8 commit 7c29a16

10 files changed

Lines changed: 37 additions & 32 deletions

‎apps/mobile/src/features/layout/workspace-inspector-pane.tsx‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,12 @@ export function WorkspaceInspectorPane(props: {
3636

3737
const onClosed = props.onClosed;
3838
useEffect(() => {
39-
inspectorProgress.value = withTiming(
40-
inspectorVisible ? 1 : 0,
41-
WORKSPACE_PANE_TIMING,
42-
(finished) => {
39+
inspectorProgress.set(
40+
withTiming(inspectorVisible ? 1 : 0, WORKSPACE_PANE_TIMING, (finished) => {
4341
if (finished === true && !inspectorVisible && onClosed !== undefined) {
4442
runOnJS(onClosed)();
4543
}
46-
},
44+
}),
4745
);
4846
const targetWidth = inspectorVisible ? (inspectorWidth ?? 0) : 0;
4947
renderedInspectorWidth.set(
@@ -61,10 +59,10 @@ export function WorkspaceInspectorPane(props: {
6159
useEffect(() => {
6260
const targetWidth = inspectorWidth ?? 0;
6361
if (!inspectorVisible || resizing) {
64-
renderedContentWidth.value = targetWidth;
62+
renderedContentWidth.set(targetWidth);
6563
return;
6664
}
67-
renderedContentWidth.value = withTiming(targetWidth, WORKSPACE_PANE_TIMING);
65+
renderedContentWidth.set(withTiming(targetWidth, WORKSPACE_PANE_TIMING));
6866
}, [inspectorVisible, inspectorWidth, renderedContentWidth, resizing]);
6967

7068
const inspectorStyle = useAnimatedStyle(

‎apps/mobile/src/features/threads/PendingUserInputCard.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
8787
}
8888
// The card resizes with the keyboard every frame, so easing each sample would leave the
8989
// feed inset and floating controls trailing it.
90-
cardCoverage.value = Math.max(0, cardHeightRef.current - barHeightRef.current);
90+
cardCoverage.set(Math.max(0, cardHeightRef.current - barHeightRef.current));
9191
}, [cardCoverage]);
9292
const handleBarLayout = useCallback(
9393
(event: LayoutChangeEvent) => {
@@ -99,7 +99,7 @@ export function PendingUserInputCard(props: PendingUserInputCardProps) {
9999
const handleCardLayout = useCallback(
100100
(event: LayoutChangeEvent) => {
101101
cardHeightRef.current = event.nativeEvent.layout.height;
102-
cardHeight.value = event.nativeEvent.layout.height;
102+
cardHeight.set(event.nativeEvent.layout.height);
103103
notifyCoverage();
104104
},
105105
[cardHeight, notifyCoverage],

‎apps/mobile/src/features/threads/ThreadComposer.tsx‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,12 +385,14 @@ export function ComposerSurface(props: {
385385
const animatedBorderRadius = useSharedValue(targetBorderRadius);
386386
const shouldAnimate = props.animateLayout !== false && Platform.OS !== "android";
387387
useLayoutEffect(() => {
388-
animatedBorderRadius.value = shouldAnimate
389-
? withTiming(targetBorderRadius, {
390-
duration: COMPOSER_TRANSITION_DURATION_MS,
391-
reduceMotion: ReduceMotion.System,
392-
})
393-
: targetBorderRadius;
388+
animatedBorderRadius.set(
389+
shouldAnimate
390+
? withTiming(targetBorderRadius, {
391+
duration: COMPOSER_TRANSITION_DURATION_MS,
392+
reduceMotion: ReduceMotion.System,
393+
})
394+
: targetBorderRadius,
395+
);
394396
}, [animatedBorderRadius, shouldAnimate, targetBorderRadius]);
395397
const borderCurve = props.style.borderCurve;
396398
const animatedShapeStyle = useAnimatedStyle(() => ({

‎apps/mobile/src/features/threads/ThreadDetailScreen.tsx‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -968,9 +968,11 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
968968
showFloatingStatus ? FLOATING_WORKING_CONTROL_COVERAGE : 0,
969969
);
970970
useEffect(() => {
971-
floatingControlCoverage.value = withTiming(
972-
showFloatingStatus ? FLOATING_WORKING_CONTROL_COVERAGE : 0,
973-
{ duration: 180, reduceMotion: ReduceMotion.System },
971+
floatingControlCoverage.set(
972+
withTiming(showFloatingStatus ? FLOATING_WORKING_CONTROL_COVERAGE : 0, {
973+
duration: 180,
974+
reduceMotion: ReduceMotion.System,
975+
}),
974976
);
975977
}, [floatingControlCoverage, showFloatingStatus]);
976978
// Android measures its expanded card in-flow; only iOS needs extra overlay coverage.
@@ -984,7 +986,7 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
984986
floatingControlCoverage.value +
985987
(userInputCoverageApplies ? userInputInsetProgress.value * userInputCardCoverage.value : 0),
986988
(value) => {
987-
combinedContentInsetEndAdjustment.value = value;
989+
combinedContentInsetEndAdjustment.set(value);
988990
},
989991
[userInputCoverageApplies],
990992
);

‎apps/mobile/src/features/threads/floating-working-control.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export function FloatingWorkingControl(props: {
105105
const separationProgress = useSharedValue(props.showScrollToEnd ? 1 : 0);
106106

107107
useEffect(() => {
108-
separationProgress.value = withTiming(props.showScrollToEnd ? 1 : 0, CONTROL_TIMING);
108+
separationProgress.set(withTiming(props.showScrollToEnd ? 1 : 0, CONTROL_TIMING));
109109
}, [props.showScrollToEnd, separationProgress]);
110110

111111
const lift = props.lift;
@@ -129,14 +129,14 @@ export function FloatingWorkingControl(props: {
129129
}
130130
const first = measuredWidthRef.current === null;
131131
measuredWidthRef.current = width;
132-
capsuleWidth.value = first ? width : withTiming(width, CONTROL_TIMING);
132+
capsuleWidth.set(first ? width : withTiming(width, CONTROL_TIMING));
133133
};
134134
const hasStatus = props.status !== null;
135135
const hasCapsule = hasStatus || hasQueue || hasAgents || hasPreview;
136136
useEffect(() => {
137137
if (!hasStatus) {
138138
measuredWidthRef.current = null;
139-
capsuleWidth.value = null;
139+
capsuleWidth.set(null);
140140
}
141141
}, [capsuleWidth, hasStatus]);
142142
const capsuleStyle = useAnimatedStyle(() => ({

‎apps/mobile/src/features/threads/thread-work-log.tsx‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,12 @@ export function ThreadDisclosureChevron(props: {
172172
const rotation = useSharedValue(props.expanded ? expandedAngle : 0);
173173

174174
useLayoutEffect(() => {
175-
rotation.value = withTiming(props.expanded ? expandedAngle : 0, {
176-
duration: THREAD_DISCLOSURE_TRANSITION_MS,
177-
reduceMotion: ReduceMotion.System,
178-
});
175+
rotation.set(
176+
withTiming(props.expanded ? expandedAngle : 0, {
177+
duration: THREAD_DISCLOSURE_TRANSITION_MS,
178+
reduceMotion: ReduceMotion.System,
179+
}),
180+
);
179181
}, [expandedAngle, props.expanded, rotation]);
180182

181183
const rotationStyle = useAnimatedStyle(() => ({

‎apps/mobile/src/features/voice-input/ComposerDictationControl.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export function ComposerDictationDraftContent(props: {
9090
}) {
9191
const rotation = useSharedValue(props.hidden ? 1 : 0);
9292
useLayoutEffect(() => {
93-
rotation.value = withTiming(props.hidden ? 1 : 0, TOOLBAR_FLIP_TIMING);
93+
rotation.set(withTiming(props.hidden ? 1 : 0, TOOLBAR_FLIP_TIMING));
9494
}, [props.hidden, rotation]);
9595
const compact = props.compact;
9696
const animatedStyle = useAnimatedStyle(() => ({
@@ -263,7 +263,7 @@ function VoiceActionButton(props: {
263263
const variant = props.variant ?? "plain";
264264
const loadingVisibility = useSharedValue(props.loading ? 1 : 0);
265265
useLayoutEffect(() => {
266-
loadingVisibility.value = withTiming(props.loading ? 1 : 0, DICTATION_TIMING);
266+
loadingVisibility.set(withTiming(props.loading ? 1 : 0, DICTATION_TIMING));
267267
}, [loadingVisibility, props.loading]);
268268
const primaryStyle = useAnimatedStyle(() => ({ opacity: 1 - loadingVisibility.value }));
269269

@@ -322,7 +322,7 @@ export function ComposerDictationStatus(props: {
322322
}) {
323323
const recordingVisibility = useSharedValue(props.phase === "recording" ? 1 : 0);
324324
useLayoutEffect(() => {
325-
recordingVisibility.value = withTiming(props.phase === "recording" ? 1 : 0, DICTATION_TIMING);
325+
recordingVisibility.set(withTiming(props.phase === "recording" ? 1 : 0, DICTATION_TIMING));
326326
}, [props.phase, recordingVisibility]);
327327
const waveformStyle = useAnimatedStyle(() => ({
328328
opacity: recordingVisibility.value,

‎apps/mobile/src/features/voice-input/GlobalVoiceInputControl.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function EdgeDictationPill(props: { readonly collapseRef: RefObject<(() => void)
6565
const [expanded, setExpanded] = useState(false);
6666
const progress = useSharedValue(0);
6767
useEffect(() => {
68-
progress.value = withTiming(expanded ? 1 : 0, MORPH_TIMING);
68+
progress.set(withTiming(expanded ? 1 : 0, MORPH_TIMING));
6969
}, [expanded, progress]);
7070
const { collapseRef } = props;
7171
useEffect(() => {

‎apps/mobile/src/features/voice-input/VoiceInputProvider.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ function useVoiceInputRuntime() {
195195

196196
if (audioLevelsRef.current.some((level) => level !== 0)) {
197197
audioLevelsRef.current = Array<number>(VOICE_WAVEFORM_SAMPLE_COUNT).fill(0);
198-
audioLevels.value = audioLevelsRef.current;
198+
audioLevels.set(audioLevelsRef.current);
199199
}
200200
if (elapsedSecondsRef.current !== 0) {
201201
elapsedSecondsRef.current = 0;
@@ -213,7 +213,7 @@ function useVoiceInputRuntime() {
213213
if (level !== 0 || history.some((sample) => sample !== 0)) {
214214
const nextLevels = [...history.slice(1), level];
215215
audioLevelsRef.current = nextLevels;
216-
audioLevels.value = nextLevels;
216+
audioLevels.set(nextLevels);
217217
}
218218

219219
const nextElapsedSeconds = Math.min(

‎vite.config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ export default defineConfig({
216216
perf: "warn",
217217
},
218218
rules: {
219+
"react/immutability": "error",
219220
"oxc/no-accumulating-spread": "error",
220221
"react/no-array-index-key": "error",
221222
"react/no-unstable-nested-components": "error",

0 commit comments

Comments
 (0)