Running newlines separating code blocks in eslint

I was clearing Eslint rule documents and cannot figure out how to apply newlines between blocks.

For example, in jscs, I can reject them for the absence of a separation line:

if (!rows.length) { // code } var pagination; if (something) { // code } 

"space-before-blocks" sounded as wanted, but it only applies to spaces, not newline characters.

+7
javascript eslint
source share
1 answer

The answer is a bit late, but now you can use the padding-line-between-statements rule to do this: http://eslint.org/docs/rules/padding-line-between-statements

I think the configuration you want will be similar to

 "padding-line-between-statements": [ "warn", { blankLine: 'always', prev: '*', next: 'block' }, { blankLine: 'always', prev: 'block', next: '*' }, { blankLine: 'always', prev: '*', next: 'block-like' }, { blankLine: 'always', prev: 'block-like', next: '*' }, ] 
0
source share

All Articles