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): [return-await] do not auto-fix when type is any/unknown #2671

Merged
merged 5 commits into from Oct 18, 2020

Conversation

thomasmichaelwallace
Copy link
Contributor

Resolves #2598

Specifically tadhgmister's solution:

If it detected that the value is type any and make a suggestion instead of a fix would that be satisfactory? That way it still gives a warning and IDE has quick fix but the --fix command doesn't remove your await?

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @thomasmichaelwallace!

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 bot commented Oct 13, 2020

Codecov Report

Merging #2671 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2671   +/-   ##
=======================================
  Coverage   92.78%   92.78%           
=======================================
  Files         294      294           
  Lines        9676     9680    +4     
  Branches     2713     2715    +2     
=======================================
+ Hits         8978     8982    +4     
  Misses        330      330           
  Partials      368      368           
Flag Coverage Δ
#unittest 92.78% <100.00%> (+<0.01%) ⬆️

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

Impacted Files Coverage Δ
packages/eslint-plugin/src/rules/return-await.ts 95.87% <100.00%> (+0.17%) ⬆️

@thomasmichaelwallace
Copy link
Contributor Author

Hmm. I'll take a look at the coverage.

Copy link
Contributor

@tadhgmister tadhgmister left a comment

Choose a reason for hiding this comment

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

While I don't expect people to run into the unknown case as much, since type unknown | Promise<unknown> collapses to just unknown and is therefore not considered await-able it is definitely desirable to also do suggestion for unknown types.

packages/eslint-plugin/src/rules/return-await.ts Outdated Show resolved Hide resolved
@bradzacher bradzacher added the bug Something isn't working label Oct 13, 2020
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

nice and simple. Thanks for fixing this.

@bradzacher bradzacher changed the title fix(eslint-plugin): [return-await] do not auto-fix against any fix(eslint-plugin): [return-await] do not auto-fix when type is any/unknown Oct 18, 2020
@bradzacher bradzacher merged commit d690c8d into typescript-eslint:master Oct 18, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[@typescript-eslint/return-await] False positive removal of await leading to control flow tampering
3 participants