RunDevelopment/eslint-plugin-clean-regex

Detect polynomial backtracking caused by the trivial concatenation of a subset with its superset

RunDevelopment opened this issue · 0 comments

Stuff like this:

/;+.*/ == /;.*/
/\d+\w+/ == /\d\w+/
/\w+\d+/ == /\w+\d/
/\w+\d*/ == /\w+/

More general: Let A be a subset of B.

/A{n,m}B{o,}/ == /A{n}B{o,}/
/B{n,}A{o,p}/ == /B{n,}A{o}/

The new rule should detect concatenation like this and report them. In trivial cases, it might even provide a fixer.