Skip to content

prefer-native-random-uuid

Prefer globalThis.crypto.randomUUID() over resolved zero-argument UUID v4 bindings from the uuid package.

Why

The platform implementation avoids an unnecessary dependency for standard random UUID generation.

Fix

Call globalThis.crypto.randomUUID() and remove the unused uuid v4 import when possible.

Examples

Before — flagged Do not call uuid v4 without options
src/id.ts
import { v4 } from "uuid";
const id = v4();
After — preferred Use the platform UUID generator
src/id.ts
const id = globalThis.crypto.randomUUID();