From 422787c1ddadf458dfb3a521243494fdbdc3eb3f Mon Sep 17 00:00:00 2001 From: josephsavona Date: Thu, 16 Oct 2025 13:12:29 -0700 Subject: [PATCH] [compiler] More useMemo validation (#34868) Two additional validations for useMemo: * Disallow reassigning to values declared outside the useMemo callback (always on) * Disallow unused useMemo calls (part of the validateNoVoidUseMemo feature flag, which in turn is off by default) We should probably enable this flag though! --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/34868). * #34855 * #34882 * __->__ #34868 DiffTrain build for [7f5ea1bf67a1a920919ebe2ae6657bdebe505aa0](https://github.com/facebook/react/commit/7f5ea1bf67a1a920919ebe2ae6657bdebe505aa0) --- compiled-rn/VERSION_NATIVE_FB | 2 +- .../react/react-dom/cjs/ReactDOM-dev.js | 4 +- .../react/react-dom/cjs/ReactDOM-prod.js | 4 +- .../react/react-dom/cjs/ReactDOM-profiling.js | 4 +- .../react/react-dom/cjs/ReactDOMClient-dev.js | 12 ++-- .../react-dom/cjs/ReactDOMClient-prod.js | 12 ++-- .../react-dom/cjs/ReactDOMClient-profiling.js | 12 ++-- .../react-dom/cjs/ReactDOMProfiling-dev.js | 12 ++-- .../react-dom/cjs/ReactDOMProfiling-prod.js | 12 ++-- .../cjs/ReactDOMProfiling-profiling.js | 12 ++-- .../cjs/ReactTestRenderer-dev.js | 8 +-- .../cjs/ReactTestRenderer-prod.js | 8 +-- .../cjs/ReactTestRenderer-profiling.js | 8 +-- .../vendor/react/react/cjs/React-dev.js | 4 +- .../vendor/react/react/cjs/React-prod.js | 4 +- .../vendor/react/react/cjs/React-profiling.js | 4 +- .../Libraries/Renderer/REVISION | 2 +- .../implementations/ReactFabric-dev.fb.js | 6 +- .../implementations/ReactFabric-prod.fb.js | 6 +- .../ReactFabric-profiling.fb.js | 6 +- .../ReactNativeRenderer-dev.fb.js | 10 +-- .../ReactNativeRenderer-prod.fb.js | 10 +-- .../ReactNativeRenderer-profiling.fb.js | 10 +-- .../eslint-plugin-react-hooks.development.js | 65 ++++++++++++++++--- .../eslint-plugin-react-hooks.production.js | 65 ++++++++++++++++--- .../eslint-plugin-react-hooks/package.json | 2 +- 26 files changed, 201 insertions(+), 103 deletions(-) diff --git a/compiled-rn/VERSION_NATIVE_FB b/compiled-rn/VERSION_NATIVE_FB index cafc13a88e..dbf0520552 100644 --- a/compiled-rn/VERSION_NATIVE_FB +++ b/compiled-rn/VERSION_NATIVE_FB @@ -1 +1 @@ -19.3.0-native-fb-2381ecc2-20251016 \ No newline at end of file +19.3.0-native-fb-7f5ea1bf-20251016 \ No newline at end of file diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js index f85a7ec40a..e8776f189e 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<02f85e09338414dec512e969ccef61b4>> + * @generated SignedSource<<93f05d103737be9287ee726746a86438>> */ "use strict"; @@ -404,5 +404,5 @@ __DEV__ && exports.useFormStatus = function () { return resolveDispatcher().useHostTransitionStatus(); }; - exports.version = "19.3.0-native-fb-2381ecc2-20251016"; + exports.version = "19.3.0-native-fb-7f5ea1bf-20251016"; })(); diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js index 7a0c6e47df..b0d57ce0f9 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-prod.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<2762d016addc7ef4be11b0622e0ed14c>> + * @generated SignedSource<> */ "use strict"; @@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.3.0-native-fb-2381ecc2-20251016"; +exports.version = "19.3.0-native-fb-7f5ea1bf-20251016"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js index 7a0c6e47df..b0d57ce0f9 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOM-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<2762d016addc7ef4be11b0622e0ed14c>> + * @generated SignedSource<> */ "use strict"; @@ -203,4 +203,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.3.0-native-fb-2381ecc2-20251016"; +exports.version = "19.3.0-native-fb-7f5ea1bf-20251016"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js index d417ccb850..964868ffb1 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<1d5f983ec0e9dae30d45a354c07ad148>> */ /* @@ -30117,11 +30117,11 @@ __DEV__ && }; (function () { var isomorphicReactPackageVersion = React.version; - if ("19.3.0-native-fb-2381ecc2-20251016" !== isomorphicReactPackageVersion) + if ("19.3.0-native-fb-7f5ea1bf-20251016" !== isomorphicReactPackageVersion) throw Error( 'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' + (isomorphicReactPackageVersion + - "\n - react-dom: 19.3.0-native-fb-2381ecc2-20251016\nLearn more: https://react.dev/warnings/version-mismatch") + "\n - react-dom: 19.3.0-native-fb-7f5ea1bf-20251016\nLearn more: https://react.dev/warnings/version-mismatch") ); })(); ("function" === typeof Map && @@ -30158,10 +30158,10 @@ __DEV__ && !(function () { var internals = { bundleType: 1, - version: "19.3.0-native-fb-2381ecc2-20251016", + version: "19.3.0-native-fb-7f5ea1bf-20251016", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016" + reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016" }; internals.overrideHookState = overrideHookState; internals.overrideHookStateDeletePath = overrideHookStateDeletePath; @@ -30311,5 +30311,5 @@ __DEV__ && listenToAllSupportedEvents(container); return new ReactDOMHydrationRoot(initialChildren); }; - exports.version = "19.3.0-native-fb-2381ecc2-20251016"; + exports.version = "19.3.0-native-fb-7f5ea1bf-20251016"; })(); diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js index fa9a699901..550a159bc2 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-prod.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<519110be3010af2965ebbe1441b70c7f>> + * @generated SignedSource<<2330850844a2955f88a2c8a80fd6903a>> */ /* @@ -17581,14 +17581,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) { }; var isomorphicReactPackageVersion$jscomp$inline_2060 = React.version; if ( - "19.3.0-native-fb-2381ecc2-20251016" !== + "19.3.0-native-fb-7f5ea1bf-20251016" !== isomorphicReactPackageVersion$jscomp$inline_2060 ) throw Error( formatProdErrorMessage( 527, isomorphicReactPackageVersion$jscomp$inline_2060, - "19.3.0-native-fb-2381ecc2-20251016" + "19.3.0-native-fb-7f5ea1bf-20251016" ) ); ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { @@ -17610,10 +17610,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { }; var internals$jscomp$inline_2637 = { bundleType: 0, - version: "19.3.0-native-fb-2381ecc2-20251016", + version: "19.3.0-native-fb-7f5ea1bf-20251016", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016" + reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_2638 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -17720,4 +17720,4 @@ exports.hydrateRoot = function (container, initialChildren, options) { listenToAllSupportedEvents(container); return new ReactDOMHydrationRoot(initialChildren); }; -exports.version = "19.3.0-native-fb-2381ecc2-20251016"; +exports.version = "19.3.0-native-fb-7f5ea1bf-20251016"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js index 3e4367ccb6..b505b66468 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMClient-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<09e0d1994fbc8f238fb7e61c35e100f5>> + * @generated SignedSource<> */ /* @@ -19703,14 +19703,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) { }; var isomorphicReactPackageVersion$jscomp$inline_2375 = React.version; if ( - "19.3.0-native-fb-2381ecc2-20251016" !== + "19.3.0-native-fb-7f5ea1bf-20251016" !== isomorphicReactPackageVersion$jscomp$inline_2375 ) throw Error( formatProdErrorMessage( 527, isomorphicReactPackageVersion$jscomp$inline_2375, - "19.3.0-native-fb-2381ecc2-20251016" + "19.3.0-native-fb-7f5ea1bf-20251016" ) ); ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { @@ -19732,10 +19732,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { }; var internals$jscomp$inline_2382 = { bundleType: 0, - version: "19.3.0-native-fb-2381ecc2-20251016", + version: "19.3.0-native-fb-7f5ea1bf-20251016", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016", + reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016", getLaneLabelMap: function () { for ( var map = new Map(), lane = 1, index$332 = 0; @@ -19858,4 +19858,4 @@ exports.hydrateRoot = function (container, initialChildren, options) { listenToAllSupportedEvents(container); return new ReactDOMHydrationRoot(initialChildren); }; -exports.version = "19.3.0-native-fb-2381ecc2-20251016"; +exports.version = "19.3.0-native-fb-7f5ea1bf-20251016"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js index 28835729de..d945eb59b1 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<23a9d5665bf5c0379547e040a4b38f94>> + * @generated SignedSource<<2c793b1cd22627537044383d916f8dce>> */ /* @@ -30173,11 +30173,11 @@ __DEV__ && }; (function () { var isomorphicReactPackageVersion = React.version; - if ("19.3.0-native-fb-2381ecc2-20251016" !== isomorphicReactPackageVersion) + if ("19.3.0-native-fb-7f5ea1bf-20251016" !== isomorphicReactPackageVersion) throw Error( 'Incompatible React versions: The "react" and "react-dom" packages must have the exact same version. Instead got:\n - react: ' + (isomorphicReactPackageVersion + - "\n - react-dom: 19.3.0-native-fb-2381ecc2-20251016\nLearn more: https://react.dev/warnings/version-mismatch") + "\n - react-dom: 19.3.0-native-fb-7f5ea1bf-20251016\nLearn more: https://react.dev/warnings/version-mismatch") ); })(); ("function" === typeof Map && @@ -30214,10 +30214,10 @@ __DEV__ && !(function () { var internals = { bundleType: 1, - version: "19.3.0-native-fb-2381ecc2-20251016", + version: "19.3.0-native-fb-7f5ea1bf-20251016", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016" + reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016" }; internals.overrideHookState = overrideHookState; internals.overrideHookStateDeletePath = overrideHookStateDeletePath; @@ -30683,7 +30683,7 @@ __DEV__ && exports.useFormStatus = function () { return resolveDispatcher().useHostTransitionStatus(); }; - exports.version = "19.3.0-native-fb-2381ecc2-20251016"; + exports.version = "19.3.0-native-fb-7f5ea1bf-20251016"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js index 3beac93b6a..7da0876179 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-prod.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<66ff435cdc7b6739b13c5d68c3114ccd>> + * @generated SignedSource<<7a8af7de4bdb5e42785d4cb67a81d6cd>> */ /* @@ -17592,14 +17592,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) { }; var isomorphicReactPackageVersion$jscomp$inline_2061 = React.version; if ( - "19.3.0-native-fb-2381ecc2-20251016" !== + "19.3.0-native-fb-7f5ea1bf-20251016" !== isomorphicReactPackageVersion$jscomp$inline_2061 ) throw Error( formatProdErrorMessage( 527, isomorphicReactPackageVersion$jscomp$inline_2061, - "19.3.0-native-fb-2381ecc2-20251016" + "19.3.0-native-fb-7f5ea1bf-20251016" ) ); ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { @@ -17621,10 +17621,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { }; var internals$jscomp$inline_2640 = { bundleType: 0, - version: "19.3.0-native-fb-2381ecc2-20251016", + version: "19.3.0-native-fb-7f5ea1bf-20251016", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016" + reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_2641 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -17884,4 +17884,4 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.3.0-native-fb-2381ecc2-20251016"; +exports.version = "19.3.0-native-fb-7f5ea1bf-20251016"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js index a996302b9b..4d1c06fa1f 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-dom/cjs/ReactDOMProfiling-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<9f86df61878df7834008acde03ece1dc>> */ /* @@ -19718,14 +19718,14 @@ ReactDOMHydrationRoot.prototype.unstable_scheduleHydration = function (target) { }; var isomorphicReactPackageVersion$jscomp$inline_2376 = React.version; if ( - "19.3.0-native-fb-2381ecc2-20251016" !== + "19.3.0-native-fb-7f5ea1bf-20251016" !== isomorphicReactPackageVersion$jscomp$inline_2376 ) throw Error( formatProdErrorMessage( 527, isomorphicReactPackageVersion$jscomp$inline_2376, - "19.3.0-native-fb-2381ecc2-20251016" + "19.3.0-native-fb-7f5ea1bf-20251016" ) ); ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { @@ -19747,10 +19747,10 @@ ReactDOMSharedInternals.findDOMNode = function (componentOrElement) { }; var internals$jscomp$inline_2383 = { bundleType: 0, - version: "19.3.0-native-fb-2381ecc2-20251016", + version: "19.3.0-native-fb-7f5ea1bf-20251016", rendererPackageName: "react-dom", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016", + reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016", getLaneLabelMap: function () { for ( var map = new Map(), lane = 1, index$332 = 0; @@ -20026,7 +20026,7 @@ exports.useFormState = function (action, initialState, permalink) { exports.useFormStatus = function () { return ReactSharedInternals.H.useHostTransitionStatus(); }; -exports.version = "19.3.0-native-fb-2381ecc2-20251016"; +exports.version = "19.3.0-native-fb-7f5ea1bf-20251016"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js index c92deb32e1..9dce059991 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<6dade134f772d7a0f2253c3671ef0473>> */ "use strict"; @@ -16021,10 +16021,10 @@ __DEV__ && (function () { var internals = { bundleType: 1, - version: "19.3.0-native-fb-2381ecc2-20251016", + version: "19.3.0-native-fb-7f5ea1bf-20251016", rendererPackageName: "react-test-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016" + reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016" }; internals.overrideHookState = overrideHookState; internals.overrideHookStateDeletePath = overrideHookStateDeletePath; @@ -16170,5 +16170,5 @@ __DEV__ && flushSyncWorkAcrossRoots_impl(0, !0)); } }; - exports.version = "19.3.0-native-fb-2381ecc2-20251016"; + exports.version = "19.3.0-native-fb-7f5ea1bf-20251016"; })(); diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js index c2b2f9d8fd..ab61faa2da 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-prod.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<43bdca4f3f471b48a2c9f152a2f9ffbe>> */ "use strict"; @@ -10110,10 +10110,10 @@ function wrapFiber(fiber) { } var internals$jscomp$inline_1494 = { bundleType: 0, - version: "19.3.0-native-fb-2381ecc2-20251016", + version: "19.3.0-native-fb-7f5ea1bf-20251016", rendererPackageName: "react-test-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016" + reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1495 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -10249,4 +10249,4 @@ exports.unstable_batchedUpdates = function (fn, a) { flushSyncWorkAcrossRoots_impl(0, !0)); } }; -exports.version = "19.3.0-native-fb-2381ecc2-20251016"; +exports.version = "19.3.0-native-fb-7f5ea1bf-20251016"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js index 4360ad1fa3..64adbfb58d 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react-test-renderer/cjs/ReactTestRenderer-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<6d7b38b8802b689ec032b47b6a11450c>> + * @generated SignedSource<> */ "use strict"; @@ -10731,10 +10731,10 @@ function wrapFiber(fiber) { } var internals$jscomp$inline_1275 = { bundleType: 0, - version: "19.3.0-native-fb-2381ecc2-20251016", + version: "19.3.0-native-fb-7f5ea1bf-20251016", rendererPackageName: "react-test-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016", + reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016", getLaneLabelMap: function () { for ( var map = new Map(), lane = 1, index$147 = 0; @@ -10885,4 +10885,4 @@ exports.unstable_batchedUpdates = function (fn, a) { flushSyncWorkAcrossRoots_impl(0, !0)); } }; -exports.version = "19.3.0-native-fb-2381ecc2-20251016"; +exports.version = "19.3.0-native-fb-7f5ea1bf-20251016"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js index 6a039c0cb8..0a6106064c 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-dev.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<23933cbfda2b1357b78f1d04c06e6b6f>> + * @generated SignedSource<<915064a980d0d36bb73ae45015dbab09>> */ "use strict"; @@ -1421,7 +1421,7 @@ __DEV__ && exports.useTransition = function () { return resolveDispatcher().useTransition(); }; - exports.version = "19.3.0-native-fb-2381ecc2-20251016"; + exports.version = "19.3.0-native-fb-7f5ea1bf-20251016"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js index 1edd9a7046..e0d4a90e97 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-prod.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<1c4b009da07f7e1edb7030664a6da637>> + * @generated SignedSource<> */ "use strict"; @@ -586,4 +586,4 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactSharedInternals.H.useTransition(); }; -exports.version = "19.3.0-native-fb-2381ecc2-20251016"; +exports.version = "19.3.0-native-fb-7f5ea1bf-20251016"; diff --git a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js index 5a8c7bd10b..546eb228ba 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js +++ b/compiled-rn/facebook-fbsource/xplat/js/RKJSModules/vendor/react/react/cjs/React-profiling.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<94e24c9a5204078002b6792251f9f602>> */ "use strict"; @@ -590,7 +590,7 @@ exports.useSyncExternalStore = function ( exports.useTransition = function () { return ReactSharedInternals.H.useTransition(); }; -exports.version = "19.3.0-native-fb-2381ecc2-20251016"; +exports.version = "19.3.0-native-fb-7f5ea1bf-20251016"; "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION index c14aee27b1..7d4b090c34 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/REVISION @@ -1 +1 @@ -2381ecc290c588f6366bdcf377529668bb3cc360 +7f5ea1bf67a1a920919ebe2ae6657bdebe505aa0 diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index 62a1ed2280..2dfe1b0a4d 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<2690160d3109526f4f577fbf365c6125>> + * @generated SignedSource<> */ "use strict"; @@ -20085,10 +20085,10 @@ __DEV__ && (function () { var internals = { bundleType: 1, - version: "19.3.0-native-fb-2381ecc2-20251016", + version: "19.3.0-native-fb-7f5ea1bf-20251016", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016" + reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016" }; null !== extraDevToolsConfig && (internals.rendererConfig = extraDevToolsConfig); diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index 3e6aa66c8c..8965155aa2 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<<69a8aba131516cde05b84899b55cc08a>> */ "use strict"; @@ -11269,10 +11269,10 @@ batchedUpdatesImpl = function (fn, a) { var roots = new Map(), internals$jscomp$inline_1321 = { bundleType: 0, - version: "19.3.0-native-fb-2381ecc2-20251016", + version: "19.3.0-native-fb-7f5ea1bf-20251016", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016" + reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016" }; null !== extraDevToolsConfig && (internals$jscomp$inline_1321.rendererConfig = extraDevToolsConfig); diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index 5605b6b5a9..c32d4c1745 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<296bbe4ea6b45c9da56efce644f0194d>> + * @generated SignedSource<> */ "use strict"; @@ -13334,10 +13334,10 @@ batchedUpdatesImpl = function (fn, a) { var roots = new Map(), internals$jscomp$inline_1629 = { bundleType: 0, - version: "19.3.0-native-fb-2381ecc2-20251016", + version: "19.3.0-native-fb-7f5ea1bf-20251016", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016" + reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016" }; null !== extraDevToolsConfig && (internals$jscomp$inline_1629.rendererConfig = extraDevToolsConfig); diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index 38f62ecaad..d809189e55 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ "use strict"; @@ -20354,11 +20354,11 @@ __DEV__ && shouldSuspendImpl = newShouldSuspendImpl; }; var isomorphicReactPackageVersion = React.version; - if ("19.3.0-native-fb-2381ecc2-20251016" !== isomorphicReactPackageVersion) + if ("19.3.0-native-fb-7f5ea1bf-20251016" !== isomorphicReactPackageVersion) throw Error( 'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' + (isomorphicReactPackageVersion + - "\n - react-native-renderer: 19.3.0-native-fb-2381ecc2-20251016\nLearn more: https://react.dev/warnings/version-mismatch") + "\n - react-native-renderer: 19.3.0-native-fb-7f5ea1bf-20251016\nLearn more: https://react.dev/warnings/version-mismatch") ); if ( "function" !== @@ -20384,10 +20384,10 @@ __DEV__ && (function () { var internals = { bundleType: 1, - version: "19.3.0-native-fb-2381ecc2-20251016", + version: "19.3.0-native-fb-7f5ea1bf-20251016", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016" + reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016" }; null !== extraDevToolsConfig && (internals.rendererConfig = extraDevToolsConfig); diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index 6e7a344e4f..696f062d1b 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<13b801bebe3073742aab84745cd367fa>> + * @generated SignedSource<<12cddf0229c1f0ae0e65108658dbc2eb>> */ "use strict"; @@ -11430,11 +11430,11 @@ function updateContainer(element, container, parentComponent, callback) { return lane; } var isomorphicReactPackageVersion = React.version; -if ("19.3.0-native-fb-2381ecc2-20251016" !== isomorphicReactPackageVersion) +if ("19.3.0-native-fb-7f5ea1bf-20251016" !== isomorphicReactPackageVersion) throw Error( 'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' + (isomorphicReactPackageVersion + - "\n - react-native-renderer: 19.3.0-native-fb-2381ecc2-20251016\nLearn more: https://react.dev/warnings/version-mismatch") + "\n - react-native-renderer: 19.3.0-native-fb-7f5ea1bf-20251016\nLearn more: https://react.dev/warnings/version-mismatch") ); if ( "function" !== @@ -11484,10 +11484,10 @@ batchedUpdatesImpl = function (fn, a) { var roots = new Map(), internals$jscomp$inline_1327 = { bundleType: 0, - version: "19.3.0-native-fb-2381ecc2-20251016", + version: "19.3.0-native-fb-7f5ea1bf-20251016", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016" + reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016" }; null !== extraDevToolsConfig && (internals$jscomp$inline_1327.rendererConfig = extraDevToolsConfig); diff --git a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index a69a8cf9f7..513338d48f 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/compiled-rn/facebook-fbsource/xplat/js/react-native-github/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ "use strict"; @@ -13488,11 +13488,11 @@ function updateContainer(element, container, parentComponent, callback) { return lane; } var isomorphicReactPackageVersion = React.version; -if ("19.3.0-native-fb-2381ecc2-20251016" !== isomorphicReactPackageVersion) +if ("19.3.0-native-fb-7f5ea1bf-20251016" !== isomorphicReactPackageVersion) throw Error( 'Incompatible React versions: The "react" and "react-native-renderer" packages must have the exact same version. Instead got:\n - react: ' + (isomorphicReactPackageVersion + - "\n - react-native-renderer: 19.3.0-native-fb-2381ecc2-20251016\nLearn more: https://react.dev/warnings/version-mismatch") + "\n - react-native-renderer: 19.3.0-native-fb-7f5ea1bf-20251016\nLearn more: https://react.dev/warnings/version-mismatch") ); if ( "function" !== @@ -13542,10 +13542,10 @@ batchedUpdatesImpl = function (fn, a) { var roots = new Map(), internals$jscomp$inline_1635 = { bundleType: 0, - version: "19.3.0-native-fb-2381ecc2-20251016", + version: "19.3.0-native-fb-7f5ea1bf-20251016", rendererPackageName: "react-native-renderer", currentDispatcherRef: ReactSharedInternals, - reconcilerVersion: "19.3.0-native-fb-2381ecc2-20251016" + reconcilerVersion: "19.3.0-native-fb-7f5ea1bf-20251016" }; null !== extraDevToolsConfig && (internals$jscomp$inline_1635.rendererConfig = extraDevToolsConfig); diff --git a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js index d175b38923..951de0c2a2 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js +++ b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.development.js @@ -12,7 +12,7 @@ * @lightSyntaxTransform * @preventMunge * @oncall react_core - * @generated SignedSource<> + * @generated SignedSource<<7e2ae6e8c57b3de627e5ebfcbcee88ad>> */ 'use strict'; @@ -44611,8 +44611,8 @@ function dropManualMemoization(func) { category: ErrorCategory.VoidUseMemo, reason: 'useMemo() callbacks must return a value', description: `This ${manualMemo.loadInstr.value.kind === 'PropertyLoad' - ? 'React.useMemo' - : 'useMemo'} callback doesn't return a value. useMemo is for computing and caching values, not for arbitrary side effects`, + ? 'React.useMemo()' + : 'useMemo()'} callback doesn't return a value. useMemo() is for computing and caching values, not for arbitrary side effects`, suggestions: null, }).withDetails({ kind: 'error', @@ -50229,8 +50229,14 @@ function validateUseMemo(fn) { const useMemos = new Set(); const react = new Set(); const functions = new Map(); + const unusedUseMemos = new Map(); for (const [, block] of fn.body.blocks) { for (const { lvalue, value } of block.instructions) { + if (unusedUseMemos.size !== 0) { + for (const operand of eachInstructionValueOperand(value)) { + unusedUseMemos.delete(operand.identifier.id); + } + } switch (value.kind) { case 'LoadGlobal': { if (value.binding.name === 'useMemo') { @@ -50255,10 +50261,8 @@ function validateUseMemo(fn) { } case 'MethodCall': case 'CallExpression': { - const callee = value.kind === 'CallExpression' - ? value.callee.identifier.id - : value.property.identifier.id; - const isUseMemo = useMemos.has(callee); + const callee = value.kind === 'CallExpression' ? value.callee : value.property; + const isUseMemo = useMemos.has(callee.identifier.id); if (!isUseMemo || value.args.length === 0) { continue; } @@ -50298,12 +50302,57 @@ function validateUseMemo(fn) { message: 'Async and generator functions are not supported', })); } + validateNoContextVariableAssignment(body.loweredFunc.func, errors); + if (fn.env.config.validateNoVoidUseMemo) { + unusedUseMemos.set(lvalue.identifier.id, callee.loc); + } + break; + } + } + } + if (unusedUseMemos.size !== 0) { + for (const operand of eachTerminalOperand(block.terminal)) { + unusedUseMemos.delete(operand.identifier.id); + } + } + } + if (unusedUseMemos.size !== 0) { + for (const loc of unusedUseMemos.values()) { + errors.pushDiagnostic(CompilerDiagnostic.create({ + category: ErrorCategory.VoidUseMemo, + reason: 'Unused useMemo()', + description: `This useMemo() value is unused. useMemo() is for computing and caching values, not for arbitrary side effects`, + suggestions: null, + }).withDetails({ + kind: 'error', + loc, + message: 'useMemo() result is unused', + })); + } + } + return errors.asResult(); +} +function validateNoContextVariableAssignment(fn, errors) { + for (const block of fn.body.blocks.values()) { + for (const instr of block.instructions) { + const value = instr.value; + switch (value.kind) { + case 'StoreContext': { + errors.pushDiagnostic(CompilerDiagnostic.create({ + category: ErrorCategory.UseMemo, + reason: 'useMemo() callbacks may not reassign variables declared outside of the callback', + description: 'useMemo() callbacks must be pure functions and cannot reassign variables defined outside of the callback function', + suggestions: null, + }).withDetails({ + kind: 'error', + loc: value.lvalue.place.loc, + message: 'Cannot reassign variable', + })); break; } } } } - return errors.asResult(); } function validateLocalsNotReassignedAfterRender(fn) { diff --git a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js index 6a1d3dcf0d..c6cfdd4c74 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js +++ b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/cjs/eslint-plugin-react-hooks.production.js @@ -6,7 +6,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - * @generated SignedSource<<9079307abbe1c09d1a87c55c574480ba>> + * @generated SignedSource<> */ 'use strict'; @@ -44390,8 +44390,8 @@ function dropManualMemoization(func) { category: ErrorCategory.VoidUseMemo, reason: 'useMemo() callbacks must return a value', description: `This ${manualMemo.loadInstr.value.kind === 'PropertyLoad' - ? 'React.useMemo' - : 'useMemo'} callback doesn't return a value. useMemo is for computing and caching values, not for arbitrary side effects`, + ? 'React.useMemo()' + : 'useMemo()'} callback doesn't return a value. useMemo() is for computing and caching values, not for arbitrary side effects`, suggestions: null, }).withDetails({ kind: 'error', @@ -50008,8 +50008,14 @@ function validateUseMemo(fn) { const useMemos = new Set(); const react = new Set(); const functions = new Map(); + const unusedUseMemos = new Map(); for (const [, block] of fn.body.blocks) { for (const { lvalue, value } of block.instructions) { + if (unusedUseMemos.size !== 0) { + for (const operand of eachInstructionValueOperand(value)) { + unusedUseMemos.delete(operand.identifier.id); + } + } switch (value.kind) { case 'LoadGlobal': { if (value.binding.name === 'useMemo') { @@ -50034,10 +50040,8 @@ function validateUseMemo(fn) { } case 'MethodCall': case 'CallExpression': { - const callee = value.kind === 'CallExpression' - ? value.callee.identifier.id - : value.property.identifier.id; - const isUseMemo = useMemos.has(callee); + const callee = value.kind === 'CallExpression' ? value.callee : value.property; + const isUseMemo = useMemos.has(callee.identifier.id); if (!isUseMemo || value.args.length === 0) { continue; } @@ -50077,12 +50081,57 @@ function validateUseMemo(fn) { message: 'Async and generator functions are not supported', })); } + validateNoContextVariableAssignment(body.loweredFunc.func, errors); + if (fn.env.config.validateNoVoidUseMemo) { + unusedUseMemos.set(lvalue.identifier.id, callee.loc); + } + break; + } + } + } + if (unusedUseMemos.size !== 0) { + for (const operand of eachTerminalOperand(block.terminal)) { + unusedUseMemos.delete(operand.identifier.id); + } + } + } + if (unusedUseMemos.size !== 0) { + for (const loc of unusedUseMemos.values()) { + errors.pushDiagnostic(CompilerDiagnostic.create({ + category: ErrorCategory.VoidUseMemo, + reason: 'Unused useMemo()', + description: `This useMemo() value is unused. useMemo() is for computing and caching values, not for arbitrary side effects`, + suggestions: null, + }).withDetails({ + kind: 'error', + loc, + message: 'useMemo() result is unused', + })); + } + } + return errors.asResult(); +} +function validateNoContextVariableAssignment(fn, errors) { + for (const block of fn.body.blocks.values()) { + for (const instr of block.instructions) { + const value = instr.value; + switch (value.kind) { + case 'StoreContext': { + errors.pushDiagnostic(CompilerDiagnostic.create({ + category: ErrorCategory.UseMemo, + reason: 'useMemo() callbacks may not reassign variables declared outside of the callback', + description: 'useMemo() callbacks must be pure functions and cannot reassign variables defined outside of the callback function', + suggestions: null, + }).withDetails({ + kind: 'error', + loc: value.lvalue.place.loc, + message: 'Cannot reassign variable', + })); break; } } } } - return errors.asResult(); } function validateLocalsNotReassignedAfterRender(fn) { diff --git a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/package.json b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/package.json index 296ef122d4..d07d8cf378 100644 --- a/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/package.json +++ b/compiled-rn/facebook-fbsource/xplat/js/tools/eslint-plugin-react-hooks/package.json @@ -1,7 +1,7 @@ { "name": "eslint-plugin-react-hooks", "description": "ESLint rules for React Hooks", - "version": "0.0.0-experimental-2381ecc2-20251016", + "version": "0.0.0-experimental-7f5ea1bf-20251016", "repository": { "type": "git", "url": "https://github.com/facebook/react.git",