Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Conversation

@soobing
Copy link
Contributor

@soobing soobing commented Aug 29, 2020

Fixes #2358
In case of using Function type the function checking is function type( named isFunctionType ) should return true.

@typescript-eslint
Copy link

@typescript-eslint typescript-eslint bot commented Aug 29, 2020

Thanks for the PR, @soobing!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@codecov
Copy link

@codecov codecov bot commented Aug 29, 2020

Codecov Report

Merging #2435 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #2435      +/-   ##
==========================================
- Coverage   92.81%   92.80%   -0.02%     
==========================================
  Files         290      290              
  Lines        9453     9459       +6     
  Branches     2647     2650       +3     
==========================================
+ Hits         8774     8778       +4     
  Misses        322      322              
- Partials      357      359       +2     
Flag Coverage Δ
#unittest 92.80% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ackages/eslint-plugin/src/rules/no-implied-eval.ts 93.75% <ø> (-2.81%) ⬇️
ts.SymbolFlags.FunctionScopedVariable |
ts.SymbolFlags.Interface |
ts.SymbolFlags.Transient,
) &&
Comment on lines 87 to 90

This comment has been minimized.

@soobing

soobing Aug 29, 2020
Author Contributor

if you have any good idea to check symbol.flags === 33554497 please let me know.

This comment has been minimized.

@bradzacher

bradzacher Sep 6, 2020
Member

It might be better instead to just do something similar to what we've got for checking if the symbol is declared locally or not:

const declarations = symbol.getDeclarations() ?? [];
for (const declaration of declarations) {
const sourceFile = declaration.getSourceFile();
if (program.isSourceFileDefaultLibrary(sourceFile)) {
context.report({ node, messageId: 'noFunctionConstructor' });
return;
}
}

This comment has been minimized.

@soobing

soobing Sep 7, 2020
Author Contributor

@bradzacher Thank you for review. I updated to check if the symbol is declared locally or not :)

@soobing soobing changed the title [no-implied-eval] In 'isFunctionType' function should return 'true' when using Function type of typescript fix(no-implied-eval): In 'isFunctionType' function should return 'true' when using Function type of typescript Aug 29, 2020
@bradzacher bradzacher added the bug label Aug 29, 2020
@bradzacher bradzacher changed the title fix(no-implied-eval): In 'isFunctionType' function should return 'true' when using Function type of typescript fix(eslint-plugin): [no-implied-eval] handle the `Function` type Aug 29, 2020
soobing added 2 commits Sep 9, 2020
Copy link
Member

@bradzacher bradzacher left a comment

LGTM - thanks for your contribution!

@bradzacher bradzacher merged commit e1401dc into typescript-eslint:master Sep 14, 2020
9 of 10 checks passed
9 of 10 checks passed
Typecheck
Details
Unit tests Unit tests
Details
Code style and lint
Details
Run integration tests on primary Node.js version
Details
Run unit tests on other Node.js versions (10.x)
Details
Run unit tests on other Node.js versions (14.x)
Details
Publish the latest code as a canary version
Details
codecov/patch Codecov Report
Details
Semantic Pull Request ready to be squashed
Details
codecov/project Codecov Report
Details
phaux added a commit to phaux/typescript-eslint that referenced this pull request Sep 28, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants