-
-
Notifications
You must be signed in to change notification settings - Fork 395
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
Add prefer-math-min-max
#2432
Add prefer-math-min-max
#2432
Conversation
docs/rules/prefer-math-min-max.md
Outdated
@@ -0,0 +1,56 @@ | |||
# Prefer `Math.min()` and `Math.max()` over ternary expressions for simple comparisons |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Prefer `Math.min()` and `Math.max()` over ternary expressions for simple comparisons | |
# Prefer `Math.min()` and `Math.max()` over ternaries for simple comparisons |
docs/rules/prefer-math-min-max.md
Outdated
<!-- end auto-generated rule header --> | ||
<!-- Do not manually modify this header. Run: `npm run fix:eslint-docs` --> | ||
|
||
Enforce the use of `Math.min()` and `Math.max()` instead of ternary expressions for simple comparisons. This makes the code more readable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is repeating the title.
Two edge cases will be broken
(0,foo) > 10 ? 10 : (0,foo)
function a() {
return+foo > 10 ? 10 : +foo
} |
This comment was marked as outdated.
This comment was marked as outdated.
Code coverage 100%, reached |
…mance
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job
col.width > 0 ? col.width : 0 conver to
It broke the logic. |
It's impossible to account for that without types. And I don't think it should account for that regardless. Implicit type conversion is an anti-pattern. If you want to do it, I suggest disabling the rule. |
Close #2373