I've been scouring the Eslint rule docs and cannot figure out how to enforce newlines between blocks.
For example, in jscs I can reject these for having no separating new line:
if (!rows.length) {
// code
}
var pagination;
if (something) {
// code
}
"space-before-blocks" sounded like it's what I wanted but it applies only to spaces, not newlines.
I've been scouring the Eslint rule docs and cannot figure out how to enforce newlines between blocks.
For example, in jscs I can reject these for having no separating new line:
if (!rows.length) {
// code
}
var pagination;
if (something) {
// code
}
"space-before-blocks" sounded like it's what I wanted but it applies only to spaces, not newlines.
Share Improve this question asked Mar 28, 2016 at 18:09 helion3helion3 37.4k16 gold badges64 silver badges110 bronze badges 1 |1 Answer
Reset to default 21Response is a bit late but you can now use the padding-line-between-statements
rule for this: http://eslint.org/docs/rules/padding-line-between-statements
I think the config you'd want would be something like
"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: '*' },
]
var
declaration. I'm still anxious to find a rule to enforce separation of the twoif
blocks in the case where thevar
isn't there, though. – rockerest Commented Mar 31, 2016 at 4:09