2 * @fileoverview Rule to flag comparisons to null without a type-checking
4 * @author Ian Christian Myers
9 //------------------------------------------------------------------------------
11 //------------------------------------------------------------------------------
13 module.exports = function(context) {
17 "BinaryExpression": function(node) {
18 var badOperator = node.operator === "==" || node.operator === "!=";
20 if (node.right.type === "Literal" && node.right.raw === "null" && badOperator ||
21 node.left.type === "Literal" && node.left.raw === "null" && badOperator) {
22 context.report(node, "Use ‘===’ to compare with ‘null’.");