Skip to content

Commit b5356aa

Browse files
committed
[compiler] Add VoidUseMemo rule to RecommendedLatest (#34783)
Adds a new error category VoidUseMemo which is only enabled in the RecommendedLatest preset for now. DiffTrain build for [4b3e662](4b3e662)
1 parent bb67c72 commit b5356aa

35 files changed

+99
-88
lines changed

compiled/eslint-plugin-react-hooks/index.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18005,7 +18005,8 @@ function printErrorSummary(category, message) {
1800518005
case ErrorCategory.StaticComponents:
1800618006
case ErrorCategory.Suppression:
1800718007
case ErrorCategory.Syntax:
18008-
case ErrorCategory.UseMemo: {
18008+
case ErrorCategory.UseMemo:
18009+
case ErrorCategory.VoidUseMemo: {
1800918010
heading = 'Error';
1801018011
break;
1801118012
}
@@ -18036,6 +18037,7 @@ var ErrorCategory;
1803618037
ErrorCategory["CapitalizedCalls"] = "CapitalizedCalls";
1803718038
ErrorCategory["StaticComponents"] = "StaticComponents";
1803818039
ErrorCategory["UseMemo"] = "UseMemo";
18040+
ErrorCategory["VoidUseMemo"] = "VoidUseMemo";
1803918041
ErrorCategory["Factories"] = "Factories";
1804018042
ErrorCategory["PreserveManualMemo"] = "PreserveManualMemo";
1804118043
ErrorCategory["IncompatibleLibrary"] = "IncompatibleLibrary";
@@ -18302,6 +18304,15 @@ function getRuleForCategoryImpl(category) {
1830218304
preset: LintRulePreset.Recommended,
1830318305
};
1830418306
}
18307+
case ErrorCategory.VoidUseMemo: {
18308+
return {
18309+
category,
18310+
severity: ErrorSeverity.Error,
18311+
name: 'void-use-memo',
18312+
description: 'Validates that useMemos always return a value. See [`useMemo()` docs](https://react.dev/reference/react/useMemo) for more information.',
18313+
preset: LintRulePreset.RecommendedLatest,
18314+
};
18315+
}
1830518316
case ErrorCategory.IncompatibleLibrary: {
1830618317
return {
1830718318
category,
@@ -44582,7 +44593,7 @@ function dropManualMemoization(func) {
4458244593
if (funcToCheck !== undefined && funcToCheck.loweredFunc.func) {
4458344594
if (!hasNonVoidReturn(funcToCheck.loweredFunc.func)) {
4458444595
errors.pushDiagnostic(CompilerDiagnostic.create({
44585-
category: ErrorCategory.UseMemo,
44596+
category: ErrorCategory.VoidUseMemo,
4458644597
reason: 'useMemo() callbacks must return a value',
4458744598
description: `This ${manualMemo.loadInstr.value.kind === 'PropertyLoad'
4458844599
? 'React.useMemo'

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3e1b34dc51dfc3cbada2cdd0ead5acee6998f444
1+
4b3e662e4ce54eb54a8701c48a967cc84a389501
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3e1b34dc51dfc3cbada2cdd0ead5acee6998f444
1+
4b3e662e4ce54eb54a8701c48a967cc84a389501

compiled/facebook-www/React-dev.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ __DEV__ &&
14601460
exports.useTransition = function () {
14611461
return resolveDispatcher().useTransition();
14621462
};
1463-
exports.version = "19.3.0-www-classic-3e1b34dc-20251008";
1463+
exports.version = "19.3.0-www-classic-4b3e662e-20251008";
14641464
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14651465
"function" ===
14661466
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-dev.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ __DEV__ &&
14601460
exports.useTransition = function () {
14611461
return resolveDispatcher().useTransition();
14621462
};
1463-
exports.version = "19.3.0-www-modern-3e1b34dc-20251008";
1463+
exports.version = "19.3.0-www-modern-4b3e662e-20251008";
14641464
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14651465
"function" ===
14661466
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-prod.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,4 +606,4 @@ exports.useSyncExternalStore = function (
606606
exports.useTransition = function () {
607607
return ReactSharedInternals.H.useTransition();
608608
};
609-
exports.version = "19.3.0-www-classic-3e1b34dc-20251008";
609+
exports.version = "19.3.0-www-classic-4b3e662e-20251008";

compiled/facebook-www/React-prod.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,4 +606,4 @@ exports.useSyncExternalStore = function (
606606
exports.useTransition = function () {
607607
return ReactSharedInternals.H.useTransition();
608608
};
609-
exports.version = "19.3.0-www-modern-3e1b34dc-20251008";
609+
exports.version = "19.3.0-www-modern-4b3e662e-20251008";

compiled/facebook-www/React-profiling.classic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ exports.useSyncExternalStore = function (
610610
exports.useTransition = function () {
611611
return ReactSharedInternals.H.useTransition();
612612
};
613-
exports.version = "19.3.0-www-classic-3e1b34dc-20251008";
613+
exports.version = "19.3.0-www-classic-4b3e662e-20251008";
614614
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
615615
"function" ===
616616
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/React-profiling.modern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ exports.useSyncExternalStore = function (
610610
exports.useTransition = function () {
611611
return ReactSharedInternals.H.useTransition();
612612
};
613-
exports.version = "19.3.0-www-modern-3e1b34dc-20251008";
613+
exports.version = "19.3.0-www-modern-4b3e662e-20251008";
614614
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
615615
"function" ===
616616
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

compiled/facebook-www/ReactART-dev.classic.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20348,10 +20348,10 @@ __DEV__ &&
2034820348
(function () {
2034920349
var internals = {
2035020350
bundleType: 1,
20351-
version: "19.3.0-www-classic-3e1b34dc-20251008",
20351+
version: "19.3.0-www-classic-4b3e662e-20251008",
2035220352
rendererPackageName: "react-art",
2035320353
currentDispatcherRef: ReactSharedInternals,
20354-
reconcilerVersion: "19.3.0-www-classic-3e1b34dc-20251008"
20354+
reconcilerVersion: "19.3.0-www-classic-4b3e662e-20251008"
2035520355
};
2035620356
internals.overrideHookState = overrideHookState;
2035720357
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -20386,7 +20386,7 @@ __DEV__ &&
2038620386
exports.Shape = Shape;
2038720387
exports.Surface = Surface;
2038820388
exports.Text = Text;
20389-
exports.version = "19.3.0-www-classic-3e1b34dc-20251008";
20389+
exports.version = "19.3.0-www-classic-4b3e662e-20251008";
2039020390
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2039120391
"function" ===
2039220392
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)