Skip to content

[strict-boolean-expression] Rework options #1515

Closed
@bradzacher

Description

@bradzacher

Original comment by @phaux in #1480

Here are the cases that I encounter often and could have an option to allow them:

  • boolean – always allowed
  • boolean | null | undefined aka optional/nullable boolean – developers often want to treat the nullish case the same as false instead of explicitly saying value ?? false or value == null ? false : value
    • allowed by allowNullable
  • string | number – developers often want to test for zero/empty string without explicit comparison value != 0 etc.
    • would be allowed by e.g. allowPrimitive or something
  • object | function | null | undefined aka nullable object/function – developers often check against the nullish case without explicitly comparing to null. I've met a lot of people that don't even know that value == null also checks for undefined.
    • would be allowed by allowSafe if we can fix it, or allowNullableObject or something

We've learned a lot about this rule and how people want to use it. We should look into reworking the options so that it matches how people want to use the rule.

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking changeThis change will require a new major version to be releasedenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulepackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions