Skip to content

Commit e58b03f

Browse files
committed
[compiler] Allow nonreactive stable types as extraneous deps (#35185)
When checking ValidateExhaustiveDeps internally, this seems to be the most common case that it flags. The current exhaustive-deps rule allows extraneous deps if they are a set of stable types. So here we reuse our existing isStableType() util in the compiler to allow this case. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/35185). * #35201 * #35202 * #35192 * #35190 * #35186 * __->__ #35185 DiffTrain build for [c9a8cf3](c9a8cf3)
1 parent 8c22771 commit e58b03f

35 files changed

+97
-88
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53600,6 +53600,12 @@ function validateExhaustiveDependencies(fn) {
5360053600
}
5360153601
extra.push(dep);
5360253602
}
53603+
retainWhere(extra, dep => {
53604+
const isNonReactiveStableValue = dep.root.kind === 'NamedLocal' &&
53605+
!dep.root.value.reactive &&
53606+
isStableType(dep.root.value.identifier);
53607+
return !isNonReactiveStableValue;
53608+
});
5360353609
if (missing.length !== 0 || extra.length !== 0) {
5360453610
let suggestions = null;
5360553611
if (startMemo.depsLoc != null && typeof startMemo.depsLoc !== 'symbol') {
@@ -54428,7 +54434,7 @@ function findProgramSuppressions(programComments, ruleNames, flowSuppressions) {
5442854434
let disableNextLinePattern = null;
5442954435
let disablePattern = null;
5443054436
let enablePattern = null;
54431-
if (ruleNames.length !== 0) {
54437+
if (ruleNames != null && ruleNames.length !== 0) {
5443254438
const rulePattern = `(${ruleNames.join('|')})`;
5443354439
disableNextLinePattern = new RegExp(`eslint-disable-next-line ${rulePattern}`);
5443454440
disablePattern = new RegExp(`eslint-disable ${rulePattern}`);
@@ -54765,7 +54771,10 @@ function compileProgram(program, pass) {
5476554771
handleError(restrictedImportsErr, pass, null);
5476654772
return null;
5476754773
}
54768-
const suppressions = findProgramSuppressions(pass.comments, (_a = pass.opts.eslintSuppressionRules) !== null && _a !== void 0 ? _a : DEFAULT_ESLINT_SUPPRESSIONS, pass.opts.flowSuppressions);
54774+
const suppressions = findProgramSuppressions(pass.comments, pass.opts.environment.validateExhaustiveMemoizationDependencies &&
54775+
pass.opts.environment.validateHooksUsage
54776+
? null
54777+
: ((_a = pass.opts.eslintSuppressionRules) !== null && _a !== void 0 ? _a : DEFAULT_ESLINT_SUPPRESSIONS), pass.opts.flowSuppressions);
5476954778
const programContext = new ProgramContext({
5477054779
program: program,
5477154780
opts: pass.opts,

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
fd524fe02a86c3e92a207d90da970941320f337f
1+
c9a8cf3411baed43d4e24fab6ec895768b297fd2
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
fd524fe02a86c3e92a207d90da970941320f337f
1+
c9a8cf3411baed43d4e24fab6ec895768b297fd2

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ __DEV__ &&
14991499
exports.useTransition = function () {
15001500
return resolveDispatcher().useTransition();
15011501
};
1502-
exports.version = "19.3.0-www-classic-fd524fe0-20251121";
1502+
exports.version = "19.3.0-www-classic-c9a8cf34-20251124";
15031503
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
15041504
"function" ===
15051505
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
@@ -1499,7 +1499,7 @@ __DEV__ &&
14991499
exports.useTransition = function () {
15001500
return resolveDispatcher().useTransition();
15011501
};
1502-
exports.version = "19.3.0-www-modern-fd524fe0-20251121";
1502+
exports.version = "19.3.0-www-modern-c9a8cf34-20251124";
15031503
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
15041504
"function" ===
15051505
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-fd524fe0-20251121";
609+
exports.version = "19.3.0-www-classic-c9a8cf34-20251124";

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-fd524fe0-20251121";
609+
exports.version = "19.3.0-www-modern-c9a8cf34-20251124";

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-fd524fe0-20251121";
613+
exports.version = "19.3.0-www-classic-c9a8cf34-20251124";
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-fd524fe0-20251121";
613+
exports.version = "19.3.0-www-modern-c9a8cf34-20251124";
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
@@ -20468,10 +20468,10 @@ __DEV__ &&
2046820468
(function () {
2046920469
var internals = {
2047020470
bundleType: 1,
20471-
version: "19.3.0-www-classic-fd524fe0-20251121",
20471+
version: "19.3.0-www-classic-c9a8cf34-20251124",
2047220472
rendererPackageName: "react-art",
2047320473
currentDispatcherRef: ReactSharedInternals,
20474-
reconcilerVersion: "19.3.0-www-classic-fd524fe0-20251121"
20474+
reconcilerVersion: "19.3.0-www-classic-c9a8cf34-20251124"
2047520475
};
2047620476
internals.overrideHookState = overrideHookState;
2047720477
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -20506,7 +20506,7 @@ __DEV__ &&
2050620506
exports.Shape = Shape;
2050720507
exports.Surface = Surface;
2050820508
exports.Text = Text;
20509-
exports.version = "19.3.0-www-classic-fd524fe0-20251121";
20509+
exports.version = "19.3.0-www-classic-c9a8cf34-20251124";
2051020510
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
2051120511
"function" ===
2051220512
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)