`useUnicodeRegex` safe fix adds `u` to patterns that are invalid in unicode mode
Author: AlbinoGeekCreated Sep 24, 2026Updated Sep 26, 2026
LabelsA-LinterL-JavaScriptS-Bug-confirmed
Environment information
CLI:
Version: 2.5.14
Platform:
CPU Architecture: x86_64
OS: linux
Environment:
BIOME_DISTRIBUTION: npm
JS_RUNTIME_NAME: nodeRule name
nursery/useUnicodeRegex
Playground link
console.log(/{/.test("{"));
console.log(/]/.test("]"));
console.log(/a{/.test("a{"));
console.log(/\a/.test("a"));
console.log(/\-/.test("-"));
console.log(/\k/.test("k"));
console.log(/[\d-z]/.test("-"));The safe fix appends u to every literal. Each of these patterns is valid without the flag and a SyntaxError with it, so after biome lint --write the file no longer loads:
SyntaxError: Invalid regular expression: /{/u: Lone quantifier bracketsThe same happens for /]/u and /a{/u (lone or incomplete quantifier brackets), /\a/u, /\-/u and /\k/u (identity escapes are not allowed in unicode mode), and /[\d-z]/u (a class escape as a range endpoint). Reproduced with the 2.5.14 CLI and in the playground.
Expected result
The fix is not offered, or is marked unsafe, when the pattern is not valid under the u flag. The rule can still report.
Code of Conduct
- I agree to follow Biome's Code of Conduct
Tool Use Disclaimer: Claude Code using Anthropic Opus 5.5 helped build the reproduction.
Source: biomejs/biome