#11933·biome

`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

bash
CLI:
  Version:                      2.5.14

Platform:
  CPU Architecture:             x86_64
  OS:                           linux

Environment:
  BIOME_DISTRIBUTION:           npm
  JS_RUNTIME_NAME:              node

Rule name

nursery/useUnicodeRegex

Playground link

https://biomejs.dev/playground/?lintRules=useUnicodeRegex&fix=safeFixes#files.a.js=YwBvAG4AcwBvAGwAZQAuAGwAbwBnACgALwB7AC8ALgB0AGUAcwB0ACgAIgB7ACIAKQApADsACgBjAG8AbgBzAG8AbABlAC4AbABvAGcAKAAvAF0ALwAuAHQAZQBzAHQAKAAiAF0AIgApACkAOwAKAGMAbwBuAHMAbwBsAGUALgBsAG8AZwAoAC8AYQB7AC8ALgB0AGUAcwB0ACgAIgBhAHsAIgApACkAOwAKAGMAbwBuAHMAbwBsAGUALgBsAG8AZwAoAC8AXABhAC8ALgB0AGUAcwB0ACgAIgBhACIAKQApADsACgBjAG8AbgBzAG8AbABlAC4AbABvAGcAKAAvAFwALQAvAC4AdABlAHMAdAAoACIALQAiACkAKQA7AAoAYwBvAG4AcwBvAGwAZQAuAGwAbwBnACgALwBcAGsALwAuAHQAZQBzAHQAKAAiAGsAIgApACkAOwAKAGMAbwBuAHMAbwBsAGUALgBsAG8AZwAoAC8AWwBcAGQALQB6AF0ALwAuAHQAZQBzAHQAKAAiAC0AIgApACkAOwAKAA%3D%3D

javascript
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 brackets

The 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.