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

New Rule: All paths in functions should resolve or reject a Promise #34

Closed
HamletDRC opened this issue Oct 5, 2015 · 2 comments
Closed
Milestone

Comments

@HamletDRC
Copy link
Member

This is very similar to #26 (#26)

This code is OK because all paths resolve or reject:

function myMethod() : Promise<void> {
    return new Promise<void>((resolve, reject) => {
        if (something) {
            resolve()
        } else {
            reject();
        }
    });
}

This code creates a violation because not all paths resolve/reject:

function myMethod() : Promise<void> {
    return new Promise<void>((resolve, reject) => {
        if (something) {
            resolve()
        }
    });
}

All of the rules for scope, variable shadowing, and type limitations apply from #26

@arogg
Copy link

arogg commented Oct 24, 2018

Tried second example, does not work with tslint 5.11.0 . Any yes I am using the --type-check and --project option :) Other rules from tslint-microsoft-contrib seem to work. ts version 3.1.3 and tslint-microsoft-contrib@5.2.1. and i have strict: true in my tsconfig

@JoshuaKGoldberg
Copy link

Hey @arogg, sorry to hear that! Would you mind filing a new issue with the following information:

  • File contents (is it exactly the second example, no modifications?)
  • Link to your project, if it's open source
  • tslint.json contents
  • How you're running TSLint, such as on the CLI or via the VS Code extension

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants