eslint-plugin-react-hooks 7.0.0-canary-93f85932-20251016 → 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 zod = require('zod');
20
- var zodValidationError = require('zod-validation-error');
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 = zod.z.enum([
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 = zod.z.enum([
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 = zod.z.enum([
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 = zod.z
31326
- .record(zod.z.string(), zod.z.lazy(() => TypeSchema))
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 = zod.z.object({
31331
- kind: zod.z.literal('object'),
31330
+ const ObjectTypeSchema = v4.z.object({
31331
+ kind: v4.z.literal('object'),
31332
31332
  properties: ObjectPropertiesSchema.nullable(),
31333
31333
  });
31334
- const LifetimeIdSchema = zod.z.string().refine(id => id.startsWith('@'), {
31334
+ const LifetimeIdSchema = v4.z.string().refine(id => id.startsWith('@'), {
31335
31335
  message: "Placeholder names must start with '@'",
31336
31336
  });
31337
- const FreezeEffectSchema = zod.z.object({
31338
- kind: zod.z.literal('Freeze'),
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 = zod.z.object({
31343
- kind: zod.z.literal('Mutate'),
31342
+ const MutateEffectSchema = v4.z.object({
31343
+ kind: v4.z.literal('Mutate'),
31344
31344
  value: LifetimeIdSchema,
31345
31345
  });
31346
- const MutateTransitiveConditionallySchema = zod.z.object({
31347
- kind: zod.z.literal('MutateTransitiveConditionally'),
31346
+ const MutateTransitiveConditionallySchema = v4.z.object({
31347
+ kind: v4.z.literal('MutateTransitiveConditionally'),
31348
31348
  value: LifetimeIdSchema,
31349
31349
  });
31350
- const CreateEffectSchema = zod.z.object({
31351
- kind: zod.z.literal('Create'),
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 = zod.z.object({
31357
- kind: zod.z.literal('Assign'),
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 = zod.z.object({
31362
- kind: zod.z.literal('Alias'),
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 = zod.z.object({
31367
- kind: zod.z.literal('ImmutableCapture'),
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 = zod.z.object({
31372
- kind: zod.z.literal('Capture'),
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 = zod.z.object({
31377
- kind: zod.z.literal('CreateFrom'),
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 = zod.z.union([
31381
+ const ApplyArgSchema = v4.z.union([
31382
31382
  LifetimeIdSchema,
31383
- zod.z.object({
31384
- kind: zod.z.literal('Spread'),
31383
+ v4.z.object({
31384
+ kind: v4.z.literal('Spread'),
31385
31385
  place: LifetimeIdSchema,
31386
31386
  }),
31387
- zod.z.object({
31388
- kind: zod.z.literal('Hole'),
31387
+ v4.z.object({
31388
+ kind: v4.z.literal('Hole'),
31389
31389
  }),
31390
31390
  ]);
31391
- const ApplyEffectSchema = zod.z.object({
31392
- kind: zod.z.literal('Apply'),
31391
+ const ApplyEffectSchema = v4.z.object({
31392
+ kind: v4.z.literal('Apply'),
31393
31393
  receiver: LifetimeIdSchema,
31394
31394
  function: LifetimeIdSchema,
31395
- mutatesFunction: zod.z.boolean(),
31396
- args: zod.z.array(ApplyArgSchema),
31395
+ mutatesFunction: v4.z.boolean(),
31396
+ args: v4.z.array(ApplyArgSchema),
31397
31397
  into: LifetimeIdSchema,
31398
31398
  });
31399
- const ImpureEffectSchema = zod.z.object({
31400
- kind: zod.z.literal('Impure'),
31399
+ const ImpureEffectSchema = v4.z.object({
31400
+ kind: v4.z.literal('Impure'),
31401
31401
  place: LifetimeIdSchema,
31402
31402
  });
31403
- const AliasingEffectSchema = zod.z.union([
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 = zod.z.object({
31416
+ const AliasingSignatureSchema = v4.z.object({
31417
31417
  receiver: LifetimeIdSchema,
31418
- params: zod.z.array(LifetimeIdSchema),
31418
+ params: v4.z.array(LifetimeIdSchema),
31419
31419
  rest: LifetimeIdSchema.nullable(),
31420
31420
  returns: LifetimeIdSchema,
31421
- effects: zod.z.array(AliasingEffectSchema),
31422
- temporaries: zod.z.array(LifetimeIdSchema),
31421
+ effects: v4.z.array(AliasingEffectSchema),
31422
+ temporaries: v4.z.array(LifetimeIdSchema),
31423
31423
  });
31424
- const FunctionTypeSchema = zod.z.object({
31425
- kind: zod.z.literal('function'),
31426
- positionalParams: zod.z.array(EffectSchema),
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: zod.z.lazy(() => TypeSchema),
31429
+ returnType: v4.z.lazy(() => TypeSchema),
31430
31430
  returnValueKind: ValueKindSchema,
31431
- noAlias: zod.z.boolean().nullable().optional(),
31432
- mutableOnlyIfOperandsAreMutable: zod.z.boolean().nullable().optional(),
31433
- impure: zod.z.boolean().nullable().optional(),
31434
- canonicalName: zod.z.string().nullable().optional(),
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: zod.z.string().nullable().optional(),
31436
+ knownIncompatible: v4.z.string().nullable().optional(),
31437
31437
  });
31438
- const HookTypeSchema = zod.z.object({
31439
- kind: zod.z.literal('hook'),
31440
- positionalParams: zod.z.array(EffectSchema).nullable().optional(),
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: zod.z.lazy(() => TypeSchema),
31442
+ returnType: v4.z.lazy(() => TypeSchema),
31443
31443
  returnValueKind: ValueKindSchema.nullable().optional(),
31444
- noAlias: zod.z.boolean().nullable().optional(),
31444
+ noAlias: v4.z.boolean().nullable().optional(),
31445
31445
  aliasing: AliasingSignatureSchema.nullable().optional(),
31446
- knownIncompatible: zod.z.string().nullable().optional(),
31446
+ knownIncompatible: v4.z.string().nullable().optional(),
31447
31447
  });
31448
- const BuiltInTypeSchema = zod.z.union([
31449
- zod.z.literal('Any'),
31450
- zod.z.literal('Ref'),
31451
- zod.z.literal('Array'),
31452
- zod.z.literal('Primitive'),
31453
- zod.z.literal('MixedReadonly'),
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 = zod.z.object({
31456
- kind: zod.z.literal('type'),
31455
+ const TypeReferenceSchema = v4.z.object({
31456
+ kind: v4.z.literal('type'),
31457
31457
  name: BuiltInTypeSchema,
31458
31458
  });
31459
- const TypeSchema = zod.z.union([
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 = zod.z.object({
32056
- elementSymbol: zod.z.union([
32057
- zod.z.literal('react.element'),
32058
- zod.z.literal('react.transitional.element'),
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: zod.z.string(),
32060
+ globalDevVar: v4.z.string(),
32061
32061
  });
32062
- const ExternalFunctionSchema = zod.z.object({
32063
- source: zod.z.string(),
32064
- importSpecifierName: zod.z.string(),
32062
+ const ExternalFunctionSchema = v4.z.object({
32063
+ source: v4.z.string(),
32064
+ importSpecifierName: v4.z.string(),
32065
32065
  });
32066
- const InstrumentationSchema = zod.z
32066
+ const InstrumentationSchema = v4.z
32067
32067
  .object({
32068
32068
  fn: ExternalFunctionSchema,
32069
32069
  gating: ExternalFunctionSchema.nullable(),
32070
- globalGating: zod.z.string().nullable(),
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 = zod.z.union([
32076
- zod.z.object({ type: zod.z.literal('wildcard') }),
32077
- zod.z.object({ type: zod.z.literal('name'), name: zod.z.string() }),
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 = zod.z.union([
32080
- zod.z.string(),
32081
- zod.z.tuple([zod.z.string(), zod.z.array(MacroMethodSchema)]),
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 = zod.z.object({
32084
- effectKind: zod.z.nativeEnum(Effect),
32085
- valueKind: zod.z.nativeEnum(ValueKind),
32086
- noAlias: zod.z.boolean().default(false),
32087
- transitiveMixedData: zod.z.boolean().default(false),
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 = zod.z.object({
32090
- customHooks: zod.z.map(zod.z.string(), HookSchema).default(new Map()),
32091
- moduleTypeProvider: zod.z.nullable(zod.z.any()).default(null),
32092
- customMacros: zod.z.nullable(zod.z.array(MacroSchema)).default(null),
32093
- enableResetCacheOnSourceFileChanges: zod.z.nullable(zod.z.boolean()).default(null),
32094
- enablePreserveExistingMemoizationGuarantees: zod.z.boolean().default(true),
32095
- validatePreserveExistingMemoizationGuarantees: zod.z.boolean().default(true),
32096
- enablePreserveExistingManualUseMemo: zod.z.boolean().default(false),
32097
- enableForest: zod.z.boolean().default(false),
32098
- enableUseTypeAnnotations: zod.z.boolean().default(false),
32099
- flowTypeProvider: zod.z.nullable(zod.z.any()).default(null),
32100
- enableOptionalDependencies: zod.z.boolean().default(true),
32101
- enableFire: zod.z.boolean().default(false),
32102
- enableNameAnonymousFunctions: zod.z.boolean().default(false),
32103
- inferEffectDependencies: zod.z
32104
- .nullable(zod.z.array(zod.z.object({
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: zod.z.number().min(1, 'autodepsIndex must be > 0'),
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: zod.z.boolean().default(true),
32111
- validateRefAccessDuringRender: zod.z.boolean().default(true),
32112
- validateNoSetStateInRender: zod.z.boolean().default(true),
32113
- validateNoSetStateInEffects: zod.z.boolean().default(false),
32114
- validateNoDerivedComputationsInEffects: zod.z.boolean().default(false),
32115
- validateNoJSXInTryStatements: zod.z.boolean().default(false),
32116
- validateStaticComponents: zod.z.boolean().default(false),
32117
- validateMemoizedEffectDependencies: zod.z.boolean().default(false),
32118
- validateNoCapitalizedCalls: zod.z.nullable(zod.z.array(zod.z.string())).default(null),
32119
- validateBlocklistedImports: zod.z.nullable(zod.z.array(zod.z.string())).default(null),
32120
- validateNoImpureFunctionsInRender: zod.z.boolean().default(false),
32121
- validateNoFreezingKnownMutableFunctions: zod.z.boolean().default(false),
32122
- enableAssumeHooksFollowRulesOfReact: zod.z.boolean().default(true),
32123
- enableTransitivelyFreezeFunctionExpressions: zod.z.boolean().default(true),
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: zod.z.boolean().default(false),
32127
- enableFunctionOutlining: zod.z.boolean().default(true),
32128
- enableJsxOutlining: zod.z.boolean().default(false),
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: zod.z.boolean().default(false),
32131
- enableChangeVariableCodegen: zod.z.boolean().default(false),
32132
- enableMemoizationComments: zod.z.boolean().default(false),
32133
- throwUnknownException__testonly: zod.z.boolean().default(false),
32134
- enableTreatFunctionDepsAsConditional: zod.z.boolean().default(false),
32135
- disableMemoizationForDebugging: zod.z.boolean().default(false),
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: zod.z.boolean().default(false),
32138
- hookPattern: zod.z.string().nullable().default(null),
32139
- enableTreatRefLikeIdentifiersAsRefs: zod.z.boolean().default(true),
32140
- enableTreatSetIdentifiersAsStateSetters: zod.z.boolean().default(false),
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: zod.z.boolean().default(false),
32143
- validateNoDynamicallyCreatedComponentsOrHooks: zod.z.boolean().default(false),
32144
- enableAllowSetStateFromRefsInEffects: zod.z.boolean().default(true),
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: `${zodValidationError.fromZodError(config.error)}`,
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: `${zodValidationError.fromZodError(externalFunction.error)}`,
32533
+ description: `${v4$1.fromZodError(externalFunction.error)}`,
32534
32534
  loc: null,
32535
32535
  suggestions: null,
32536
32536
  });
@@ -44523,7 +44523,6 @@ function extractManualMemoizationArgs(instr, kind, sidemap, errors) {
44523
44523
  };
44524
44524
  }
44525
44525
  function dropManualMemoization(func) {
44526
- var _a;
44527
44526
  const errors = new CompilerError();
44528
44527
  const isValidationEnabled = func.env.config.validatePreserveExistingMemoizationGuarantees ||
44529
44528
  func.env.config.validateNoSetStateInRender ||
@@ -44553,26 +44552,6 @@ function dropManualMemoization(func) {
44553
44552
  if (fnPlace == null) {
44554
44553
  continue;
44555
44554
  }
44556
- if (func.env.config.validateNoVoidUseMemo &&
44557
- manualMemo.kind === 'useMemo') {
44558
- const funcToCheck = (_a = sidemap.functions.get(fnPlace.identifier.id)) === null || _a === void 0 ? void 0 : _a.value;
44559
- if (funcToCheck !== undefined && funcToCheck.loweredFunc.func) {
44560
- if (!hasNonVoidReturn(funcToCheck.loweredFunc.func)) {
44561
- errors.pushDiagnostic(CompilerDiagnostic.create({
44562
- category: ErrorCategory.VoidUseMemo,
44563
- reason: 'useMemo() callbacks must return a value',
44564
- description: `This ${manualMemo.loadInstr.value.kind === 'PropertyLoad'
44565
- ? 'React.useMemo'
44566
- : 'useMemo'} callback doesn't return a value. useMemo is for computing and caching values, not for arbitrary side effects`,
44567
- suggestions: null,
44568
- }).withDetails({
44569
- kind: 'error',
44570
- loc: instr.value.loc,
44571
- message: 'useMemo() callbacks must return a value',
44572
- }));
44573
- }
44574
- }
44575
- }
44576
44555
  instr.value = getManualMemoizationReplacement(fnPlace, instr.value.loc, manualMemo.kind);
44577
44556
  if (isValidationEnabled) {
44578
44557
  if (!sidemap.functions.has(fnPlace.identifier.id)) {
@@ -44684,17 +44663,6 @@ function findOptionalPlaces(fn) {
44684
44663
  }
44685
44664
  return optionals;
44686
44665
  }
44687
- function hasNonVoidReturn(func) {
44688
- for (const [, block] of func.body.blocks) {
44689
- if (block.terminal.kind === 'return') {
44690
- if (block.terminal.returnVariant === 'Explicit' ||
44691
- block.terminal.returnVariant === 'Implicit') {
44692
- return true;
44693
- }
44694
- }
44695
- }
44696
- return false;
44697
- }
44698
44666
 
44699
44667
  class StableSidemap {
44700
44668
  constructor(env) {
@@ -50177,11 +50145,18 @@ function isUnmemoized(operand, scopes) {
50177
50145
 
50178
50146
  function validateUseMemo(fn) {
50179
50147
  const errors = new CompilerError();
50148
+ const voidMemoErrors = new CompilerError();
50180
50149
  const useMemos = new Set();
50181
50150
  const react = new Set();
50182
50151
  const functions = new Map();
50152
+ const unusedUseMemos = new Map();
50183
50153
  for (const [, block] of fn.body.blocks) {
50184
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
+ }
50185
50160
  switch (value.kind) {
50186
50161
  case 'LoadGlobal': {
50187
50162
  if (value.binding.name === 'useMemo') {
@@ -50206,10 +50181,8 @@ function validateUseMemo(fn) {
50206
50181
  }
50207
50182
  case 'MethodCall':
50208
50183
  case 'CallExpression': {
50209
- const callee = value.kind === 'CallExpression'
50210
- ? value.callee.identifier.id
50211
- : value.property.identifier.id;
50212
- const isUseMemo = useMemos.has(callee);
50184
+ const callee = value.kind === 'CallExpression' ? value.callee : value.property;
50185
+ const isUseMemo = useMemos.has(callee.identifier.id);
50213
50186
  if (!isUseMemo || value.args.length === 0) {
50214
50187
  continue;
50215
50188
  }
@@ -50249,13 +50222,84 @@ function validateUseMemo(fn) {
50249
50222
  message: 'Async and generator functions are not supported',
50250
50223
  }));
50251
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
+ }
50252
50243
  break;
50253
50244
  }
50254
50245
  }
50255
50246
  }
50247
+ if (unusedUseMemos.size !== 0) {
50248
+ for (const operand of eachTerminalOperand(block.terminal)) {
50249
+ unusedUseMemos.delete(operand.identifier.id);
50250
+ }
50251
+ }
50256
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
+ }
50266
+ }
50267
+ fn.env.logErrors(voidMemoErrors.asResult());
50257
50268
  return errors.asResult();
50258
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
+ }
50259
50303
 
50260
50304
  function validateLocalsNotReassignedAfterRender(fn) {
50261
50305
  const contextVariables = new Set();
@@ -53700,27 +53744,27 @@ function isNonNamespacedImport(importDeclPath) {
53700
53744
  importDeclPath.node.importKind !== 'typeof');
53701
53745
  }
53702
53746
 
53703
- zod.z.enum([
53747
+ v4.z.enum([
53704
53748
  'all_errors',
53705
53749
  'critical_errors',
53706
53750
  'none',
53707
53751
  ]);
53708
- const DynamicGatingOptionsSchema = zod.z.object({
53709
- source: zod.z.string(),
53752
+ const DynamicGatingOptionsSchema = v4.z.object({
53753
+ source: v4.z.string(),
53710
53754
  });
53711
- const CustomOptOutDirectiveSchema = zod.z
53712
- .nullable(zod.z.array(zod.z.string()))
53755
+ const CustomOptOutDirectiveSchema = v4.z
53756
+ .nullable(v4.z.array(v4.z.string()))
53713
53757
  .default(null);
53714
- const CompilerReactTargetSchema = zod.z.union([
53715
- zod.z.literal('17'),
53716
- zod.z.literal('18'),
53717
- zod.z.literal('19'),
53718
- zod.z.object({
53719
- kind: zod.z.literal('donotuse_meta_internal'),
53720
- runtimeModule: zod.z.string().default('react'),
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'),
53721
53765
  }),
53722
53766
  ]);
53723
- zod.z.enum([
53767
+ v4.z.enum([
53724
53768
  'infer',
53725
53769
  'syntax',
53726
53770
  'annotation',
@@ -53793,7 +53837,7 @@ function parsePluginOptions(obj) {
53793
53837
  else {
53794
53838
  CompilerError.throwInvalidConfig({
53795
53839
  reason: 'Could not parse dynamic gating. Update React Compiler config to fix the error',
53796
- description: `${zodValidationError.fromZodError(result.error)}`,
53840
+ description: `${v4$1.fromZodError(result.error)}`,
53797
53841
  loc: null,
53798
53842
  suggestions: null,
53799
53843
  });
@@ -53809,7 +53853,7 @@ function parsePluginOptions(obj) {
53809
53853
  else {
53810
53854
  CompilerError.throwInvalidConfig({
53811
53855
  reason: 'Could not parse custom opt out directives. Update React Compiler config to fix the error',
53812
- description: `${zodValidationError.fromZodError(result.error)}`,
53856
+ description: `${v4$1.fromZodError(result.error)}`,
53813
53857
  loc: null,
53814
53858
  suggestions: null,
53815
53859
  });
@@ -53832,7 +53876,7 @@ function parseTargetConfig(value) {
53832
53876
  else {
53833
53877
  CompilerError.throwInvalidConfig({
53834
53878
  reason: 'Not a valid target',
53835
- description: `${zodValidationError.fromZodError(parsed.error)}`,
53879
+ description: `${v4$1.fromZodError(parsed.error)}`,
53836
53880
  suggestions: null,
53837
53881
  loc: null,
53838
53882
  });
@@ -57346,6 +57390,10 @@ function isUseEffectEventIdentifier(node) {
57346
57390
  return node.type === 'Identifier' && node.name === 'useEffectEvent';
57347
57391
  }
57348
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
+ }
57349
57397
  return (`\`${fn}\` is a function created with React Hook "useEffectEvent", and can only be called from ` +
57350
57398
  'Effects and Effect Events in the same component.' +
57351
57399
  (called ? '' : ' It cannot be assigned to a variable or passed down.'));
@@ -57645,6 +57693,7 @@ const rule = {
57645
57693
  analyzer.leaveNode(node);
57646
57694
  },
57647
57695
  CallExpression(node) {
57696
+ var _a, _b;
57648
57697
  if (isHook(node.callee)) {
57649
57698
  const reactHooksMap = last(codePathReactHooksMapStack);
57650
57699
  const codePathSegment = last(codePathSegmentStack);
@@ -57661,6 +57710,15 @@ const rule = {
57661
57710
  node.arguments.length > 0) {
57662
57711
  lastEffect = node;
57663
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
+ }
57664
57722
  },
57665
57723
  Identifier(node) {
57666
57724
  if (lastEffect == null && useEffectEventFunctions.has(node)) {