]>
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 //------------------------------------------------------------------------------
13 /** @type {import('../shared/types').Rule} */
19 description
: "Disallow `null` comparisons without type-checking operators",
21 url
: "https://eslint.org/docs/rules/no-eq-null"
27 unexpected
: "Use '===' to compare with null."
35 BinaryExpression(node
) {
36 const badOperator
= node
.operator
=== "==" || node
.operator
=== "!=";
38 if (node
.right
.type
=== "Literal" && node
.right
.raw
=== "null" && badOperator
||
39 node
.left
.type
=== "Literal" && node
.left
.raw
=== "null" && badOperator
) {
40 context
.report({ node
, messageId
: "unexpected" });