Skip to content

Latest commit

 

History

History

plugin-convert-index-of-to-includes

@putout/plugin-convert-index-of-to-includes NPM version

The includes() method determines whether an array includes a certain value among its entries, returning true or false as appropriate.

(c)MDN

🐊Putout plugin adds ability to convert 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