-
Notifications
You must be signed in to change notification settings - Fork 22
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 new rule no-assert-equal-boolean
#121
Conversation
f729996
to
4e5123e
Compare
lib/rules/no-assert-equal-boolean.js
Outdated
if (!booleanArgument.value) { | ||
countNegations++; | ||
} | ||
const newAssertionFunctionName = countNegations % 2 === 0 ? "true" : "false"; |
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 could be simplified to booleanArgument.value ? "true" : "false"
.
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.
Updated.
4e5123e
to
efad896
Compare
efad896
to
2fd5632
Compare
2fd5632
to
27391ed
Compare
@platinumazure ready for review. |
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.
Just a few thoughts on the lint message and messageId, otherwise looks great. Thanks for your patience!
lib/rules/no-assert-equal-boolean.js
Outdated
}, | ||
fixable: "code", | ||
messages: { | ||
general: "Use assert.true(...) or assert.false(...) for boolean assertions." |
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.
Some thoughts on the message:
- "general" is a very general messageId, let's use something more specific (not attached to anything in particular)
- I like using backticks for code references
- I don't think "(...)" adds much useful info. I would be okay with no parentheses or just "()".
I've provided a suggestion to remove the parentheses altogether and use a different messageId, but I'm not strongly attached to those particular changes.
general: "Use assert.true(...) or assert.false(...) for boolean assertions." | |
useAssertTrueOrFalse: "Use `assert.true` or `assert.false` for boolean assertions." |
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.
Sounds good, adopted your suggestions!
27391ed
to
bd85fe0
Compare
For enforcing usage of new
assert.true(...)
orassert.false(...)
assertions.