Skip to content

New Rule: 默认开启 no-unneeded-ternary #73

@SyMind

Description

@SyMind

https://eslint.org/docs/rules/no-unneeded-ternary

no-unneeded-ternary 检查非必要的三元表达式。

// Bad
var isYes = answer === 1 ? true : false;

// Good
var isYes = answer === 1;


// Bad
var isNo = answer === 1 ? false : true;

// Good
var isNo = answer !== 1;

// Bad
foo(bar ? bar : 1);

// Good
foo(bar || 1);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions