Skip to content

Commit

Permalink
fix: no-new-fuc should catch calls to Function.apply
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Jul 30, 2021
1 parent ed007c8 commit 80b2c35
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions lib/rules/no-new-func.js
Expand Up @@ -38,12 +38,23 @@ module.exports = {
variable.references.forEach(ref => {
const node = ref.identifier;
const { parent } = node;
var isEval = false;

if (
parent &&
(parent.type === "NewExpression" || parent.type === "CallExpression") &&
node === parent.callee
) {
if (parent) {
if (node === parent.callee && (
parent.type === "NewExpression" ||
parent.type === "CallExpression"
)) {
isEval = true;
} else if (parent.type === "MemberExpression") {
var gParent = parent.parent;
if (gParent && gParent.type === "CallExpression") {
isEval = true;
}
}
}

if(isEval) {
context.report({
node: parent,
messageId: "noFunctionConstructor"
Expand Down

0 comments on commit 80b2c35

Please sign in to comment.