You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just a small correction in case anyone starts implementing the rule -- since the second parameter is the length of the returned array instead of the number of splits to do:
string.split('/').at(numberVar)// would be:string.split('/',numberVar+1).at(numberVar)
Description
Whenever we use
String.prototype.split
with literals like so:We benefit by limiting the search space, this allows split to exit early once it attains the number of splits and to not scan the whole string:
Fail
Pass
Proposed rule name
specify-split-limit or prefer-split-limit
Additional Info
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split#limit
The text was updated successfully, but these errors were encountered: