Motivation
require-unicode-regexp
in ESLint now supports a requireFlag
option to require the v
flag (as your plugin already does). However, if one is stuck in environments that don't support the v
flag, one may end up writing regexes for the u
flag which are difficult to refactor later for the v
flag if that code doesn't do the proper escaping expected by the v
flag.
Description
It would be nice to have a rule which prohibited characters which were unescaped as far as would be valid for the v
flag (even if the u
flag were in use).
Examples
/* ✓ GOOD */
var foo = /[\[a]/u;
/* ✗ BAD */
var foo = /[[a]/u; // Technically ok, but will be invalid when switching to `v` flag