Skip to content

Commit

Permalink
Correct error message for "requireSpaceAfterKeywords" rule
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanDonovan authored and markelog committed Oct 19, 2014
1 parent 76be229 commit 9af1e27
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rules/require-space-after-keywords.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module.exports.prototype = {
if (nextToken.type !== 'Punctuator' || nextToken.value !== ';') {
errors.add(
util.format.apply(null,
diff === 1 ?
diff === 0 ?
[texts[0], token.value] :
[texts[1], diff, token.value]
),
Expand Down
6 changes: 5 additions & 1 deletion test/rules/require-space-after-keywords.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ describe('rules/require-space-after-keywords', function() {

it('should trigger different error for comments with more than one space', function() {
checker.configure({ requireSpaceAfterKeywords: ['if'] });
assert(checker.checkString('if(x) { x++; }').getErrorCount() === 1);

var errors = checker.checkString('if /**/(x) {}');
var error = errors.getErrorList()[0];

assert(errors.explainError(error).indexOf('Should be one space instead of 2, after "if"') === 0);
});

it('should report on all spaced keywords if a value of true is supplied', function() {
Expand Down

0 comments on commit 9af1e27

Please sign in to comment.