Disallow using the method indexOf.
Note: This plugin will likely cause many false positives. For example,
Backbone collections offer an indexOf method, which will be have to be
manually ignored.
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-indexof:
$ npm install eslint-plugin-indexof --save-dev
Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-indexof globally.
Add indexof to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:
{
"plugins": [
"indexof"
]
}Then configure the rules you want to use under the rules section.
{
"rules": {
"indexof/rule-name": [2, {exceptOn: ['_']}]
}
}- no-indexof Disallow using the
indexOf()method.