Skip to content

Commit

Permalink
requirePaddingNewlinesBeforeKeywords: allow same line function return
Browse files Browse the repository at this point in the history
This adds an exception in the logic of the rule to
allow returning an anonymous function

```js
// valid
function func() {
    var a = 0;

    return function() {/*...*/}
}
```

Closes jscs-devgh-1997
  • Loading branch information
adambullmer authored and hzoo committed Jan 27, 2016
1 parent fc4fa40 commit b70a925
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/specs/rules/require-padding-newlines-before-keywords.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,5 +138,15 @@ describe('rules/require-padding-newlines-before-keywords', function() {
'function x() { var a; return; }'
)).to.have.one.validation.error.from('requirePaddingNewlinesBeforeKeywords');
});

it('should not report when returning a function', function() {
expect(checker.checkString(
'function x() {\n' +
' var a = 0;\n' +
' \n' +
' return function() {};\n' +
'}'
)).to.have.no.errors();
});
});
});

0 comments on commit b70a925

Please sign in to comment.