]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/lib/rules/no-eq-null.js
2 * @fileoverview Rule to flag comparisons to null without a type-checking
4 * @author Ian Christian Myers
9 //------------------------------------------------------------------------------
11 //------------------------------------------------------------------------------
18 description
: "disallow `null` comparisons without type-checking operators",
20 url
: "https://eslint.org/docs/rules/no-eq-null"
26 unexpected
: "Use '===' to compare with null."
34 BinaryExpression(node
) {
35 const badOperator
= node
.operator
=== "==" || node
.operator
=== "!=";
37 if (node
.right
.type
=== "Literal" && node
.right
.raw
=== "null" && badOperator
||
38 node
.left
.type
=== "Literal" && node
.left
.raw
=== "null" && badOperator
) {
39 context
.report({ node
, messageId
: "unexpected" });