Skip to content

Commit e671c74

Browse files
committed
[compiler] Enable additional lints by default (#33752)
Enable more validations to help catch bad patterns, but only in the linter. These rules are already enabled by default in the compiler _if_ violations could produce unsafe output. --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/33752). * #33981 * #33777 * #33767 * #33765 * #33760 * #33759 * #33758 * #33751 * __->__ #33752 * #33753 DiffTrain build for [0d39496](0d39496)
1 parent 97b9414 commit e671c74

35 files changed

+99
-91
lines changed

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30156,7 +30156,7 @@ const EnvironmentConfigSchema = zod.z.object({
3015630156
validateHooksUsage: zod.z.boolean().default(true),
3015730157
validateRefAccessDuringRender: zod.z.boolean().default(true),
3015830158
validateNoSetStateInRender: zod.z.boolean().default(true),
30159-
validateNoSetStateInPassiveEffects: zod.z.boolean().default(false),
30159+
validateNoSetStateInEffects: zod.z.boolean().default(false),
3016030160
validateNoJSXInTryStatements: zod.z.boolean().default(false),
3016130161
validateStaticComponents: zod.z.boolean().default(false),
3016230162
validateMemoizedEffectDependencies: zod.z.boolean().default(false),
@@ -48864,7 +48864,7 @@ function emitArrayInstr(elements, env) {
4886448864
return arrayInstr;
4886548865
}
4886648866

48867-
function validateNoSetStateInPassiveEffects(fn) {
48867+
function validateNoSetStateInEffects(fn) {
4886848868
const setStateFunctions = new Map();
4886948869
const errors = new CompilerError();
4887048870
for (const [, block] of fn.body.blocks) {
@@ -48898,7 +48898,9 @@ function validateNoSetStateInPassiveEffects(fn) {
4889848898
const callee = instr.value.kind === 'MethodCall'
4889948899
? instr.value.receiver
4890048900
: instr.value.callee;
48901-
if (isUseEffectHookType(callee.identifier)) {
48901+
if (isUseEffectHookType(callee.identifier) ||
48902+
isUseLayoutEffectHookType(callee.identifier) ||
48903+
isUseInsertionEffectHookType(callee.identifier)) {
4890248904
const arg = instr.value.args[0];
4890348905
if (arg !== undefined && arg.kind === 'Identifier') {
4890448906
const setState = setStateFunctions.get(arg.identifier.id);
@@ -50118,8 +50120,8 @@ function runWithEnvironment(func, env) {
5011850120
if (env.config.validateNoSetStateInRender) {
5011950121
validateNoSetStateInRender(hir).unwrap();
5012050122
}
50121-
if (env.config.validateNoSetStateInPassiveEffects) {
50122-
env.logErrors(validateNoSetStateInPassiveEffects(hir));
50123+
if (env.config.validateNoSetStateInEffects) {
50124+
env.logErrors(validateNoSetStateInEffects(hir));
5012350125
}
5012450126
if (env.config.validateNoJSXInTryStatements) {
5012550127
env.logErrors(validateNoJSXInTryStatement(hir));
@@ -51947,6 +51949,12 @@ const COMPILER_OPTIONS = {
5194751949
flowSuppressions: false,
5194851950
environment: validateEnvironmentConfig({
5194951951
validateRefAccessDuringRender: false,
51952+
validateNoSetStateInRender: true,
51953+
validateNoSetStateInEffects: true,
51954+
validateNoJSXInTryStatements: true,
51955+
validateNoImpureFunctionsInRender: true,
51956+
validateStaticComponents: true,
51957+
validateNoFreezingKnownMutableFunctions: true,
5195051958
}),
5195151959
};
5195251960
const rule$1 = {

compiled/facebook-www/REVISION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
448f781a52d62042341d2411d1352d705ce2cbfe
1+
0d39496eab710b5a3efc07d34c0db3f2475c04f8
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
448f781a52d62042341d2411d1352d705ce2cbfe
1+
0d39496eab710b5a3efc07d34c0db3f2475c04f8

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1434,7 +1434,7 @@ __DEV__ &&
14341434
exports.useTransition = function () {
14351435
return resolveDispatcher().useTransition();
14361436
};
1437-
exports.version = "19.2.0-www-classic-448f781a-20250724";
1437+
exports.version = "19.2.0-www-classic-0d39496e-20250724";
14381438
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14391439
"function" ===
14401440
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
@@ -1434,7 +1434,7 @@ __DEV__ &&
14341434
exports.useTransition = function () {
14351435
return resolveDispatcher().useTransition();
14361436
};
1437-
exports.version = "19.2.0-www-modern-448f781a-20250724";
1437+
exports.version = "19.2.0-www-modern-0d39496e-20250724";
14381438
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
14391439
"function" ===
14401440
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
@@ -610,4 +610,4 @@ exports.useSyncExternalStore = function (
610610
exports.useTransition = function () {
611611
return ReactSharedInternals.H.useTransition();
612612
};
613-
exports.version = "19.2.0-www-classic-448f781a-20250724";
613+
exports.version = "19.2.0-www-classic-0d39496e-20250724";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,4 +610,4 @@ exports.useSyncExternalStore = function (
610610
exports.useTransition = function () {
611611
return ReactSharedInternals.H.useTransition();
612612
};
613-
exports.version = "19.2.0-www-modern-448f781a-20250724";
613+
exports.version = "19.2.0-www-modern-0d39496e-20250724";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ exports.useSyncExternalStore = function (
614614
exports.useTransition = function () {
615615
return ReactSharedInternals.H.useTransition();
616616
};
617-
exports.version = "19.2.0-www-classic-448f781a-20250724";
617+
exports.version = "19.2.0-www-classic-0d39496e-20250724";
618618
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
619619
"function" ===
620620
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
@@ -614,7 +614,7 @@ exports.useSyncExternalStore = function (
614614
exports.useTransition = function () {
615615
return ReactSharedInternals.H.useTransition();
616616
};
617-
exports.version = "19.2.0-www-modern-448f781a-20250724";
617+
exports.version = "19.2.0-www-modern-0d39496e-20250724";
618618
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
619619
"function" ===
620620
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
@@ -19299,10 +19299,10 @@ __DEV__ &&
1929919299
(function () {
1930019300
var internals = {
1930119301
bundleType: 1,
19302-
version: "19.2.0-www-classic-448f781a-20250724",
19302+
version: "19.2.0-www-classic-0d39496e-20250724",
1930319303
rendererPackageName: "react-art",
1930419304
currentDispatcherRef: ReactSharedInternals,
19305-
reconcilerVersion: "19.2.0-www-classic-448f781a-20250724"
19305+
reconcilerVersion: "19.2.0-www-classic-0d39496e-20250724"
1930619306
};
1930719307
internals.overrideHookState = overrideHookState;
1930819308
internals.overrideHookStateDeletePath = overrideHookStateDeletePath;
@@ -19336,7 +19336,7 @@ __DEV__ &&
1933619336
exports.Shape = Shape;
1933719337
exports.Surface = Surface;
1933819338
exports.Text = Text;
19339-
exports.version = "19.2.0-www-classic-448f781a-20250724";
19339+
exports.version = "19.2.0-www-classic-0d39496e-20250724";
1934019340
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
1934119341
"function" ===
1934219342
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&

0 commit comments

Comments
 (0)