Skip to content

💅 noUnsafePlusOperands is 3.94x slower in 2.5.12 on Zod-inferred form values #11616

Description

@jakeleventhal

Environment information

Details
CLI:
  Version: 2.5.12

Platform:
  CPU Architecture: aarch64
  OS: macos 27.0
  CPU: Apple M1 Max

Environment:
  BIOME_DISTRIBUTION: npm
  JS_RUNTIME_VERSION: v24.12.0
  JS_RUNTIME_NAME: node

Biome Configuration:
  Status: Loaded successfully
  Path: biome.json
  VCS enabled: false
  Enabled rule: nursery/noUnsafePlusOperands

Rule name

nursery/noUnsafePlusOperands

Playground link

https://github.com/jakeleventhal/biome-no-unsafe-plus-operands-perf-repro

The repository pins Biome 2.5.10 and 2.5.12 side by side. Run:

bun install --frozen-lockfile
bun run bench
bun run profile:2.5.10
bun run profile:2.5.12

The analyzed file contains one binary + expression. Its operands come from React Hook Form values whose type is inferred from a minimal Zod schema:

import type { UseFormReturn } from "react-hook-form";
import { z } from "zod";

const formSchema = z.object({
	ounces: z.number().nonnegative(),
	pounds: z.number().nonnegative(),
});

declare const form: UseFormReturn<z.infer<typeof formSchema>>;

export function getWeightInOunces() {
	const ounces = form.watch("ounces");
	const pounds = form.watch("pounds");
	return 16 * pounds + ounces;
}

Five-run averages on the machine above:

Version End-to-end average noUnsafePlusOperands rule time
2.5.10 1.480s 1.379s
2.5.12 5.554s 5.432s

That is a 3.75x end-to-end slowdown and a 3.94x increase inside the rule. Removing the binary + removes the expensive rule invocation and reduces the 2.5.12 check to about 52 milliseconds.

Expected result

Biome 2.5.12 should process this expression in roughly the same time as 2.5.10. noUnsafePlusOperands should not spend more than five seconds resolving two numeric React Hook Form values.

Code of Conduct

  • I agree to follow Biome's Code of Conduct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-Type-InferenceArea: type inferenceL-JavaScriptLanguage: JavaScript and super languagesS-Bug-confirmedStatus: report has been confirmed as a valid bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions