Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

promise-must-complete false positive when passing resolve/reject out of scope #329

Closed
connor4312 opened this issue Jan 2, 2017 · 2 comments
Assignees
Labels
Difficulty: Medium People with non-trivial experience in TSLint should be able to send a pull request for this issue. Microsoft Internal Issues related to closed source Microsoft code. Status: Accepting PRs Type: Rule Feature Adding a feature to an existing rule.

Comments

@connor4312
Copy link
Member

connor4312 commented Jan 2, 2017

Take the following code snippet that lazy-loads an external script:

new Promise(resolve => {
    const script = document.createElement('script');
    script.onload = resolve;
    script.src = 'http://example.com/script.js';
    document.body.appendChild(script);
});

This would fail with

demo.ts[1, 1]: A Promise was found that appears to not have resolve or reject invoked on all code paths

I would suggest providing a less-strict version of promise-must-complete rule, or an option, which bails out and allows the rule to pass when resolve and/or reject are made available outside the scope of the promise's closure.

@HamletDRC
Copy link
Member

Yes, so this was a conscious design decision. I like your recommendation of adding a parameter to make it a little less strict.

@HamletDRC HamletDRC added this to the 3.0.1 milestone Feb 17, 2017
@HamletDRC HamletDRC self-assigned this Feb 17, 2017
@HamletDRC HamletDRC added enhancement Microsoft Internal Issues related to closed source Microsoft code. labels Feb 17, 2017
@HamletDRC HamletDRC modified the milestones: None, 4.0.1 Mar 16, 2017
@JoshuaKGoldberg JoshuaKGoldberg added Status: Accepting PRs Difficulty: Medium People with non-trivial experience in TSLint should be able to send a pull request for this issue. Type: Rule Feature Adding a feature to an existing rule. and removed Type: Enhancement labels Jul 4, 2018
@JoshuaKGoldberg JoshuaKGoldberg removed this from the None milestone Jul 6, 2018
@JoshuaKGoldberg
Copy link

☠️ It's time! ☠️

Per #876, this repository is no longer accepting feature pull requests. TSLint is being deprecated and we recommend you switch to https://typescript-eslint.io.

Thanks for open sourcing with us, everyone!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Difficulty: Medium People with non-trivial experience in TSLint should be able to send a pull request for this issue. Microsoft Internal Issues related to closed source Microsoft code. Status: Accepting PRs Type: Rule Feature Adding a feature to an existing rule.
Projects
None yet
Development

No branches or pull requests

3 participants