Skip to content
This repository was archived by the owner on Mar 25, 2021. It is now read-only.
This repository was archived by the owner on Mar 25, 2021. It is now read-only.

New rule to only allow boolean statements in logical expressions #253

Closed

Description

@oefirouz

Disallow if (expr) unless expr is a boolean.

So no if (obj)... rather if (obj != null)

Activity

  1. ashwinr commented on Dec 18, 2014

    @ashwinr
    Contributor

    the "unless expr is a boolean" might be troublesome since we don't use the typing annotations from the compiler yet. we'll need to investigate that.

  2. adidahiya commented on Apr 24, 2015

    @adidahiya
    Contributor

    I think the new TS APIs have support for type information about nodes. This should be doable.

  3. added this to the TSLint 3.0 milestone on Oct 6, 2015
  4. adidahiya commented on Oct 6, 2015

    @adidahiya
    Contributor

    blocked on #680

  5. changed the title [-]Add rule to only allow boolean statements in logical expression[/-] [+]New rule to only allow boolean statements in logical expressions[/+] on Oct 6, 2015
  6. 2 remaining items

  7. jkillian commented on Aug 19, 2016

    @jkillian
    Contributor

    See microsoft/TypeScript#9702 as well, although as far as I can tell they haven't decided to implement this yet. This shouldn't be too hard to do now on our end!

  8. Sammons commented on Aug 19, 2016

    @Sammons

    I would really like this to help with not coercing promise-like types to booleans, but I think it would be really nice if we could explicitly enable certain types (strings, numbers) for coercion.

  9. radykov commented on Sep 20, 2016

    @radykov

    I think the new TS APIs have support for type information about nodes. This should be doable.

    Would it be able to pick up things such as x = y || z;?
    I'm unfamiliar with TS APIs and what was meant by nodes

  10. adidahiya commented on Sep 20, 2016

    @adidahiya
    Contributor

    @radykov

    Would it be able to pick up things such as x = y || z;?

    yes, that check should probably be incorporated into this lint rule.

  11. OliverJAsh commented on Sep 26, 2016

    @OliverJAsh
    Contributor

    This would be really handy and catch so many bugs.

  12. adidahiya commented on Feb 26, 2017

    @adidahiya
    Contributor

    fixed via #1820

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions