disallow the use of lookbehind assertions((?<= ) and (?<! )) in regular expressions (no-lookbehind-assertions-regexp
)
Regular expression lookbehind assertions are not supported by some browsers (such as Safari) and can cause unexpected errors.
This rule disallows the use of regular expression lookbehind assertions.
In the examples below, we will use the following configuration:
"rules": {
"lookbehind-assertions/no-lookbehind-assertions-regexp": "error"
}
Examples of incorrect code:
let re = /(?<=ripe )orange/;
re = new RegExp('(?<=ripe )orange');
Examples of correct code:
let re = /\d+(?=%)/;
re = new RegExp('d+(?=%)');