Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Docs: wrong information for rule inno-unnecessary-boolean-literal-compare #6897

Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issuedocumentationDocumentation ("docs") that needs adding/updating
@thariq-nugrohotomo

Description

@thariq-nugrohotomo

Before You File a Documentation Request Please Confirm You Have Done The Following...

Suggested Changes

I'm reading through the documentation inhttps://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare/#fixer and seeing the following part:

ComparisonFixer Output
nullableBooleanVar === falsenullableBooleanVar ?? true
nullableBooleanVar !== false!(nullableBooleanVar ?? true)

I believe both of them are wrong, i.e. the statement incomparison andfixer output are not equal.

To show how those are wrong, we can simply compare final evaluation result for each possible value ofnullableBooleanVar =true,false, andundefined. (null will be treated as same asundefined).

VariablenullableBooleanVarComparisonnullableBooleanVar === falseFixer OutputnullableBooleanVar ?? true
truefalsetrue
falsetruefalse
undefinedfalsetrue

As shown above, we can see that the reportedFixer Output on the right-side will use expression that evaluate to different value from the original code on the middle.

VariablenullableBooleanVarComparisonnullableBooleanVar !== falseFixer Output!(nullableBooleanVar ?? true)
truetruefalse
falsefalsetrue
undefinedtruefalse

Again, as shown above, we can see that the reportedFixer Output on the right-side will use expression that evaluate to different value from the original code on the middle.

I can't advise about what the correct (expected)Fixer Output should be. The reason why I read this documentation in the first place is because I'm not sure how to fix my code. Yet the documentation gives incorrect information.

Also, I'm not sure whether this issue is also happen to your Fixer utility, since I'm not using it. I always fix lint error by hand ;-) or IDE.

Thanks.

Affected URL(s)

https://typescript-eslint.io/rules/no-unnecessary-boolean-literal-compare/#fixer

Metadata

Metadata

Assignees

No one assigned

    Labels

    accepting prsGo ahead, send a pull request that resolves this issuedocumentationDocumentation ("docs") that needs adding/updating

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp