eslint-plugin-react-hooks 7.0.0-canary-1873ad79-20251015 → 7.0.0-canary-1324e1bb-20251016
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -16,8 +16,8 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
16
16
|
|
|
17
17
|
var core$1 = require('@babel/core');
|
|
18
18
|
var BabelParser = require('@babel/parser');
|
|
19
|
-
var
|
|
20
|
-
var
|
|
19
|
+
var v4 = require('zod/v4');
|
|
20
|
+
var v4$1 = require('zod-validation-error/v4');
|
|
21
21
|
var crypto = require('crypto');
|
|
22
22
|
var HermesParser = require('hermes-parser');
|
|
23
23
|
var util = require('util');
|
|
@@ -18303,7 +18303,7 @@ function getRuleForCategoryImpl(category) {
|
|
|
18303
18303
|
category,
|
|
18304
18304
|
severity: ErrorSeverity.Error,
|
|
18305
18305
|
name: 'void-use-memo',
|
|
18306
|
-
description: 'Validates that useMemos always return a value. See [`useMemo()` docs](https://react.dev/reference/react/useMemo) for more information.',
|
|
18306
|
+
description: 'Validates that useMemos always return a value and that the result of the useMemo is used by the component/hook. See [`useMemo()` docs](https://react.dev/reference/react/useMemo) for more information.',
|
|
18307
18307
|
preset: LintRulePreset.RecommendedLatest,
|
|
18308
18308
|
};
|
|
18309
18309
|
}
|
|
@@ -18735,7 +18735,7 @@ var ValueKind;
|
|
|
18735
18735
|
ValueKind["Mutable"] = "mutable";
|
|
18736
18736
|
ValueKind["Context"] = "context";
|
|
18737
18737
|
})(ValueKind || (ValueKind = {}));
|
|
18738
|
-
const ValueKindSchema =
|
|
18738
|
+
const ValueKindSchema = v4.z.enum([
|
|
18739
18739
|
ValueKind.MaybeFrozen,
|
|
18740
18740
|
ValueKind.Frozen,
|
|
18741
18741
|
ValueKind.Primitive,
|
|
@@ -18743,7 +18743,7 @@ const ValueKindSchema = zod.z.enum([
|
|
|
18743
18743
|
ValueKind.Mutable,
|
|
18744
18744
|
ValueKind.Context,
|
|
18745
18745
|
]);
|
|
18746
|
-
const ValueReasonSchema =
|
|
18746
|
+
const ValueReasonSchema = v4.z.enum([
|
|
18747
18747
|
ValueReason.Context,
|
|
18748
18748
|
ValueReason.Effect,
|
|
18749
18749
|
ValueReason.Global,
|
|
@@ -18767,7 +18767,7 @@ var Effect;
|
|
|
18767
18767
|
Effect["Mutate"] = "mutate";
|
|
18768
18768
|
Effect["Store"] = "store";
|
|
18769
18769
|
})(Effect || (Effect = {}));
|
|
18770
|
-
const EffectSchema =
|
|
18770
|
+
const EffectSchema = v4.z.enum([
|
|
18771
18771
|
Effect.Read,
|
|
18772
18772
|
Effect.Mutate,
|
|
18773
18773
|
Effect.ConditionallyMutate,
|
|
@@ -31322,85 +31322,85 @@ function getReanimatedModuleType(registry) {
|
|
|
31322
31322
|
return addObject(registry, null, reanimatedType);
|
|
31323
31323
|
}
|
|
31324
31324
|
|
|
31325
|
-
const ObjectPropertiesSchema =
|
|
31326
|
-
.record(
|
|
31325
|
+
const ObjectPropertiesSchema = v4.z
|
|
31326
|
+
.record(v4.z.string(), v4.z.lazy(() => TypeSchema))
|
|
31327
31327
|
.refine(record => {
|
|
31328
31328
|
return Object.keys(record).every(key => key === '*' || key === 'default' || libExports$1.isValidIdentifier(key));
|
|
31329
31329
|
}, 'Expected all "object" property names to be valid identifier, `*` to match any property, of `default` to define a module default export');
|
|
31330
|
-
const ObjectTypeSchema =
|
|
31331
|
-
kind:
|
|
31330
|
+
const ObjectTypeSchema = v4.z.object({
|
|
31331
|
+
kind: v4.z.literal('object'),
|
|
31332
31332
|
properties: ObjectPropertiesSchema.nullable(),
|
|
31333
31333
|
});
|
|
31334
|
-
const LifetimeIdSchema =
|
|
31334
|
+
const LifetimeIdSchema = v4.z.string().refine(id => id.startsWith('@'), {
|
|
31335
31335
|
message: "Placeholder names must start with '@'",
|
|
31336
31336
|
});
|
|
31337
|
-
const FreezeEffectSchema =
|
|
31338
|
-
kind:
|
|
31337
|
+
const FreezeEffectSchema = v4.z.object({
|
|
31338
|
+
kind: v4.z.literal('Freeze'),
|
|
31339
31339
|
value: LifetimeIdSchema,
|
|
31340
31340
|
reason: ValueReasonSchema,
|
|
31341
31341
|
});
|
|
31342
|
-
const MutateEffectSchema =
|
|
31343
|
-
kind:
|
|
31342
|
+
const MutateEffectSchema = v4.z.object({
|
|
31343
|
+
kind: v4.z.literal('Mutate'),
|
|
31344
31344
|
value: LifetimeIdSchema,
|
|
31345
31345
|
});
|
|
31346
|
-
const MutateTransitiveConditionallySchema =
|
|
31347
|
-
kind:
|
|
31346
|
+
const MutateTransitiveConditionallySchema = v4.z.object({
|
|
31347
|
+
kind: v4.z.literal('MutateTransitiveConditionally'),
|
|
31348
31348
|
value: LifetimeIdSchema,
|
|
31349
31349
|
});
|
|
31350
|
-
const CreateEffectSchema =
|
|
31351
|
-
kind:
|
|
31350
|
+
const CreateEffectSchema = v4.z.object({
|
|
31351
|
+
kind: v4.z.literal('Create'),
|
|
31352
31352
|
into: LifetimeIdSchema,
|
|
31353
31353
|
value: ValueKindSchema,
|
|
31354
31354
|
reason: ValueReasonSchema,
|
|
31355
31355
|
});
|
|
31356
|
-
const AssignEffectSchema =
|
|
31357
|
-
kind:
|
|
31356
|
+
const AssignEffectSchema = v4.z.object({
|
|
31357
|
+
kind: v4.z.literal('Assign'),
|
|
31358
31358
|
from: LifetimeIdSchema,
|
|
31359
31359
|
into: LifetimeIdSchema,
|
|
31360
31360
|
});
|
|
31361
|
-
const AliasEffectSchema =
|
|
31362
|
-
kind:
|
|
31361
|
+
const AliasEffectSchema = v4.z.object({
|
|
31362
|
+
kind: v4.z.literal('Alias'),
|
|
31363
31363
|
from: LifetimeIdSchema,
|
|
31364
31364
|
into: LifetimeIdSchema,
|
|
31365
31365
|
});
|
|
31366
|
-
const ImmutableCaptureEffectSchema =
|
|
31367
|
-
kind:
|
|
31366
|
+
const ImmutableCaptureEffectSchema = v4.z.object({
|
|
31367
|
+
kind: v4.z.literal('ImmutableCapture'),
|
|
31368
31368
|
from: LifetimeIdSchema,
|
|
31369
31369
|
into: LifetimeIdSchema,
|
|
31370
31370
|
});
|
|
31371
|
-
const CaptureEffectSchema =
|
|
31372
|
-
kind:
|
|
31371
|
+
const CaptureEffectSchema = v4.z.object({
|
|
31372
|
+
kind: v4.z.literal('Capture'),
|
|
31373
31373
|
from: LifetimeIdSchema,
|
|
31374
31374
|
into: LifetimeIdSchema,
|
|
31375
31375
|
});
|
|
31376
|
-
const CreateFromEffectSchema =
|
|
31377
|
-
kind:
|
|
31376
|
+
const CreateFromEffectSchema = v4.z.object({
|
|
31377
|
+
kind: v4.z.literal('CreateFrom'),
|
|
31378
31378
|
from: LifetimeIdSchema,
|
|
31379
31379
|
into: LifetimeIdSchema,
|
|
31380
31380
|
});
|
|
31381
|
-
const ApplyArgSchema =
|
|
31381
|
+
const ApplyArgSchema = v4.z.union([
|
|
31382
31382
|
LifetimeIdSchema,
|
|
31383
|
-
|
|
31384
|
-
kind:
|
|
31383
|
+
v4.z.object({
|
|
31384
|
+
kind: v4.z.literal('Spread'),
|
|
31385
31385
|
place: LifetimeIdSchema,
|
|
31386
31386
|
}),
|
|
31387
|
-
|
|
31388
|
-
kind:
|
|
31387
|
+
v4.z.object({
|
|
31388
|
+
kind: v4.z.literal('Hole'),
|
|
31389
31389
|
}),
|
|
31390
31390
|
]);
|
|
31391
|
-
const ApplyEffectSchema =
|
|
31392
|
-
kind:
|
|
31391
|
+
const ApplyEffectSchema = v4.z.object({
|
|
31392
|
+
kind: v4.z.literal('Apply'),
|
|
31393
31393
|
receiver: LifetimeIdSchema,
|
|
31394
31394
|
function: LifetimeIdSchema,
|
|
31395
|
-
mutatesFunction:
|
|
31396
|
-
args:
|
|
31395
|
+
mutatesFunction: v4.z.boolean(),
|
|
31396
|
+
args: v4.z.array(ApplyArgSchema),
|
|
31397
31397
|
into: LifetimeIdSchema,
|
|
31398
31398
|
});
|
|
31399
|
-
const ImpureEffectSchema =
|
|
31400
|
-
kind:
|
|
31399
|
+
const ImpureEffectSchema = v4.z.object({
|
|
31400
|
+
kind: v4.z.literal('Impure'),
|
|
31401
31401
|
place: LifetimeIdSchema,
|
|
31402
31402
|
});
|
|
31403
|
-
const AliasingEffectSchema =
|
|
31403
|
+
const AliasingEffectSchema = v4.z.union([
|
|
31404
31404
|
FreezeEffectSchema,
|
|
31405
31405
|
CreateEffectSchema,
|
|
31406
31406
|
CreateFromEffectSchema,
|
|
@@ -31413,50 +31413,50 @@ const AliasingEffectSchema = zod.z.union([
|
|
|
31413
31413
|
MutateTransitiveConditionallySchema,
|
|
31414
31414
|
ApplyEffectSchema,
|
|
31415
31415
|
]);
|
|
31416
|
-
const AliasingSignatureSchema =
|
|
31416
|
+
const AliasingSignatureSchema = v4.z.object({
|
|
31417
31417
|
receiver: LifetimeIdSchema,
|
|
31418
|
-
params:
|
|
31418
|
+
params: v4.z.array(LifetimeIdSchema),
|
|
31419
31419
|
rest: LifetimeIdSchema.nullable(),
|
|
31420
31420
|
returns: LifetimeIdSchema,
|
|
31421
|
-
effects:
|
|
31422
|
-
temporaries:
|
|
31421
|
+
effects: v4.z.array(AliasingEffectSchema),
|
|
31422
|
+
temporaries: v4.z.array(LifetimeIdSchema),
|
|
31423
31423
|
});
|
|
31424
|
-
const FunctionTypeSchema =
|
|
31425
|
-
kind:
|
|
31426
|
-
positionalParams:
|
|
31424
|
+
const FunctionTypeSchema = v4.z.object({
|
|
31425
|
+
kind: v4.z.literal('function'),
|
|
31426
|
+
positionalParams: v4.z.array(EffectSchema),
|
|
31427
31427
|
restParam: EffectSchema.nullable(),
|
|
31428
31428
|
calleeEffect: EffectSchema,
|
|
31429
|
-
returnType:
|
|
31429
|
+
returnType: v4.z.lazy(() => TypeSchema),
|
|
31430
31430
|
returnValueKind: ValueKindSchema,
|
|
31431
|
-
noAlias:
|
|
31432
|
-
mutableOnlyIfOperandsAreMutable:
|
|
31433
|
-
impure:
|
|
31434
|
-
canonicalName:
|
|
31431
|
+
noAlias: v4.z.boolean().nullable().optional(),
|
|
31432
|
+
mutableOnlyIfOperandsAreMutable: v4.z.boolean().nullable().optional(),
|
|
31433
|
+
impure: v4.z.boolean().nullable().optional(),
|
|
31434
|
+
canonicalName: v4.z.string().nullable().optional(),
|
|
31435
31435
|
aliasing: AliasingSignatureSchema.nullable().optional(),
|
|
31436
|
-
knownIncompatible:
|
|
31436
|
+
knownIncompatible: v4.z.string().nullable().optional(),
|
|
31437
31437
|
});
|
|
31438
|
-
const HookTypeSchema =
|
|
31439
|
-
kind:
|
|
31440
|
-
positionalParams:
|
|
31438
|
+
const HookTypeSchema = v4.z.object({
|
|
31439
|
+
kind: v4.z.literal('hook'),
|
|
31440
|
+
positionalParams: v4.z.array(EffectSchema).nullable().optional(),
|
|
31441
31441
|
restParam: EffectSchema.nullable().optional(),
|
|
31442
|
-
returnType:
|
|
31442
|
+
returnType: v4.z.lazy(() => TypeSchema),
|
|
31443
31443
|
returnValueKind: ValueKindSchema.nullable().optional(),
|
|
31444
|
-
noAlias:
|
|
31444
|
+
noAlias: v4.z.boolean().nullable().optional(),
|
|
31445
31445
|
aliasing: AliasingSignatureSchema.nullable().optional(),
|
|
31446
|
-
knownIncompatible:
|
|
31446
|
+
knownIncompatible: v4.z.string().nullable().optional(),
|
|
31447
31447
|
});
|
|
31448
|
-
const BuiltInTypeSchema =
|
|
31449
|
-
|
|
31450
|
-
|
|
31451
|
-
|
|
31452
|
-
|
|
31453
|
-
|
|
31448
|
+
const BuiltInTypeSchema = v4.z.union([
|
|
31449
|
+
v4.z.literal('Any'),
|
|
31450
|
+
v4.z.literal('Ref'),
|
|
31451
|
+
v4.z.literal('Array'),
|
|
31452
|
+
v4.z.literal('Primitive'),
|
|
31453
|
+
v4.z.literal('MixedReadonly'),
|
|
31454
31454
|
]);
|
|
31455
|
-
const TypeReferenceSchema =
|
|
31456
|
-
kind:
|
|
31455
|
+
const TypeReferenceSchema = v4.z.object({
|
|
31456
|
+
kind: v4.z.literal('type'),
|
|
31457
31457
|
name: BuiltInTypeSchema,
|
|
31458
31458
|
});
|
|
31459
|
-
const TypeSchema =
|
|
31459
|
+
const TypeSchema = v4.z.union([
|
|
31460
31460
|
ObjectTypeSchema,
|
|
31461
31461
|
FunctionTypeSchema,
|
|
31462
31462
|
HookTypeSchema,
|
|
@@ -32052,96 +32052,96 @@ function defaultModuleTypeProvider(moduleName) {
|
|
|
32052
32052
|
}
|
|
32053
32053
|
|
|
32054
32054
|
var _Environment_instances, _Environment_globals, _Environment_shapes, _Environment_moduleTypes, _Environment_nextIdentifer, _Environment_nextBlock, _Environment_nextScope, _Environment_scope, _Environment_outlinedFunctions, _Environment_contextIdentifiers, _Environment_hoistedIdentifiers, _Environment_flowTypeEnvironment, _Environment_resolveModuleType, _Environment_isKnownReactModule, _Environment_getCustomHookType;
|
|
32055
|
-
const ReactElementSymbolSchema =
|
|
32056
|
-
elementSymbol:
|
|
32057
|
-
|
|
32058
|
-
|
|
32055
|
+
const ReactElementSymbolSchema = v4.z.object({
|
|
32056
|
+
elementSymbol: v4.z.union([
|
|
32057
|
+
v4.z.literal('react.element'),
|
|
32058
|
+
v4.z.literal('react.transitional.element'),
|
|
32059
32059
|
]),
|
|
32060
|
-
globalDevVar:
|
|
32060
|
+
globalDevVar: v4.z.string(),
|
|
32061
32061
|
});
|
|
32062
|
-
const ExternalFunctionSchema =
|
|
32063
|
-
source:
|
|
32064
|
-
importSpecifierName:
|
|
32062
|
+
const ExternalFunctionSchema = v4.z.object({
|
|
32063
|
+
source: v4.z.string(),
|
|
32064
|
+
importSpecifierName: v4.z.string(),
|
|
32065
32065
|
});
|
|
32066
|
-
const InstrumentationSchema =
|
|
32066
|
+
const InstrumentationSchema = v4.z
|
|
32067
32067
|
.object({
|
|
32068
32068
|
fn: ExternalFunctionSchema,
|
|
32069
32069
|
gating: ExternalFunctionSchema.nullable(),
|
|
32070
|
-
globalGating:
|
|
32070
|
+
globalGating: v4.z.string().nullable(),
|
|
32071
32071
|
})
|
|
32072
32072
|
.refine(opts => opts.gating != null || opts.globalGating != null, 'Expected at least one of gating or globalGating');
|
|
32073
32073
|
const USE_FIRE_FUNCTION_NAME = 'useFire';
|
|
32074
32074
|
const EMIT_FREEZE_GLOBAL_GATING = 'true';
|
|
32075
|
-
const MacroMethodSchema =
|
|
32076
|
-
|
|
32077
|
-
|
|
32075
|
+
const MacroMethodSchema = v4.z.union([
|
|
32076
|
+
v4.z.object({ type: v4.z.literal('wildcard') }),
|
|
32077
|
+
v4.z.object({ type: v4.z.literal('name'), name: v4.z.string() }),
|
|
32078
32078
|
]);
|
|
32079
|
-
const MacroSchema =
|
|
32080
|
-
|
|
32081
|
-
|
|
32079
|
+
const MacroSchema = v4.z.union([
|
|
32080
|
+
v4.z.string(),
|
|
32081
|
+
v4.z.tuple([v4.z.string(), v4.z.array(MacroMethodSchema)]),
|
|
32082
32082
|
]);
|
|
32083
|
-
const HookSchema =
|
|
32084
|
-
effectKind:
|
|
32085
|
-
valueKind:
|
|
32086
|
-
noAlias:
|
|
32087
|
-
transitiveMixedData:
|
|
32083
|
+
const HookSchema = v4.z.object({
|
|
32084
|
+
effectKind: v4.z.nativeEnum(Effect),
|
|
32085
|
+
valueKind: v4.z.nativeEnum(ValueKind),
|
|
32086
|
+
noAlias: v4.z.boolean().default(false),
|
|
32087
|
+
transitiveMixedData: v4.z.boolean().default(false),
|
|
32088
32088
|
});
|
|
32089
|
-
const EnvironmentConfigSchema =
|
|
32090
|
-
customHooks:
|
|
32091
|
-
moduleTypeProvider:
|
|
32092
|
-
customMacros:
|
|
32093
|
-
enableResetCacheOnSourceFileChanges:
|
|
32094
|
-
enablePreserveExistingMemoizationGuarantees:
|
|
32095
|
-
validatePreserveExistingMemoizationGuarantees:
|
|
32096
|
-
enablePreserveExistingManualUseMemo:
|
|
32097
|
-
enableForest:
|
|
32098
|
-
enableUseTypeAnnotations:
|
|
32099
|
-
flowTypeProvider:
|
|
32100
|
-
enableOptionalDependencies:
|
|
32101
|
-
enableFire:
|
|
32102
|
-
enableNameAnonymousFunctions:
|
|
32103
|
-
inferEffectDependencies:
|
|
32104
|
-
.nullable(
|
|
32089
|
+
const EnvironmentConfigSchema = v4.z.object({
|
|
32090
|
+
customHooks: v4.z.map(v4.z.string(), HookSchema).default(new Map()),
|
|
32091
|
+
moduleTypeProvider: v4.z.nullable(v4.z.any()).default(null),
|
|
32092
|
+
customMacros: v4.z.nullable(v4.z.array(MacroSchema)).default(null),
|
|
32093
|
+
enableResetCacheOnSourceFileChanges: v4.z.nullable(v4.z.boolean()).default(null),
|
|
32094
|
+
enablePreserveExistingMemoizationGuarantees: v4.z.boolean().default(true),
|
|
32095
|
+
validatePreserveExistingMemoizationGuarantees: v4.z.boolean().default(true),
|
|
32096
|
+
enablePreserveExistingManualUseMemo: v4.z.boolean().default(false),
|
|
32097
|
+
enableForest: v4.z.boolean().default(false),
|
|
32098
|
+
enableUseTypeAnnotations: v4.z.boolean().default(false),
|
|
32099
|
+
flowTypeProvider: v4.z.nullable(v4.z.any()).default(null),
|
|
32100
|
+
enableOptionalDependencies: v4.z.boolean().default(true),
|
|
32101
|
+
enableFire: v4.z.boolean().default(false),
|
|
32102
|
+
enableNameAnonymousFunctions: v4.z.boolean().default(false),
|
|
32103
|
+
inferEffectDependencies: v4.z
|
|
32104
|
+
.nullable(v4.z.array(v4.z.object({
|
|
32105
32105
|
function: ExternalFunctionSchema,
|
|
32106
|
-
autodepsIndex:
|
|
32106
|
+
autodepsIndex: v4.z.number().min(1, 'autodepsIndex must be > 0'),
|
|
32107
32107
|
})))
|
|
32108
32108
|
.default(null),
|
|
32109
32109
|
inlineJsxTransform: ReactElementSymbolSchema.nullable().default(null),
|
|
32110
|
-
validateHooksUsage:
|
|
32111
|
-
validateRefAccessDuringRender:
|
|
32112
|
-
validateNoSetStateInRender:
|
|
32113
|
-
validateNoSetStateInEffects:
|
|
32114
|
-
validateNoDerivedComputationsInEffects:
|
|
32115
|
-
validateNoJSXInTryStatements:
|
|
32116
|
-
validateStaticComponents:
|
|
32117
|
-
validateMemoizedEffectDependencies:
|
|
32118
|
-
validateNoCapitalizedCalls:
|
|
32119
|
-
validateBlocklistedImports:
|
|
32120
|
-
validateNoImpureFunctionsInRender:
|
|
32121
|
-
validateNoFreezingKnownMutableFunctions:
|
|
32122
|
-
enableAssumeHooksFollowRulesOfReact:
|
|
32123
|
-
enableTransitivelyFreezeFunctionExpressions:
|
|
32110
|
+
validateHooksUsage: v4.z.boolean().default(true),
|
|
32111
|
+
validateRefAccessDuringRender: v4.z.boolean().default(true),
|
|
32112
|
+
validateNoSetStateInRender: v4.z.boolean().default(true),
|
|
32113
|
+
validateNoSetStateInEffects: v4.z.boolean().default(false),
|
|
32114
|
+
validateNoDerivedComputationsInEffects: v4.z.boolean().default(false),
|
|
32115
|
+
validateNoJSXInTryStatements: v4.z.boolean().default(false),
|
|
32116
|
+
validateStaticComponents: v4.z.boolean().default(false),
|
|
32117
|
+
validateMemoizedEffectDependencies: v4.z.boolean().default(false),
|
|
32118
|
+
validateNoCapitalizedCalls: v4.z.nullable(v4.z.array(v4.z.string())).default(null),
|
|
32119
|
+
validateBlocklistedImports: v4.z.nullable(v4.z.array(v4.z.string())).default(null),
|
|
32120
|
+
validateNoImpureFunctionsInRender: v4.z.boolean().default(false),
|
|
32121
|
+
validateNoFreezingKnownMutableFunctions: v4.z.boolean().default(false),
|
|
32122
|
+
enableAssumeHooksFollowRulesOfReact: v4.z.boolean().default(true),
|
|
32123
|
+
enableTransitivelyFreezeFunctionExpressions: v4.z.boolean().default(true),
|
|
32124
32124
|
enableEmitFreeze: ExternalFunctionSchema.nullable().default(null),
|
|
32125
32125
|
enableEmitHookGuards: ExternalFunctionSchema.nullable().default(null),
|
|
32126
|
-
enableInstructionReordering:
|
|
32127
|
-
enableFunctionOutlining:
|
|
32128
|
-
enableJsxOutlining:
|
|
32126
|
+
enableInstructionReordering: v4.z.boolean().default(false),
|
|
32127
|
+
enableFunctionOutlining: v4.z.boolean().default(true),
|
|
32128
|
+
enableJsxOutlining: v4.z.boolean().default(false),
|
|
32129
32129
|
enableEmitInstrumentForget: InstrumentationSchema.nullable().default(null),
|
|
32130
|
-
assertValidMutableRanges:
|
|
32131
|
-
enableChangeVariableCodegen:
|
|
32132
|
-
enableMemoizationComments:
|
|
32133
|
-
throwUnknownException__testonly:
|
|
32134
|
-
enableTreatFunctionDepsAsConditional:
|
|
32135
|
-
disableMemoizationForDebugging:
|
|
32130
|
+
assertValidMutableRanges: v4.z.boolean().default(false),
|
|
32131
|
+
enableChangeVariableCodegen: v4.z.boolean().default(false),
|
|
32132
|
+
enableMemoizationComments: v4.z.boolean().default(false),
|
|
32133
|
+
throwUnknownException__testonly: v4.z.boolean().default(false),
|
|
32134
|
+
enableTreatFunctionDepsAsConditional: v4.z.boolean().default(false),
|
|
32135
|
+
disableMemoizationForDebugging: v4.z.boolean().default(false),
|
|
32136
32136
|
enableChangeDetectionForDebugging: ExternalFunctionSchema.nullable().default(null),
|
|
32137
|
-
enableCustomTypeDefinitionForReanimated:
|
|
32138
|
-
hookPattern:
|
|
32139
|
-
enableTreatRefLikeIdentifiersAsRefs:
|
|
32140
|
-
enableTreatSetIdentifiersAsStateSetters:
|
|
32137
|
+
enableCustomTypeDefinitionForReanimated: v4.z.boolean().default(false),
|
|
32138
|
+
hookPattern: v4.z.string().nullable().default(null),
|
|
32139
|
+
enableTreatRefLikeIdentifiersAsRefs: v4.z.boolean().default(true),
|
|
32140
|
+
enableTreatSetIdentifiersAsStateSetters: v4.z.boolean().default(false),
|
|
32141
32141
|
lowerContextAccess: ExternalFunctionSchema.nullable().default(null),
|
|
32142
|
-
validateNoVoidUseMemo:
|
|
32143
|
-
validateNoDynamicallyCreatedComponentsOrHooks:
|
|
32144
|
-
enableAllowSetStateFromRefsInEffects:
|
|
32142
|
+
validateNoVoidUseMemo: v4.z.boolean().default(true),
|
|
32143
|
+
validateNoDynamicallyCreatedComponentsOrHooks: v4.z.boolean().default(false),
|
|
32144
|
+
enableAllowSetStateFromRefsInEffects: v4.z.boolean().default(true),
|
|
32145
32145
|
});
|
|
32146
32146
|
class Environment {
|
|
32147
32147
|
constructor(scope, fnType, compilerMode, config, contextIdentifiers, parentFunction, logger, filename, code, programContext) {
|
|
@@ -32518,7 +32518,7 @@ function validateEnvironmentConfig(partialConfig) {
|
|
|
32518
32518
|
}
|
|
32519
32519
|
CompilerError.throwInvalidConfig({
|
|
32520
32520
|
reason: 'Could not validate environment config. Update React Compiler config to fix the error',
|
|
32521
|
-
description: `${
|
|
32521
|
+
description: `${v4$1.fromZodError(config.error)}`,
|
|
32522
32522
|
loc: null,
|
|
32523
32523
|
suggestions: null,
|
|
32524
32524
|
});
|
|
@@ -32530,7 +32530,7 @@ function tryParseExternalFunction(maybeExternalFunction) {
|
|
|
32530
32530
|
}
|
|
32531
32531
|
CompilerError.throwInvalidConfig({
|
|
32532
32532
|
reason: 'Could not parse external function. Update React Compiler config to fix the error',
|
|
32533
|
-
description: `${
|
|
32533
|
+
description: `${v4$1.fromZodError(externalFunction.error)}`,
|
|
32534
32534
|
loc: null,
|
|
32535
32535
|
suggestions: null,
|
|
32536
32536
|
});
|
|
@@ -37130,30 +37130,49 @@ function memoizeFbtAndMacroOperandsInSameScope(fn) {
|
|
|
37130
37130
|
...Array.from(FBT_TAGS).map((tag) => [tag, []]),
|
|
37131
37131
|
...((_a = fn.env.config.customMacros) !== null && _a !== void 0 ? _a : []),
|
|
37132
37132
|
]);
|
|
37133
|
-
const
|
|
37133
|
+
const macroTagsCalls = new Set();
|
|
37134
|
+
const macroValues = new Map();
|
|
37134
37135
|
const macroMethods = new Map();
|
|
37135
|
-
|
|
37136
|
-
|
|
37137
|
-
|
|
37138
|
-
|
|
37139
|
-
|
|
37140
|
-
break;
|
|
37136
|
+
visit$1(fn, fbtMacroTags, macroTagsCalls, macroMethods, macroValues);
|
|
37137
|
+
for (const root of macroValues.keys()) {
|
|
37138
|
+
const scope = root.scope;
|
|
37139
|
+
if (scope == null) {
|
|
37140
|
+
continue;
|
|
37141
37141
|
}
|
|
37142
|
+
if (!macroTagsCalls.has(root.id)) {
|
|
37143
|
+
continue;
|
|
37144
|
+
}
|
|
37145
|
+
mergeScopes(root, scope, macroValues, macroTagsCalls);
|
|
37142
37146
|
}
|
|
37143
|
-
return
|
|
37147
|
+
return macroTagsCalls;
|
|
37144
37148
|
}
|
|
37145
37149
|
const FBT_TAGS = new Set([
|
|
37146
37150
|
'fbt',
|
|
37147
37151
|
'fbt:param',
|
|
37152
|
+
'fbt:enum',
|
|
37153
|
+
'fbt:plural',
|
|
37148
37154
|
'fbs',
|
|
37149
37155
|
'fbs:param',
|
|
37156
|
+
'fbs:enum',
|
|
37157
|
+
'fbs:plural',
|
|
37150
37158
|
]);
|
|
37151
37159
|
const SINGLE_CHILD_FBT_TAGS = new Set([
|
|
37152
37160
|
'fbt:param',
|
|
37153
37161
|
'fbs:param',
|
|
37154
37162
|
]);
|
|
37155
|
-
function visit$1(fn, fbtMacroTags,
|
|
37163
|
+
function visit$1(fn, fbtMacroTags, macroTagsCalls, macroMethods, macroValues) {
|
|
37156
37164
|
for (const [, block] of fn.body.blocks) {
|
|
37165
|
+
for (const phi of block.phis) {
|
|
37166
|
+
const macroOperands = [];
|
|
37167
|
+
for (const operand of phi.operands.values()) {
|
|
37168
|
+
if (macroValues.has(operand.identifier)) {
|
|
37169
|
+
macroOperands.push(operand.identifier);
|
|
37170
|
+
}
|
|
37171
|
+
}
|
|
37172
|
+
if (macroOperands.length !== 0) {
|
|
37173
|
+
macroValues.set(phi.place.identifier, macroOperands);
|
|
37174
|
+
}
|
|
37175
|
+
}
|
|
37157
37176
|
for (const instruction of block.instructions) {
|
|
37158
37177
|
const { lvalue, value } = instruction;
|
|
37159
37178
|
if (lvalue === null) {
|
|
@@ -37162,11 +37181,11 @@ function visit$1(fn, fbtMacroTags, fbtValues, macroMethods) {
|
|
|
37162
37181
|
if (value.kind === 'Primitive' &&
|
|
37163
37182
|
typeof value.value === 'string' &&
|
|
37164
37183
|
matchesExactTag(value.value, fbtMacroTags)) {
|
|
37165
|
-
|
|
37184
|
+
macroTagsCalls.add(lvalue.identifier.id);
|
|
37166
37185
|
}
|
|
37167
37186
|
else if (value.kind === 'LoadGlobal' &&
|
|
37168
37187
|
matchesExactTag(value.binding.name, fbtMacroTags)) {
|
|
37169
|
-
|
|
37188
|
+
macroTagsCalls.add(lvalue.identifier.id);
|
|
37170
37189
|
}
|
|
37171
37190
|
else if (value.kind === 'LoadGlobal' &&
|
|
37172
37191
|
matchTagRoot(value.binding.name, fbtMacroTags) !== null) {
|
|
@@ -37185,7 +37204,7 @@ function visit$1(fn, fbtMacroTags, fbtValues, macroMethods) {
|
|
|
37185
37204
|
newMethods.push(method.slice(1));
|
|
37186
37205
|
}
|
|
37187
37206
|
else {
|
|
37188
|
-
|
|
37207
|
+
macroTagsCalls.add(lvalue.identifier.id);
|
|
37189
37208
|
}
|
|
37190
37209
|
}
|
|
37191
37210
|
}
|
|
@@ -37193,46 +37212,40 @@ function visit$1(fn, fbtMacroTags, fbtValues, macroMethods) {
|
|
|
37193
37212
|
macroMethods.set(lvalue.identifier.id, newMethods);
|
|
37194
37213
|
}
|
|
37195
37214
|
}
|
|
37196
|
-
else if (
|
|
37197
|
-
|
|
37198
|
-
|
|
37199
|
-
continue;
|
|
37200
|
-
}
|
|
37201
|
-
for (const operand of eachReactiveValueOperand(value)) {
|
|
37202
|
-
operand.identifier.scope = fbtScope;
|
|
37203
|
-
expandFbtScopeRange(fbtScope.range, operand.identifier.mutableRange);
|
|
37204
|
-
fbtValues.add(operand.identifier.id);
|
|
37205
|
-
}
|
|
37215
|
+
else if (value.kind === 'PropertyLoad' &&
|
|
37216
|
+
macroTagsCalls.has(value.object.identifier.id)) {
|
|
37217
|
+
macroTagsCalls.add(lvalue.identifier.id);
|
|
37206
37218
|
}
|
|
37207
|
-
else if (isFbtJsxExpression(fbtMacroTags,
|
|
37208
|
-
isFbtJsxChild(
|
|
37209
|
-
|
|
37210
|
-
|
|
37211
|
-
|
|
37212
|
-
}
|
|
37213
|
-
for (const operand of eachReactiveValueOperand(value)) {
|
|
37214
|
-
operand.identifier.scope = fbtScope;
|
|
37215
|
-
expandFbtScopeRange(fbtScope.range, operand.identifier.mutableRange);
|
|
37216
|
-
fbtValues.add(operand.identifier.id);
|
|
37217
|
-
}
|
|
37219
|
+
else if (isFbtJsxExpression(fbtMacroTags, macroTagsCalls, value) ||
|
|
37220
|
+
isFbtJsxChild(macroTagsCalls, lvalue, value) ||
|
|
37221
|
+
isFbtCallExpression(macroTagsCalls, value)) {
|
|
37222
|
+
macroTagsCalls.add(lvalue.identifier.id);
|
|
37223
|
+
macroValues.set(lvalue.identifier, Array.from(eachInstructionValueOperand(value), operand => operand.identifier));
|
|
37218
37224
|
}
|
|
37219
|
-
else if (
|
|
37220
|
-
const
|
|
37221
|
-
|
|
37222
|
-
|
|
37223
|
-
|
|
37224
|
-
for (const operand of eachReactiveValueOperand(value)) {
|
|
37225
|
-
if (operand.identifier.name !== null &&
|
|
37226
|
-
operand.identifier.name.kind === 'named') {
|
|
37227
|
-
continue;
|
|
37225
|
+
else if (Iterable_some(eachInstructionValueOperand(value), operand => macroValues.has(operand.identifier))) {
|
|
37226
|
+
const macroOperands = [];
|
|
37227
|
+
for (const operand of eachInstructionValueOperand(value)) {
|
|
37228
|
+
if (macroValues.has(operand.identifier)) {
|
|
37229
|
+
macroOperands.push(operand.identifier);
|
|
37228
37230
|
}
|
|
37229
|
-
operand.identifier.scope = fbtScope;
|
|
37230
|
-
expandFbtScopeRange(fbtScope.range, operand.identifier.mutableRange);
|
|
37231
37231
|
}
|
|
37232
|
+
macroValues.set(lvalue.identifier, macroOperands);
|
|
37232
37233
|
}
|
|
37233
37234
|
}
|
|
37234
37235
|
}
|
|
37235
37236
|
}
|
|
37237
|
+
function mergeScopes(root, scope, macroValues, macroTagsCalls) {
|
|
37238
|
+
const operands = macroValues.get(root);
|
|
37239
|
+
if (operands == null) {
|
|
37240
|
+
return;
|
|
37241
|
+
}
|
|
37242
|
+
for (const operand of operands) {
|
|
37243
|
+
operand.scope = scope;
|
|
37244
|
+
expandFbtScopeRange(scope.range, operand.mutableRange);
|
|
37245
|
+
macroTagsCalls.add(operand.id);
|
|
37246
|
+
mergeScopes(operand, scope, macroValues, macroTagsCalls);
|
|
37247
|
+
}
|
|
37248
|
+
}
|
|
37236
37249
|
function matchesExactTag(s, tags) {
|
|
37237
37250
|
return Array.from(tags).some(macro => typeof macro === 'string'
|
|
37238
37251
|
? s === macro
|
|
@@ -37256,22 +37269,23 @@ function matchTagRoot(s, tags) {
|
|
|
37256
37269
|
return null;
|
|
37257
37270
|
}
|
|
37258
37271
|
}
|
|
37259
|
-
function isFbtCallExpression(
|
|
37272
|
+
function isFbtCallExpression(macroTagsCalls, value) {
|
|
37260
37273
|
return ((value.kind === 'CallExpression' &&
|
|
37261
|
-
|
|
37262
|
-
(value.kind === 'MethodCall' &&
|
|
37274
|
+
macroTagsCalls.has(value.callee.identifier.id)) ||
|
|
37275
|
+
(value.kind === 'MethodCall' &&
|
|
37276
|
+
macroTagsCalls.has(value.property.identifier.id)));
|
|
37263
37277
|
}
|
|
37264
|
-
function isFbtJsxExpression(fbtMacroTags,
|
|
37278
|
+
function isFbtJsxExpression(fbtMacroTags, macroTagsCalls, value) {
|
|
37265
37279
|
return (value.kind === 'JsxExpression' &&
|
|
37266
37280
|
((value.tag.kind === 'Identifier' &&
|
|
37267
|
-
|
|
37281
|
+
macroTagsCalls.has(value.tag.identifier.id)) ||
|
|
37268
37282
|
(value.tag.kind === 'BuiltinTag' &&
|
|
37269
37283
|
matchesExactTag(value.tag.name, fbtMacroTags))));
|
|
37270
37284
|
}
|
|
37271
|
-
function isFbtJsxChild(
|
|
37285
|
+
function isFbtJsxChild(macroTagsCalls, lvalue, value) {
|
|
37272
37286
|
return ((value.kind === 'JsxExpression' || value.kind === 'JsxFragment') &&
|
|
37273
37287
|
lvalue !== null &&
|
|
37274
|
-
|
|
37288
|
+
macroTagsCalls.has(lvalue.identifier.id));
|
|
37275
37289
|
}
|
|
37276
37290
|
function expandFbtScopeRange(fbtRange, extendWith) {
|
|
37277
37291
|
if (extendWith.start !== 0) {
|
|
@@ -44509,7 +44523,6 @@ function extractManualMemoizationArgs(instr, kind, sidemap, errors) {
|
|
|
44509
44523
|
};
|
|
44510
44524
|
}
|
|
44511
44525
|
function dropManualMemoization(func) {
|
|
44512
|
-
var _a;
|
|
44513
44526
|
const errors = new CompilerError();
|
|
44514
44527
|
const isValidationEnabled = func.env.config.validatePreserveExistingMemoizationGuarantees ||
|
|
44515
44528
|
func.env.config.validateNoSetStateInRender ||
|
|
@@ -44539,26 +44552,6 @@ function dropManualMemoization(func) {
|
|
|
44539
44552
|
if (fnPlace == null) {
|
|
44540
44553
|
continue;
|
|
44541
44554
|
}
|
|
44542
|
-
if (func.env.config.validateNoVoidUseMemo &&
|
|
44543
|
-
manualMemo.kind === 'useMemo') {
|
|
44544
|
-
const funcToCheck = (_a = sidemap.functions.get(fnPlace.identifier.id)) === null || _a === void 0 ? void 0 : _a.value;
|
|
44545
|
-
if (funcToCheck !== undefined && funcToCheck.loweredFunc.func) {
|
|
44546
|
-
if (!hasNonVoidReturn(funcToCheck.loweredFunc.func)) {
|
|
44547
|
-
errors.pushDiagnostic(CompilerDiagnostic.create({
|
|
44548
|
-
category: ErrorCategory.VoidUseMemo,
|
|
44549
|
-
reason: 'useMemo() callbacks must return a value',
|
|
44550
|
-
description: `This ${manualMemo.loadInstr.value.kind === 'PropertyLoad'
|
|
44551
|
-
? 'React.useMemo'
|
|
44552
|
-
: 'useMemo'} callback doesn't return a value. useMemo is for computing and caching values, not for arbitrary side effects`,
|
|
44553
|
-
suggestions: null,
|
|
44554
|
-
}).withDetails({
|
|
44555
|
-
kind: 'error',
|
|
44556
|
-
loc: instr.value.loc,
|
|
44557
|
-
message: 'useMemo() callbacks must return a value',
|
|
44558
|
-
}));
|
|
44559
|
-
}
|
|
44560
|
-
}
|
|
44561
|
-
}
|
|
44562
44555
|
instr.value = getManualMemoizationReplacement(fnPlace, instr.value.loc, manualMemo.kind);
|
|
44563
44556
|
if (isValidationEnabled) {
|
|
44564
44557
|
if (!sidemap.functions.has(fnPlace.identifier.id)) {
|
|
@@ -44670,17 +44663,6 @@ function findOptionalPlaces(fn) {
|
|
|
44670
44663
|
}
|
|
44671
44664
|
return optionals;
|
|
44672
44665
|
}
|
|
44673
|
-
function hasNonVoidReturn(func) {
|
|
44674
|
-
for (const [, block] of func.body.blocks) {
|
|
44675
|
-
if (block.terminal.kind === 'return') {
|
|
44676
|
-
if (block.terminal.returnVariant === 'Explicit' ||
|
|
44677
|
-
block.terminal.returnVariant === 'Implicit') {
|
|
44678
|
-
return true;
|
|
44679
|
-
}
|
|
44680
|
-
}
|
|
44681
|
-
}
|
|
44682
|
-
return false;
|
|
44683
|
-
}
|
|
44684
44666
|
|
|
44685
44667
|
class StableSidemap {
|
|
44686
44668
|
constructor(env) {
|
|
@@ -48124,7 +48106,7 @@ function* generateInstructionTypes(env, names, instr) {
|
|
|
48124
48106
|
});
|
|
48125
48107
|
}
|
|
48126
48108
|
else {
|
|
48127
|
-
|
|
48109
|
+
continue;
|
|
48128
48110
|
}
|
|
48129
48111
|
}
|
|
48130
48112
|
}
|
|
@@ -50163,11 +50145,18 @@ function isUnmemoized(operand, scopes) {
|
|
|
50163
50145
|
|
|
50164
50146
|
function validateUseMemo(fn) {
|
|
50165
50147
|
const errors = new CompilerError();
|
|
50148
|
+
const voidMemoErrors = new CompilerError();
|
|
50166
50149
|
const useMemos = new Set();
|
|
50167
50150
|
const react = new Set();
|
|
50168
50151
|
const functions = new Map();
|
|
50152
|
+
const unusedUseMemos = new Map();
|
|
50169
50153
|
for (const [, block] of fn.body.blocks) {
|
|
50170
50154
|
for (const { lvalue, value } of block.instructions) {
|
|
50155
|
+
if (unusedUseMemos.size !== 0) {
|
|
50156
|
+
for (const operand of eachInstructionValueOperand(value)) {
|
|
50157
|
+
unusedUseMemos.delete(operand.identifier.id);
|
|
50158
|
+
}
|
|
50159
|
+
}
|
|
50171
50160
|
switch (value.kind) {
|
|
50172
50161
|
case 'LoadGlobal': {
|
|
50173
50162
|
if (value.binding.name === 'useMemo') {
|
|
@@ -50192,10 +50181,8 @@ function validateUseMemo(fn) {
|
|
|
50192
50181
|
}
|
|
50193
50182
|
case 'MethodCall':
|
|
50194
50183
|
case 'CallExpression': {
|
|
50195
|
-
const callee = value.kind === 'CallExpression'
|
|
50196
|
-
|
|
50197
|
-
: value.property.identifier.id;
|
|
50198
|
-
const isUseMemo = useMemos.has(callee);
|
|
50184
|
+
const callee = value.kind === 'CallExpression' ? value.callee : value.property;
|
|
50185
|
+
const isUseMemo = useMemos.has(callee.identifier.id);
|
|
50199
50186
|
if (!isUseMemo || value.args.length === 0) {
|
|
50200
50187
|
continue;
|
|
50201
50188
|
}
|
|
@@ -50235,13 +50222,84 @@ function validateUseMemo(fn) {
|
|
|
50235
50222
|
message: 'Async and generator functions are not supported',
|
|
50236
50223
|
}));
|
|
50237
50224
|
}
|
|
50225
|
+
validateNoContextVariableAssignment(body.loweredFunc.func, errors);
|
|
50226
|
+
if (fn.env.config.validateNoVoidUseMemo) {
|
|
50227
|
+
if (!hasNonVoidReturn(body.loweredFunc.func)) {
|
|
50228
|
+
voidMemoErrors.pushDiagnostic(CompilerDiagnostic.create({
|
|
50229
|
+
category: ErrorCategory.VoidUseMemo,
|
|
50230
|
+
reason: 'useMemo() callbacks must return a value',
|
|
50231
|
+
description: `This useMemo() callback doesn't return a value. useMemo() is for computing and caching values, not for arbitrary side effects`,
|
|
50232
|
+
suggestions: null,
|
|
50233
|
+
}).withDetails({
|
|
50234
|
+
kind: 'error',
|
|
50235
|
+
loc: body.loc,
|
|
50236
|
+
message: 'useMemo() callbacks must return a value',
|
|
50237
|
+
}));
|
|
50238
|
+
}
|
|
50239
|
+
else {
|
|
50240
|
+
unusedUseMemos.set(lvalue.identifier.id, callee.loc);
|
|
50241
|
+
}
|
|
50242
|
+
}
|
|
50238
50243
|
break;
|
|
50239
50244
|
}
|
|
50240
50245
|
}
|
|
50241
50246
|
}
|
|
50247
|
+
if (unusedUseMemos.size !== 0) {
|
|
50248
|
+
for (const operand of eachTerminalOperand(block.terminal)) {
|
|
50249
|
+
unusedUseMemos.delete(operand.identifier.id);
|
|
50250
|
+
}
|
|
50251
|
+
}
|
|
50252
|
+
}
|
|
50253
|
+
if (unusedUseMemos.size !== 0) {
|
|
50254
|
+
for (const loc of unusedUseMemos.values()) {
|
|
50255
|
+
voidMemoErrors.pushDiagnostic(CompilerDiagnostic.create({
|
|
50256
|
+
category: ErrorCategory.VoidUseMemo,
|
|
50257
|
+
reason: 'useMemo() result is unused',
|
|
50258
|
+
description: `This useMemo() value is unused. useMemo() is for computing and caching values, not for arbitrary side effects`,
|
|
50259
|
+
suggestions: null,
|
|
50260
|
+
}).withDetails({
|
|
50261
|
+
kind: 'error',
|
|
50262
|
+
loc,
|
|
50263
|
+
message: 'useMemo() result is unused',
|
|
50264
|
+
}));
|
|
50265
|
+
}
|
|
50242
50266
|
}
|
|
50267
|
+
fn.env.logErrors(voidMemoErrors.asResult());
|
|
50243
50268
|
return errors.asResult();
|
|
50244
50269
|
}
|
|
50270
|
+
function validateNoContextVariableAssignment(fn, errors) {
|
|
50271
|
+
for (const block of fn.body.blocks.values()) {
|
|
50272
|
+
for (const instr of block.instructions) {
|
|
50273
|
+
const value = instr.value;
|
|
50274
|
+
switch (value.kind) {
|
|
50275
|
+
case 'StoreContext': {
|
|
50276
|
+
errors.pushDiagnostic(CompilerDiagnostic.create({
|
|
50277
|
+
category: ErrorCategory.UseMemo,
|
|
50278
|
+
reason: 'useMemo() callbacks may not reassign variables declared outside of the callback',
|
|
50279
|
+
description: 'useMemo() callbacks must be pure functions and cannot reassign variables defined outside of the callback function',
|
|
50280
|
+
suggestions: null,
|
|
50281
|
+
}).withDetails({
|
|
50282
|
+
kind: 'error',
|
|
50283
|
+
loc: value.lvalue.place.loc,
|
|
50284
|
+
message: 'Cannot reassign variable',
|
|
50285
|
+
}));
|
|
50286
|
+
break;
|
|
50287
|
+
}
|
|
50288
|
+
}
|
|
50289
|
+
}
|
|
50290
|
+
}
|
|
50291
|
+
}
|
|
50292
|
+
function hasNonVoidReturn(func) {
|
|
50293
|
+
for (const [, block] of func.body.blocks) {
|
|
50294
|
+
if (block.terminal.kind === 'return') {
|
|
50295
|
+
if (block.terminal.returnVariant === 'Explicit' ||
|
|
50296
|
+
block.terminal.returnVariant === 'Implicit') {
|
|
50297
|
+
return true;
|
|
50298
|
+
}
|
|
50299
|
+
}
|
|
50300
|
+
}
|
|
50301
|
+
return false;
|
|
50302
|
+
}
|
|
50245
50303
|
|
|
50246
50304
|
function validateLocalsNotReassignedAfterRender(fn) {
|
|
50247
50305
|
const contextVariables = new Set();
|
|
@@ -53686,27 +53744,27 @@ function isNonNamespacedImport(importDeclPath) {
|
|
|
53686
53744
|
importDeclPath.node.importKind !== 'typeof');
|
|
53687
53745
|
}
|
|
53688
53746
|
|
|
53689
|
-
|
|
53747
|
+
v4.z.enum([
|
|
53690
53748
|
'all_errors',
|
|
53691
53749
|
'critical_errors',
|
|
53692
53750
|
'none',
|
|
53693
53751
|
]);
|
|
53694
|
-
const DynamicGatingOptionsSchema =
|
|
53695
|
-
source:
|
|
53752
|
+
const DynamicGatingOptionsSchema = v4.z.object({
|
|
53753
|
+
source: v4.z.string(),
|
|
53696
53754
|
});
|
|
53697
|
-
const CustomOptOutDirectiveSchema =
|
|
53698
|
-
.nullable(
|
|
53755
|
+
const CustomOptOutDirectiveSchema = v4.z
|
|
53756
|
+
.nullable(v4.z.array(v4.z.string()))
|
|
53699
53757
|
.default(null);
|
|
53700
|
-
const CompilerReactTargetSchema =
|
|
53701
|
-
|
|
53702
|
-
|
|
53703
|
-
|
|
53704
|
-
|
|
53705
|
-
kind:
|
|
53706
|
-
runtimeModule:
|
|
53758
|
+
const CompilerReactTargetSchema = v4.z.union([
|
|
53759
|
+
v4.z.literal('17'),
|
|
53760
|
+
v4.z.literal('18'),
|
|
53761
|
+
v4.z.literal('19'),
|
|
53762
|
+
v4.z.object({
|
|
53763
|
+
kind: v4.z.literal('donotuse_meta_internal'),
|
|
53764
|
+
runtimeModule: v4.z.string().default('react'),
|
|
53707
53765
|
}),
|
|
53708
53766
|
]);
|
|
53709
|
-
|
|
53767
|
+
v4.z.enum([
|
|
53710
53768
|
'infer',
|
|
53711
53769
|
'syntax',
|
|
53712
53770
|
'annotation',
|
|
@@ -53779,7 +53837,7 @@ function parsePluginOptions(obj) {
|
|
|
53779
53837
|
else {
|
|
53780
53838
|
CompilerError.throwInvalidConfig({
|
|
53781
53839
|
reason: 'Could not parse dynamic gating. Update React Compiler config to fix the error',
|
|
53782
|
-
description: `${
|
|
53840
|
+
description: `${v4$1.fromZodError(result.error)}`,
|
|
53783
53841
|
loc: null,
|
|
53784
53842
|
suggestions: null,
|
|
53785
53843
|
});
|
|
@@ -53795,7 +53853,7 @@ function parsePluginOptions(obj) {
|
|
|
53795
53853
|
else {
|
|
53796
53854
|
CompilerError.throwInvalidConfig({
|
|
53797
53855
|
reason: 'Could not parse custom opt out directives. Update React Compiler config to fix the error',
|
|
53798
|
-
description: `${
|
|
53856
|
+
description: `${v4$1.fromZodError(result.error)}`,
|
|
53799
53857
|
loc: null,
|
|
53800
53858
|
suggestions: null,
|
|
53801
53859
|
});
|
|
@@ -53818,7 +53876,7 @@ function parseTargetConfig(value) {
|
|
|
53818
53876
|
else {
|
|
53819
53877
|
CompilerError.throwInvalidConfig({
|
|
53820
53878
|
reason: 'Not a valid target',
|
|
53821
|
-
description: `${
|
|
53879
|
+
description: `${v4$1.fromZodError(parsed.error)}`,
|
|
53822
53880
|
suggestions: null,
|
|
53823
53881
|
loc: null,
|
|
53824
53882
|
});
|
|
@@ -57332,6 +57390,10 @@ function isUseEffectEventIdentifier(node) {
|
|
|
57332
57390
|
return node.type === 'Identifier' && node.name === 'useEffectEvent';
|
|
57333
57391
|
}
|
|
57334
57392
|
function useEffectEventError(fn, called) {
|
|
57393
|
+
if (fn === null) {
|
|
57394
|
+
return (`React Hook "useEffectEvent" can only be called at the top level of your component.` +
|
|
57395
|
+
` It cannot be passed down.`);
|
|
57396
|
+
}
|
|
57335
57397
|
return (`\`${fn}\` is a function created with React Hook "useEffectEvent", and can only be called from ` +
|
|
57336
57398
|
'Effects and Effect Events in the same component.' +
|
|
57337
57399
|
(called ? '' : ' It cannot be assigned to a variable or passed down.'));
|
|
@@ -57631,6 +57693,7 @@ const rule = {
|
|
|
57631
57693
|
analyzer.leaveNode(node);
|
|
57632
57694
|
},
|
|
57633
57695
|
CallExpression(node) {
|
|
57696
|
+
var _a, _b;
|
|
57634
57697
|
if (isHook(node.callee)) {
|
|
57635
57698
|
const reactHooksMap = last(codePathReactHooksMapStack);
|
|
57636
57699
|
const codePathSegment = last(codePathSegmentStack);
|
|
@@ -57647,6 +57710,15 @@ const rule = {
|
|
|
57647
57710
|
node.arguments.length > 0) {
|
|
57648
57711
|
lastEffect = node;
|
|
57649
57712
|
}
|
|
57713
|
+
if (isUseEffectEventIdentifier(nodeWithoutNamespace) &&
|
|
57714
|
+
((_a = node.parent) === null || _a === void 0 ? void 0 : _a.type) !== 'VariableDeclarator' &&
|
|
57715
|
+
((_b = node.parent) === null || _b === void 0 ? void 0 : _b.type) !== 'ExpressionStatement') {
|
|
57716
|
+
const message = useEffectEventError(null, false);
|
|
57717
|
+
context.report({
|
|
57718
|
+
node,
|
|
57719
|
+
message,
|
|
57720
|
+
});
|
|
57721
|
+
}
|
|
57650
57722
|
},
|
|
57651
57723
|
Identifier(node) {
|
|
57652
57724
|
if (lastEffect == null && useEffectEventFunctions.has(node)) {
|