]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/rules/no-self-compare.js
2 * @fileoverview Tests for no-self-compare rule.
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
12 const rule
= require("../../../lib/rules/no-self-compare"),
13 { RuleTester
} = require("../../../lib/rule-tester");
15 //------------------------------------------------------------------------------
17 //------------------------------------------------------------------------------
19 const ruleTester
= new RuleTester();
21 ruleTester
.run("no-self-compare", rule
, {
26 "foo.bar.baz === foo.bar.qux"
29 { code
: "if (x === x) { }", errors
: [{ messageId
: "comparingToSelf", type
: "BinaryExpression" }] },
30 { code
: "if (x !== x) { }", errors
: [{ messageId
: "comparingToSelf", type
: "BinaryExpression" }] },
31 { code
: "if (x > x) { }", errors
: [{ messageId
: "comparingToSelf", type
: "BinaryExpression" }] },
32 { code
: "if ('x' > 'x') { }", errors
: [{ messageId
: "comparingToSelf", type
: "BinaryExpression" }] },
33 { code
: "do {} while (x === x)", errors
: [{ messageId
: "comparingToSelf", type
: "BinaryExpression" }] },
34 { code
: "x === x", errors
: [{ messageId
: "comparingToSelf", type
: "BinaryExpression" }] },
35 { code
: "x !== x", errors
: [{ messageId
: "comparingToSelf", type
: "BinaryExpression" }] },
36 { code
: "x == x", errors
: [{ messageId
: "comparingToSelf", type
: "BinaryExpression" }] },
37 { code
: "x != x", errors
: [{ messageId
: "comparingToSelf", type
: "BinaryExpression" }] },
38 { code
: "x > x", errors
: [{ messageId
: "comparingToSelf", type
: "BinaryExpression" }] },
39 { code
: "x < x", errors
: [{ messageId
: "comparingToSelf", type
: "BinaryExpression" }] },
40 { code
: "x >= x", errors
: [{ messageId
: "comparingToSelf", type
: "BinaryExpression" }] },
41 { code
: "x <= x", errors
: [{ messageId
: "comparingToSelf", type
: "BinaryExpression" }] },
42 { code
: "foo.bar().baz.qux >= foo.bar ().baz .qux", errors
: [{ messageId
: "comparingToSelf", type
: "BinaryExpression" }] }