Skip to content

Commit

Permalink
Update: improve isNaNIdentifier to detect Number.isNaN (fixes #14715
Browse files Browse the repository at this point in the history
)
  • Loading branch information
snitin315 committed Jun 18, 2021
1 parent a47e5e3 commit e4d0b42
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/rules/use-isnan.js
Expand Up @@ -21,7 +21,10 @@ const astUtils = require("./utils/ast-utils");
* @returns {boolean} `true` if the node is 'NaN' identifier.
*/
function isNaNIdentifier(node) {
return Boolean(node) && node.type === "Identifier" && node.name === "NaN";
return Boolean(node) && (node.type === "Identifier" && node.name === "NaN" ||
(node.type === "MemberExpression" &&
node.object.type === "Identifier" && node.object.name === "Number" &&
node.property.type === "Identifier" && node.property.name === "NaN"));
}

//------------------------------------------------------------------------------
Expand Down

0 comments on commit e4d0b42

Please sign in to comment.