massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / eslint / lib / rules / use-isnan.js
index cd9ccdbaf898ee332feff6f0970977cde26a602c..ef95b21314a1ce99d5a6abc9d7e14f61a3a58b26 100644 (file)
@@ -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) && (
+        astUtils.isSpecificId(node, "NaN") ||
+        astUtils.isSpecificMemberAccess(node, "Number", "NaN")
+    );
 }
 
 //------------------------------------------------------------------------------
@@ -45,7 +48,7 @@ module.exports = {
                 properties: {
                     enforceForSwitchCase: {
                         type: "boolean",
-                        default: false
+                        default: true
                     },
                     enforceForIndexOf: {
                         type: "boolean",
@@ -66,7 +69,7 @@ module.exports = {
 
     create(context) {
 
-        const enforceForSwitchCase = context.options[0] && context.options[0].enforceForSwitchCase;
+        const enforceForSwitchCase = !context.options[0] || context.options[0].enforceForSwitchCase;
         const enforceForIndexOf = context.options[0] && context.options[0].enforceForIndexOf;
 
         /**
@@ -101,12 +104,12 @@ module.exports = {
         }
 
         /**
-         * Checks the the given `CallExpression` node for `.indexOf(NaN)` and `.lastIndexOf(NaN)`.
+         * Checks the given `CallExpression` node for `.indexOf(NaN)` and `.lastIndexOf(NaN)`.
          * @param {ASTNode} node The node to check.
          * @returns {void}
          */
         function checkCallExpression(node) {
-            const callee = node.callee;
+            const callee = astUtils.skipChainExpression(node.callee);
 
             if (callee.type === "MemberExpression") {
                 const methodName = astUtils.getStaticPropertyName(callee);