@putout/plugin-convert-index-of-to-includes
The
includes()
method determines whether an array includes a certain value among its entries, returningtrue
orfalse
as appropriate.(c)MDN
indexOf
to includes
.
Install
npm i @putout/plugin-convert-index-of-to-includes -D
Rule
{
"rules": {
"convert-index-of-to-includes": "on"
}
}
❌ Example of incorrect code
if (~array.indexOf(element)) {
}
✅ Example of correct code
if (array.includes(element)) {
}
License
MIT