Skip to content

Commit

Permalink
Fix: literal-compare-order crash on BDD-style assertions (fixes #74)
Browse files Browse the repository at this point in the history
  • Loading branch information
platinumazure committed May 12, 2020
1 parent 5dec4fc commit e055c1b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const ASSERTION_METADATA = {
function getAssertionMetadata(calleeNode, assertVar) {
if (calleeNode.type === "MemberExpression") {
return calleeNode.object &&
calleeNode.object.type === "Identifier" &&
calleeNode.object.name === assertVar &&
calleeNode.property &&
Object.hasOwnProperty.call(ASSERTION_METADATA, calleeNode.property.name) &&
Expand Down
5 changes: 4 additions & 1 deletion tests/lib/rules/literal-compare-order.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ ruleTester.run("literal-compare-order", rule, {
wrap("notPropEqual(variable, 'Literal');"),
wrap("notPropEqual(variable, 'Literal', 'Message');"),
wrap("assert.notPropEqual(variable, 'Literal');"),
wrap("assert.notPropEqual(variable, 'Literal', 'Message');")
wrap("assert.notPropEqual(variable, 'Literal', 'Message');"),

// avoid crash in BDD-style assertions
"QUnit.test('Name', function() { expect(variable).to.equal('Literal'); });"
],
invalid: [
// equal
Expand Down

0 comments on commit e055c1b

Please sign in to comment.