Repository: facebook/react
File: compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Pipeline.ts (TypeScript)

Code before:
  });
  log({kind: 'hir', name: 'InferMutationAliasingRanges', value: hir});
  if (env.isInferredMemoEnabled) {
    if (mutabilityAliasingRangeErrors.isErr()) {
      throw mutabilityAliasingRangeErrors.unwrapErr();
    }
    validateLocalsNotReassignedAfterRender(hir);
  }

  if (env.isInferredMemoEnabled) {
    if (env.config.assertValidMutableRanges) {
      assertValidMutableRanges(hir);
    }

    if (env.config.validateRefAccessDuringRender) {
      validateNoRefAccessInRender(hir).unwrap();
    }

    if (env.config.validateNoSetStateInRender) {
      validateNoSetStateInRender(hir).unwrap();
    }

    if (
      env.config.validateNoDerivedComputationsInEffects &&
      !env.config.validateNoDerivedComputationsInEffects_exp
    ) {
      validateNoDerivedComputationsInEffects(hir);
    }

    if (env.config.validateNoDerivedComputationsInEffects_exp) {
      env.logErrors(validateNoDerivedComputationsInEffects_exp(hir));
    }

    if (env.config.validateNoSetStateInEffects) {
      env.logErrors(validateNoSetStateInEffects(hir, env));
    }

    if (env.config.validateNoJSXInTryStatements) {
      env.logErrors(validateNoJSXInTryStatement(hir));
    }

    if (env.config.validateNoImpureFunctionsInRender) {
      validateNoImpureFunctionsInRender(hir).unwrap();
    }

    validateNoFreezingKnownMutableFunctions(hir).unwrap();
  }

  inferReactivePlaces(hir);
  log({kind: 'hir', name: 'InferReactivePlaces', value: hir});


Review comment (suggestion):
maybe merge w the _exp case below? `if (config.validate...exp) { ...} else if (config.validate...) { ... }`

Code after:
  });
  log({kind: 'hir', name: 'InferMutationAliasingRanges', value: hir});
  if (env.isInferredMemoEnabled) {
    if (mutabilityAliasingRangeErrors.isErr()) {
      throw mutabilityAliasingRangeErrors.unwrapErr();
    }
    validateLocalsNotReassignedAfterRender(hir);
  }

  if (env.isInferredMemoEnabled) {
    if (env.config.assertValidMutableRanges) {
      assertValidMutableRanges(hir);
    }

    if (env.config.validateRefAccessDuringRender) {
      validateNoRefAccessInRender(hir).unwrap();
    }

    if (env.config.validateNoSetStateInRender) {
      validateNoSetStateInRender(hir).unwrap();
    }

    if (env.config.validateNoDerivedComputationsInEffects_exp) {
      env.logErrors(validateNoDerivedComputationsInEffects_exp(hir));
    } else if (env.config.validateNoDerivedComputationsInEffects) {
      validateNoDerivedComputationsInEffects(hir);
    }

    if (env.config.validateNoSetStateInEffects) {
      env.logErrors(validateNoSetStateInEffects(hir, env));
    }

    if (env.config.validateNoJSXInTryStatements) {
      env.logErrors(validateNoJSXInTryStatement(hir));
    }

    if (env.config.validateNoImpureFunctionsInRender) {
      validateNoImpureFunctionsInRender(hir).unwrap();
    }

    validateNoFreezingKnownMutableFunctions(hir).unwrap();
  }

  inferReactivePlaces(hir);
  log({kind: 'hir', name: 'InferReactivePlaces', value: hir});

  rewriteInstructionKindsBasedOnReassignment(hir);
  log({
    kind: 'hir',
    name: 'RewriteInstructionKindsBasedOnReassignment',
    value: hir,