Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 7e8c2af

Browse files
Rob--Wmarkelog
authored andcommitted
requireSpaceBeforeBinaryOperators: report "operator ="
Similar to #907, but for the spacing before the = operator. Before: "Operator undefined should not stick to preceding expression" After : "Operator = should not stick to preceding expression" Closes gh-1948
1 parent 874053d commit 7e8c2af

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

lib/rules/require-space-before-binary-operators.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ module.exports.prototype = {
113113
errors.assert.whitespaceBetween({
114114
token: prevToken,
115115
nextToken: operatorToken,
116-
message: 'Operator ' + node.operator + ' should not stick to preceding expression'
116+
message: 'Operator ' + operator + ' should not stick to preceding expression'
117117
});
118118
}
119119
}

test/specs/rules/require-space-before-binary-operators.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@ describe('rules/require-space-before-binary-operators', function() {
8989

9090
it('should report for assignment expression', function() {
9191
checker.configure({ requireSpaceBeforeBinaryOperators: ['='] });
92-
expect(checker.checkString('var x=1')).to.have.one.validation.error.from('requireSpaceBeforeBinaryOperators');
92+
var errors = checker.checkString('var x=1');
93+
expect(errors).to.have.one.validation.error.from('requireSpaceBeforeBinaryOperators');
94+
var error = errors.getErrorList()[0];
95+
expect(error.line).to.equal(1);
96+
expect(error.column).to.equal(5);
97+
expect(error.message).to.equal('Operator = should not stick to preceding expression');
9398
});
9499

95100
it('should report for assignment expressions', function() {

0 commit comments

Comments
 (0)