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

Commit 3d4e05a

Browse files
committed
requireSpaceBeforeKeywords: correct keywords check
Fixes #2135
1 parent 3e918af commit 3d4e05a

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/rules/require-space-before-keywords.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,11 @@ module.exports.prototype = {
5555
excludedKeywords = keywords.allExcept;
5656
}
5757

58-
keywords = defaultKeywords.filter(function(keyword) {
59-
return (excludedKeywords.indexOf(keyword) === -1);
60-
});
58+
if (!Array.isArray(keywords)) {
59+
keywords = defaultKeywords.filter(function(keyword) {
60+
return (excludedKeywords.indexOf(keyword) === -1);
61+
});
62+
}
6163

6264
this._keywords = keywords;
6365
},

test/specs/rules/require-space-before-keywords.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,12 @@ describe('rules/require-space-before-keywords', function() {
121121
expect(errors).to.have.one.validation.error.from('requireSpaceBeforeKeywords');
122122
expect(errors.explainError(error)).to.have.string('Missing space before "function" keyword');
123123
});
124+
125+
it('should ignore keywords that is not mentioned in the config list (#2135)', function() {
126+
checker.configure({ requireSpaceBeforeKeywords: [] });
127+
128+
expect(
129+
checker.checkString('if (typeof value !== "function") {}')
130+
).to.have.no.errors();
131+
});
124132
});

0 commit comments

Comments
 (0)