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

Commit

Permalink
requireSpaceBeforeKeywords: correct keywords check
Browse files Browse the repository at this point in the history
Fixes #2135
  • Loading branch information
markelog committed Feb 15, 2016
1 parent c695048 commit 594a4ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/rules/require-space-before-keywords.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,11 @@ module.exports.prototype = {
excludedKeywords = keywords.allExcept;
}

keywords = defaultKeywords.filter(function(keyword) {
return (excludedKeywords.indexOf(keyword) === -1);
});
if (!Array.isArray(keywords)) {
keywords = defaultKeywords.filter(function(keyword) {
return (excludedKeywords.indexOf(keyword) === -1);
});
}

this._keywords = keywords;
},
Expand Down
8 changes: 8 additions & 0 deletions test/specs/rules/require-space-before-keywords.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,12 @@ describe('rules/require-space-before-keywords', function() {
expect(errors).to.have.one.validation.error.from('requireSpaceBeforeKeywords');
expect(errors.explainError(error)).to.have.string('Missing space before "function" keyword');
});

it('should ignore keywords that is not mentioned in the config list (#2135)', function() {
checker.configure({ requireSpaceBeforeKeywords: [] });

expect(
checker.checkString('if (typeof value !== "function") {}')
).to.have.no.errors();
});
});

0 comments on commit 594a4ee

Please sign in to comment.