Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SyMind opened this issue Mar 17, 2022 · 1 comment
Open

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

SyMind opened this issue Mar 17, 2022 · 1 comment

Comments

@SyMind
Copy link
Contributor

SyMind commented Mar 17, 2022

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);
@SyMind
Copy link
Contributor Author

SyMind commented Mar 17, 2022

@otakustay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant