Closed
Description
The rule would catch the following cases:
.startsWith
instead of:
foo.indexOf('bar') === 0
foo[0] === 'b'
foo.charAt(0) === 'b'
(andfoo.charAt()
)foo.slice(0, 2) === 'bar'
(and.substring
&.substr
)/^bar/.test(foo)
(and.match()
)
.endsWith
instead of:
.lastIndexOf
foo[foo.length - 1] === 'r'
foo.charAt(foo.length - 1) === 'b'
foo.slice(0, -3) === 'bar'
(and.substring
&.substr
)/bar$/.test(foo)
(and.match()
)
The regex case is especially useful as I've seen a lot of regexes used in this scenario.