When using String.prototype.replace() or String.prototype.replaceAll() with a replacement string, referencing capturing groups that do not exist in the pattern is likely a mistake.
This includes numeric references like $3 when only two groups exist, or named references like $<middle> when no such named group exists.
These invalid references will be treated as literal text in the output, which is rarely the intended behavior.
This rule reports dollar replacements that are either invalid or unnecessary.
Passes a string and
{@linkcode
replaceValue
}
to the [Symbol.replace] method on
{@linkcode
searchValue
}
. This method is expected to implement its own replacement algorithm.
@param ― searchValue An object that supports searching for and replacing matches within a string.
Passes a string and
{@linkcode
replaceValue
}
to the [Symbol.replace] method on
{@linkcode
searchValue
}
. This method is expected to implement its own replacement algorithm.
@param ― searchValue An object that supports searching for and replacing matches within a string.
Passes a string and
{@linkcode
replaceValue
}
to the [Symbol.replace] method on
{@linkcode
searchValue
}
. This method is expected to implement its own replacement algorithm.
@param ― searchValue An object that supports searching for and replacing matches within a string.
Passes a string and
{@linkcode
replaceValue
}
to the [Symbol.replace] method on
{@linkcode
searchValue
}
. This method is expected to implement its own replacement algorithm.
@param ― searchValue An object that supports searching for and replacing matches within a string.
Passes a string and
{@linkcode
replaceValue
}
to the [Symbol.replace] method on
{@linkcode
searchValue
}
. This method is expected to implement its own replacement algorithm.
@param ― searchValue An object that supports searching for and replacing matches within a string.
Passes a string and
{@linkcode
replaceValue
}
to the [Symbol.replace] method on
{@linkcode
searchValue
}
. This method is expected to implement its own replacement algorithm.
@param ― searchValue An object that supports searching for and replacing matches within a string.
Passes a string and
{@linkcode
replaceValue
}
to the [Symbol.replace] method on
{@linkcode
searchValue
}
. This method is expected to implement its own replacement algorithm.
@param ― searchValue An object that supports searching for and replacing matches within a string.
If you intentionally use invalid dollar replacements as literal text (though this is rare and confusing), you might want to disable this rule.
Consider escaping the dollar sign with $$ instead for clarity.