]> git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/rules/no-void.js
first commit
[pve-eslint.git] / eslint / tests / lib / rules / no-void.js
1 /**
2 * @fileoverview Rule to disallow use of void operator.
3 * @author Mike Sidorov
4 */
5 "use strict";
6
7 //------------------------------------------------------------------------------
8 // Requirements
9 //------------------------------------------------------------------------------
10
11 const rule = require("../../../lib/rules/no-void");
12 const { RuleTester } = require("../../../lib/rule-tester");
13
14 //------------------------------------------------------------------------------
15 // Tests
16 //------------------------------------------------------------------------------
17
18 const ruleTester = new RuleTester();
19
20 ruleTester.run("no-void", rule, {
21 valid: [
22 "var foo = bar()",
23 "foo.void()",
24 "foo.void = bar",
25 "delete foo;",
26 {
27 code: "void 0",
28 options: [{ allowAsStatement: true }]
29 },
30 {
31 code: "void(0)",
32 options: [{ allowAsStatement: true }]
33 }
34 ],
35
36 invalid: [
37 {
38 code: "void 0",
39 errors: [{ messageId: "noVoid" }]
40 },
41 {
42 code: "void 0",
43 options: [{}],
44 errors: [{ messageId: "noVoid" }]
45 },
46 {
47 code: "void 0",
48 options: [{ allowAsStatement: false }],
49 errors: [{ messageId: "noVoid" }]
50 },
51 {
52 code: "void(0)",
53 errors: [{ messageId: "noVoid" }]
54 },
55 {
56 code: "var foo = void 0",
57 errors: [{ messageId: "noVoid" }]
58 },
59 {
60 code: "var foo = void 0",
61 options: [{ allowAsStatement: true }],
62 errors: [{ messageId: "noVoid" }]
63 }
64 ]
65 });