The legacy string method substr is called
What it finds
String.prototype.substr takes a start and a length, unlike slice and substring, which take a start and an end. It is listed among the legacy features of the language that implementations outside browsers need not provide, and mixing it with the other two invites off-by-length mistakes.
Reported are method calls named substr. There is no fix, since the second argument has to be turned from a length into an end.
From the rule's source, substr_call.rs.
export const a = "hello".substr(1, 3);tx0 reports: substr is a legacy methodexport const b = "hello".substring(1, 3); Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:substr-call" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:substr-call] reason="..."tx0 explain tx0/ts:substr-call shows the same in the terminal. Found a false positive? Report it.