Require Regex Literals to be Wrapped (wrap-regex)

When a regular expression is used in certain situations, it can end up looking like a division operator. For example:

function a() {
    return /foo/.test("bar");
}

Rule Details

This is used to disambiguate the slash operator and facilitates more readable code.

The following patterns are considered problems:

/*eslint wrap-regex: "error"*/

function a() {
    return /foo/.test("bar");
}

The following patterns are not considered problems:

/*eslint wrap-regex: "error"*/

function a() {
    return (/foo/).test("bar");
}

Version

This rule was introduced in ESLint 0.1.0.

Resources