# regexp/no-potentially-useless-backreference

disallow backreferences that reference a group that might not be matched

  • ⚙️ This rule is included in "plugin:regexp/recommended".

# 📖 Rule Details

If the referenced group of a backreference is not matched because some other path leads to the backreference, the backreference will trivially accept (e.g. /(?:(a)|b)\1/). The same will happen if the captured text of the referenced group was reset before reaching the backreference.

This will not handle backreferences that always trivially accept. Use regexp/no-useless-backreference for that.

Now loading...

# 🔧 Options

Nothing.

# ❤️ Compatibility

This rule was taken from eslint-plugin-clean-regex (opens new window).
This rule is compatible with clean-regex/no-potentially-empty-backreference (opens new window) rule.

# 🚀 Version

This rule was introduced in eslint-plugin-regexp v0.9.0

# 🔍 Implementation