diff --git a/src/__tests__/lib/rules/prefer-to-have-value.js b/src/__tests__/lib/rules/prefer-to-have-value.js index 062a79c..aed17c6 100644 --- a/src/__tests__/lib/rules/prefer-to-have-value.js +++ b/src/__tests__/lib/rules/prefer-to-have-value.js @@ -52,6 +52,10 @@ ruleTester.run("prefer-to-have-value", rule, { `const element = { value: 'foo' }; expect(element.value).not.toBe('foo');`, + ` + const res = makePath()(); + expect(res.value).toEqual('/repositories/create'); + `, ], invalid: [ { diff --git a/src/assignment-ast.js b/src/assignment-ast.js index dc8a9c8..4f5e987 100644 --- a/src/assignment-ast.js +++ b/src/assignment-ast.js @@ -74,7 +74,9 @@ export function getQueryNodeFrom(context, nodeWithValueProp) { }; } - const query = queryNode.callee.name || queryNode.callee.property.name; + const query = + queryNode.callee.name || + (queryNode.callee.property && queryNode.callee.property.name); const queryArg = queryNode.arguments[0] && queryNode.arguments[0].value; const isDTLQuery = queries.includes(query);