]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/rules/guard-for-in.js
2 * @fileoverview Tests for guard-for-in rule.
3 * @author Nicholas C. Zakas
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
12 const rule
= require("../../../lib/rules/guard-for-in"),
13 { RuleTester
} = require("../../../lib/rule-tester");
15 //------------------------------------------------------------------------------
17 //------------------------------------------------------------------------------
19 const ruleTester
= new RuleTester();
20 const error
= { messageId
: "wrap", type
: "ForInStatement" };
22 ruleTester
.run("guard-for-in", rule
, {
25 "for (var x in o) {}",
26 "for (var x in o) if (x) f();",
27 "for (var x in o) { if (x) { f(); } }",
28 "for (var x in o) { if (x) continue; f(); }",
29 "for (var x in o) { if (x) { continue; } f(); }"
32 { code
: "for (var x in o) { if (x) { f(); continue; } g(); }", errors
: [error
] },
33 { code
: "for (var x in o) { if (x) { continue; f(); } g(); }", errors
: [error
] },
34 { code
: "for (var x in o) { if (x) { f(); } g(); }", errors
: [error
] },
35 { code
: "for (var x in o) { if (x) f(); g(); }", errors
: [error
] },
36 { code
: "for (var x in o) { foo() }", errors
: [error
] },
37 { code
: "for (var x in o) foo();", errors
: [error
] }