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

Add new rule no-assert-equal-boolean #121

Merged
merged 1 commit into from
Nov 26, 2020

Conversation

bmish
Copy link
Member

@bmish bmish commented Nov 9, 2020

For enforcing usage of new assert.true(...) or assert.false(...) assertions.

@coveralls
Copy link

coveralls commented Nov 9, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling bd85fe0 on bmish:no-assert-equal-boolean into f67311b on platinumazure:master.

@bmish bmish force-pushed the no-assert-equal-boolean branch 3 times, most recently from f729996 to 4e5123e Compare November 9, 2020 02:05
if (!booleanArgument.value) {
countNegations++;
}
const newAssertionFunctionName = countNegations % 2 === 0 ? "true" : "false";

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".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@bmish bmish force-pushed the no-assert-equal-boolean branch from 4e5123e to efad896 Compare November 9, 2020 19:37
@bmish bmish force-pushed the no-assert-equal-boolean branch from efad896 to 2fd5632 Compare November 9, 2020 19:54
@bmish bmish force-pushed the no-assert-equal-boolean branch from 2fd5632 to 27391ed Compare November 24, 2020 17:00
@bmish
Copy link
Member Author

bmish commented Nov 24, 2020

@platinumazure ready for review.

Copy link
Collaborator

@platinumazure platinumazure left a 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!

},
fixable: "code",
messages: {
general: "Use assert.true(...) or assert.false(...) for boolean assertions."
Copy link
Collaborator

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.

Suggested change
general: "Use assert.true(...) or assert.false(...) for boolean assertions."
useAssertTrueOrFalse: "Use `assert.true` or `assert.false` for boolean assertions."

Copy link
Member Author

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!

Verified

This commit was signed with the committer’s verified signature.
JamesNK James Newton-King
@bmish bmish force-pushed the no-assert-equal-boolean branch from 27391ed to bd85fe0 Compare November 24, 2020 23:33
@platinumazure platinumazure merged commit 4f085b1 into qunitjs:master Nov 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants