sindresorhus / eslint-plugin-unicorn

More than 100 powerful ESLint rules
MIT License
4.2k stars 363 forks source link

`prefer-starts-ends-with`: Support `string.indexOf('') === 0` #712

Open fisker opened 4 years ago

fisker commented 4 years ago

foo.startsWith(bar) over foo.indexOf(bar) === 0

fisker commented 4 years ago

Forgot Array#indexOf(), seems we can't support it.

sindresorhus commented 4 years ago

We could if we do https://github.com/sindresorhus/eslint-plugin-unicorn/issues/347.

silverwind commented 6 months ago

Forgot Array#indexOf(), seems we can't support it.

Could maybe be supported if Array#at() is preferred over Array#indexOf() so any remaining indexOf property access must be against strings.