Skip to content

Report sequences unescaped for v flag (even if using the u or earlier flags) #762

@brettz9

Description

@brettz9

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions