sindresorhus/eslint-plugin-unicorn
The issue has been solved
`prefer-includes` rule #8
sindresorhus posted onGitHub
Prefer .includes()
over .indexOf()
when checking for existence. Since ESLint has no type analysis we'll have to assume all properties named .indexOf()
have a .includes()
counterpart. This is luckily true for all builtins: String#includes
, Array#includes
, TypedArray#includes
, Buffer#includes
.
See https://github.com/eslint/eslint/issues/4209 for more.
.includes()
cases:
'foobar'.indexOf('foo') !== -1
'foobar'.indexOf('foo') != -1
'foobar'.indexOf('foo') > -1
'foobar'.indexOf('foo') >= 0
New to making ESLint rules? Check out this quick guide on how to get started.
Fund this Issue
Rewarded pull request
Add `prefer-includes` rule #214submitted byprbart(20)
Click to copy link
Recent activities