Skip to content

[strict-boolean-expressions] Add option to allow null and undefined #698

Closed
@sindresorhus

Description

@sindresorhus

The strict-boolean-expressions rule was added recently, but it's missing many of the options from the TSLint rule. I agree that many of those options makes the rule pointless, but I also think the rule is too strict by default. It results in very verbose code for no good reason.

An option to allow undefined and null in the union would be useful. Equivalent to the TSLint allow-null-union and allow-undefined-union options.

Such option would allow this pattern which is very common:

if (previousComment && previousComment.closest('.js-timeline-item') !== comment) {

^ Which does a quick null/undefined check before operating on a variable.

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