2.0.1 β€’ Published 1 year ago

@putout/plugin-convert-index-of-to-includes v2.0.1

Weekly downloads
2,533
License
MIT
Repository
github
Last release
1 year ago

@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