Skip to content

feat(eslint-plugin): [no-unsafe-call] check calls of Function #10010

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

Merged

Conversation

kirkwaiblinger
Copy link
Member

PR Checklist

Overview

  • Simply check for Function type in existing rule.
  • Minor cleanup of some sloppiness in the report messages, to ensure that they can say "Function typed" rather than "any typed"

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @kirkwaiblinger!

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.

Copy link

netlify bot commented Sep 18, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit d1e954c
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/66eae80754c5600008adfe22
😎 Deploy Preview https://deploy-preview-10010--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 99 (🟢 up 4 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

nx-cloud bot commented Sep 18, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit d1e954c. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@kirkwaiblinger kirkwaiblinger marked this pull request as ready for review September 18, 2024 04:23
Copy link

codecov bot commented Sep 18, 2024

Codecov Report

Attention: Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.70%. Comparing base (385bedb) to head (d1e954c).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
packages/eslint-plugin/src/rules/no-unsafe-call.ts 92.85% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10010   +/-   ##
=======================================
  Coverage   88.69%   88.70%           
=======================================
  Files         426      426           
  Lines       14829    14843   +14     
  Branches     4313     4318    +5     
=======================================
+ Hits        13153    13166   +13     
- Misses       1533     1534    +1     
  Partials      143      143           
Flag Coverage Δ
unittest 88.70% <92.85%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
packages/eslint-plugin/src/rules/no-unsafe-call.ts 97.05% <92.85%> (-2.95%) ⬇️

@kirkwaiblinger kirkwaiblinger marked this pull request as draft September 18, 2024 04:45
@kirkwaiblinger kirkwaiblinger marked this pull request as ready for review September 18, 2024 06:14
@@ -55,7 +55,7 @@ export function parseTSConfig(code?: string): TSConfig {
const moduleRegexp = /(module\.exports\s*=)/g;

function constrainedScopeEval(obj: string): unknown {
// eslint-disable-next-line @typescript-eslint/no-implied-eval
// eslint-disable-next-line @typescript-eslint/no-implied-eval, @typescript-eslint/no-unsafe-call
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear,

// this is the no-implied-eval violation
const yoloFunction = Function('inline function');
// this is the no-unsafe-call violation
yoloFunction();

They just happen to be on the same line here. So, this isn't a case of these rules stepping on each others' toes IMO.

Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Just some comments on testing/style, nothing major.

}
// etc
}
```
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Praise] Great example, really clear and concise.

return;
}
} else {
// eslint-disable-next-line no-lonely-if
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

y?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh. I'll revert that.

This is just my personal vendetta; I really, really dislike no-lonely-if. IMO if/elseif should only be used for conditions which can be safely reorded, which is incompatible with no-lonely-if

@JoshuaKGoldberg JoshuaKGoldberg added the awaiting response Issues waiting for a reply from the OP or another party label Sep 18, 2024
@kirkwaiblinger kirkwaiblinger added the enhancement New feature or request label Sep 18, 2024
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

@github-actions github-actions bot removed the awaiting response Issues waiting for a reply from the OP or another party label Sep 18, 2024
@JoshuaKGoldberg JoshuaKGoldberg added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Sep 18, 2024
@JoshuaKGoldberg JoshuaKGoldberg merged commit e8555a0 into typescript-eslint:main Sep 23, 2024
67 checks passed
@kirkwaiblinger kirkwaiblinger deleted the no-unsafe-call-Function branch September 23, 2024 16:24
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no-unsafe-call: ban calling Function
2 participants