Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Configs: [prefer-nullish-coalescing] change default for ignoreConditionalTests to true #8243

Copy link
Copy link
Closed
@bradzacher

Description

@bradzacher
Issue body actions

Before You File a Proposal Please Confirm You Have Done The Following...

Description

Ref: #7955

IMO most codebases would prefer to avoid nullish coalescing in conditional tests.

Consider the downlevelled output:

if (x || y) { }

// vs

if (x ?? y) { } 
// downlevelled to
if (x != null ? x : y) { }

There's an extra check there that doesn't do anything.

The logic behind the latter is much harder to grasp exactly, IMO:

  • If x is truthy, then true,
  • If x is falsey and not nullish, then false,
  • Else the boolean coercion of y

vs the former:

  • If x is falsey then false
  • Else the boolean coercion of y

It's just A lot simpler to read and understand the non-nullish-coalescing form, IMO.

Impacted Configurations

No response

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebreaking changeThis change will require a new major version to be releasedThis change will require a new major version to be releasedlocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-pluginpreset config changeProposal for an addition, removal, or general change to a preset configProposal for an addition, removal, or general change to a preset config

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.