Skip to content
Permalink
Browse files

fix(eslint-plugin): [no-implied-eval] handle the `Function` type (#2435)

  • Loading branch information
soobing committed Sep 14, 2020
1 parent 7ca54c3 commit e1401dc5897d01da516802cfb2333cf4bc6d0e93
@@ -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,
@@ -246,6 +246,11 @@ const fn = (foo: () => void) => {
import { Function } from './class';
new Function('foo');
`,
`
const foo = (callback: Function) => {
setTimeout(callback, 0);
};
`,
],

invalid: [

0 comments on commit e1401dc

Please sign in to comment.
You can’t perform that action at this time.