]>
git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/rules/no-new-func.js
aa0542090e24229bf28b5b1948b252bea1030bb3
2 * @fileoverview Tests for no-new-func rule.
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
12 const rule
= require("../../../lib/rules/no-new-func"),
13 { RuleTester
} = require("../../../lib/rule-tester");
15 //------------------------------------------------------------------------------
17 //------------------------------------------------------------------------------
19 const ruleTester
= new RuleTester();
21 ruleTester
.run("no-new-func", rule
, {
23 "var a = new _function(\"b\", \"c\", \"return b+c\");",
24 "var a = _function(\"b\", \"c\", \"return b+c\");",
26 code
: "class Function {}; new Function()",
32 code
: "const fn = () => { class Function {}; new Function() }",
37 "function Function() {}; Function()",
38 "var fn = function () { function Function() {}; Function() }",
39 "var x = function Function() { Function(); }",
45 code
: "var a = new Function(\"b\", \"c\", \"return b+c\");",
47 messageId
: "noFunctionConstructor",
52 code
: "var a = Function(\"b\", \"c\", \"return b+c\");",
54 messageId
: "noFunctionConstructor",
55 type
: "CallExpression"
59 code
: "const fn = () => { class Function {} }; new Function('', '')",
64 messageId
: "noFunctionConstructor",
69 code
: "var fn = function () { function Function() {} }; Function('', '')",
71 messageId
: "noFunctionConstructor",
72 type
: "CallExpression"