Skip to content
Merged
10 changes: 10 additions & 0 deletions packages/eslint-plugin/src/rules/no-implied-eval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ export default util.createRule({
return true;
}

if (symbol && symbol.escapedName === FUNCTION_CONSTRUCTOR) {
const declarations = symbol.getDeclarations() ?? [];
for (const declaration of declarations) {
const sourceFile = declaration.getSourceFile();
if (program.isSourceFileDefaultLibrary(sourceFile)) {
return true;
}
}
}

const signatures = checker.getSignaturesOfType(
type,
ts.SignatureKind.Call,
Expand Down
5 changes: 5 additions & 0 deletions packages/eslint-plugin/tests/rules/no-implied-eval.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ const fn = (foo: () => void) => {
import { Function } from './class';
new Function('foo');
`,
`
const foo = (callback: Function) => {
setTimeout(callback, 0);
};
`,
],

invalid: [
Expand Down