Skip to content

Commit

Permalink
feat: ignoreSticky for regexp/no-super-linear-move
Browse files Browse the repository at this point in the history
Sticky regular expressions are not at risk of super-linear scanning,
since the match must start at the end of the previous match.  Since I
don't usually change flags or build RegExp patterns from other RegExp
patterns, ignoring these poses little risk.

Note: This matches the documented default for ignoreSticky, which
differs from the current code.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
  • Loading branch information
kevinoid committed Oct 1, 2023
1 parent 2f49479 commit 99b5de6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rules/regexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ module.exports = {
// since I often find it preferable to use the common/expected case.
"regexp/letter-case": "off",

// Don't allow super-linear worst-case runtime moving across input string
//
// Note: Default for ignoreSticky is false, which differs from docs:
// https://github.com/ota-meshi/eslint-plugin-regexp/issues/629
"regexp/no-super-linear-move": ["error", {
"ignoreSticky": true
}],

// Don't prefer \d to [0-9].
// I find 0-9 clearer. (\d matches Unicode digits in some RegEx dialects)
"regexp/prefer-d": "off",
Expand Down

0 comments on commit 99b5de6

Please sign in to comment.