2 * @fileoverview Rule to flag when using new Function
8 //------------------------------------------------------------------------------
10 //------------------------------------------------------------------------------
17 description: "disallow `new` operators with the `Function` object",
18 category: "Best Practices",
20 url: "https://eslint.org/docs/rules/no-new-func"
26 noFunctionConstructor: "The Function constructor is eval."
34 const globalScope = context.getScope();
35 const variable = globalScope.set.get("Function");
37 if (variable && variable.defs.length === 0) {
38 variable.references.forEach(ref => {
39 const node = ref.identifier;
40 const { parent } = node;
44 (parent.type === "NewExpression" || parent.type === "CallExpression") &&
45 node === parent.callee
49 messageId: "noFunctionConstructor"