-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
package.json
{
"devDependencies": {
"eslint": "7.23.0",
"eslint-plugin-more": "1.0.2"
}
}.eslintrc.json
{
"plugins": ["more"],
"rules": { "more/prefer-includes": "error" }
}index.js
foo() + "bar";Output
$ eslint index.js
Oops! Something went wrong! :(
ESLint: 7.23.0
TypeError: Cannot read property 'name' of undefined
Occurred while linting index.js:1
at BinaryExpression (node_modules/eslint-plugin-more/lib/rules/prefer-includes.js:15:42)
...
Resolution
Possibly just need a more thorough check of the property chain.
diff --git a/lib/rules/prefer-includes.js b/lib/rules/prefer-includes.js
index 7711a22..daecf0c 100644
--- a/lib/rules/prefer-includes.js
+++ b/lib/rules/prefer-includes.js
@@ -12,6 +12,7 @@ module.exports = function (context) {
const moreOrEqualThanZero = operator === '>=' && right.value === 0;
const isIndexOfEqualToMinusOne = left
&& left.callee
+ && left.callee.property
&& (left.callee.property.name === 'indexOf')
&& (compareWithMinusOne || lessThanZero || moreOrEqualThanZero);heleg
Metadata
Metadata
Assignees
Labels
No labels