Skip to content

Files

Latest commit

 

History

History
24 lines (17 loc) · 597 Bytes

require-unicode-regexp.md

File metadata and controls

24 lines (17 loc) · 597 Bytes

Pattern: Missing u flag on regular expression

Issue: -

Description

This rule reports regular expressions without the u flag.

It will automatically add the u flag to regular expressions where it is statically guaranteed to be safe to do so. In all other cases, the developer has to check that adding the u flag doesn't cause the regex to behave incorrectly.

Examples

/* eslint regexp/require-unicode-regexp: "error" */
/* ✓ GOOD */
var foo = /foo/u;
var foo = /a\s+b/u;

/* ✗ BAD */
var foo = /foo/;
var foo = RegExp("a\\s+b");
var foo = /[a-z]/i;
var foo = /\S/;