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): check optional chaining for floating promises #4096

Merged
merged 1 commit into from Nov 11, 2021
Merged

fix(eslint-plugin): check optional chaining for floating promises #4096

merged 1 commit into from Nov 11, 2021

Conversation

G-Rath
Copy link
Contributor

@G-Rath G-Rath commented Nov 6, 2021

PR Checklist

Overview

Changes no-floating-promises to "expand" optional chain so that it's expression is checked.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @G-Rath!

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 Nov 6, 2021

Codecov Report

Merging #4096 (4bced73) into master (c289d13) will increase coverage by 0.21%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #4096      +/-   ##
==========================================
+ Coverage   93.11%   93.33%   +0.21%     
==========================================
  Files         174      152      -22     
  Lines        9619     8029    -1590     
  Branches     3004     2576     -428     
==========================================
- Hits         8957     7494    -1463     
+ Misses        248      180      -68     
+ Partials      414      355      -59     
Flag Coverage Δ
unittest 93.33% <100.00%> (+0.21%) ⬆️

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

Impacted Files Coverage Δ
...es/eslint-plugin/src/rules/no-floating-promises.ts 100.00% <100.00%> (ø)
packages/typescript-estree/src/convert-comments.ts
packages/typescript-estree/src/simple-traverse.ts
...ript-estree/src/create-program/createSourceFile.ts
...plugin-internal/src/rules/prefer-ast-types-enum.ts
...ges/typescript-estree/src/create-program/shared.ts
packages/typescript-estree/src/version-check.ts
packages/typescript-estree/src/node-utils.ts
...internal/src/rules/no-typescript-default-import.ts
...estree/src/create-program/createIsolatedProgram.ts
... and 13 more

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.

🔥

Comment on lines +68 to +72
let expression = node.expression;

if (expression.type === AST_NODE_TYPES.ChainExpression) {
expression = expression.expression;
}
Copy link
Member

Choose a reason for hiding this comment

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

Nit: this is similar to skipChainExpression from padding-line-between-statements. You might consider making a util for it? I imagine this situation is one that will keep coming up.

Not a blocker, just a thought!

@bradzacher bradzacher added the bug Something isn't working label Nov 11, 2021
@bradzacher bradzacher merged commit d724777 into typescript-eslint:master Nov 11, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 12, 2021
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.

[no-floating-promises] optionally called function that return a promise is not flagged
3 participants