* @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")
+ );
}
//------------------------------------------------------------------------------
properties: {
enforceForSwitchCase: {
type: "boolean",
- default: false
+ default: true
},
enforceForIndexOf: {
type: "boolean",
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;
/**
}
/**
- * 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);