consistent-empty-lines
Enforce configured empty-line consistency between selected nodes.
Targeted pattern scope
This rule operates on the full file text and checks for runs of empty lines.
It allows:
- zero empty lines, or
- exactly one empty line between non-empty lines.
It reports when it finds two or more consecutive empty lines.
What this rule reports
This rule reports files containing consecutive blank-line runs longer than one line.
An autofix is provided and collapses each run to a single blank line.
Why this rule exists
Extra vertical whitespace often accumulates during edits and merge conflict resolution. Enforcing a single-blank-line maximum keeps files visually dense and reduces noisy formatting diffs.
❌ Incorrect
const first = 1;
const second = 2;
✅ Correct
const first = 1;
const second = 2;
Behavior and migration notes
This rule is fully autofixable (fixable: "whitespace").
Recommended rollout:
- Run once with
--fix-dry-runto estimate churn. - Apply autofix in a dedicated formatting PR.
- Enable as
errorto keep the baseline clean.
Options
This rule has no options.
Additional examples
function run(): void {
stepOne();
stepTwo();
}
ESLint flat config example
import etcMisc from "eslint-plugin-etc-misc";
export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/consistent-empty-lines": "error",
},
},
];
When not to use it
Disable this rule if your style guide intentionally allows multiple blank lines for sectioning or if another formatter already controls vertical spacing exactly as desired.
Package documentation
Rule catalog ID: R004
Further reading
Adoption resources
- Start at warning level in CI, then move to error after cleanup.
- Use focused codemods/autofix batches per package or directory.