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

Commit 3a41563

Browse files
committed
Rule : do not fail on linebreaks
1 parent 859f760 commit 3a41563

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ module.exports.prototype = {
2323
if (keywordIndex[token.value]) {
2424
var nextToken = tokens[i + 1];
2525

26-
if (nextToken && nextToken.range[0] - token.range[1] !== 1) {
26+
if (nextToken &&
27+
nextToken.loc.end.line === token.loc.start.line &&
28+
nextToken.range[0] - token.range[1] !== 1
29+
) {
2730
if (nextToken.type !== 'Punctuator' || nextToken.value !== ';') {
2831
errors.add(
2932
'Missing space after `' + token.value + '` keyword',

test/rules/require-space-after-keywords.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,8 @@ describe('rules/require-space-after-keywords', function() {
3939
checker.configure({ requireSpaceAfterKeywords: ['if'] });
4040
assert(checker.checkString('function f() { if(true) {"something";} }').getErrorCount() === 1);
4141
});
42+
it('should not trigger error for spaced return inside function (#357)', function() {
43+
checker.configure({ requireSpaceAfterKeywords: ['return'] });
44+
assert(checker.checkString('function foo() {\r\n\treturn\r\n}').getErrorCount() === 0);
45+
});
4246
});

0 commit comments

Comments
 (0)