Skip to content
This repository was archived by the owner on Apr 29, 2022. It is now read-only.
This repository was archived by the owner on Apr 29, 2022. It is now read-only.

Use of strict-boolean-expressions #29

@narkowicz

Description

@narkowicz

The configuration of tslint: strict-boolean-expressions currently prevents using short-circuit evaluation in assignment as per Airbnb's 15.7 no-unneeded-ternary:

This type is not allowed in the operand for the '||' operator because it is always truthy.

There's an issue palantir/tslint#3279 concerning the application of strict-boolean-expressions in different contexts that will hopefully allow excluding assignments - which would support loosening the rule to support compliance with no-unneeded-ternary.

Meanwhile there is no ideal setting, but I've currently overridden the rule to the following:

"strict-boolean-expressions": [
  true,
  "allow-null-union",
  "allow-undefined-union",
  "allow-string",
  "allow-mix"
]

It's not ideal... 😐 but helps compliance with 15.7 for string building and assignment (at the cost of compliance with 15.3), while not allowing numbers prevents using array length without a comparison which seems to be the most common violation of 15.3 at the cost of excluding use of numbers in logical assignment.

I appreciate there are a lot of inconsistencies with the eslint implementation due largely to rule availability and differing coding standards - so mainly just flagging the open tslint issue and more generally interested in your thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions