From b095205240d2c26a5a32a2ab06a4839bb394414e Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Fri, 3 Dec 2021 07:32:53 +0530 Subject: [PATCH] chore: apply suggestions --- lib/rules/prefer-object-has-own.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/rules/prefer-object-has-own.js b/lib/rules/prefer-object-has-own.js index c066876c059..7455eed67a4 100644 --- a/lib/rules/prefer-object-has-own.js +++ b/lib/rules/prefer-object-has-own.js @@ -1,6 +1,7 @@ /** * @fileoverview Prefers Object.hasOwn instead of Object.prototype.hasOwnProperty - * @author Nitin Kumar, Gautam Arora + * @author Nitin Kumar + * @author Gautam Arora */ "use strict"; @@ -13,10 +14,10 @@ const astUtils = require("./utils/ast-utils"); /** * Checks to see if a property name object exists in the subtree recursively. - * @param {node} node to evalutate. + * @param {ASTnode} node to evalutate. * @returns {boolean} `true` if object property exists, `false` otherwise. */ -function checkForObject(node) { +function hasLeftHandObject(node) { if (!node.object) { return false; } @@ -32,7 +33,7 @@ function checkForObject(node) { const propertyName = astUtils.getStaticPropertyName(node.object); if (propertyName === "hasOwnProperty" || propertyName === "prototype") { - return checkForObject(node.object); + return hasLeftHandObject(node.object); } return false; @@ -63,7 +64,7 @@ module.exports = { CallExpression(node) { const calleePropertyName = astUtils.getStaticPropertyName(node.callee); const objectPropertyName = astUtils.getStaticPropertyName(node.callee.object); - const isObject = checkForObject(node.callee); + const isObject = hasLeftHandObject(node.callee); // check `Object` scope const scope = context.getScope();