Skip to main content

Require Padding Lines

Require blank lines between specific statement patterns so code stays visually organized and easy to scan.

Summary

The require-padding-lines rule enforces blank lines in five situations:

  • Between process.exitCode assignments and return.
  • Before loop statements.
  • Around bare await expressions adjacent to declarations.
  • Between distinct expression-statement operations.
  • Between non-empty switch cases.

Why Use This Rule?

  1. Separates exit-code logic from the return statement so the intent is visually clear.
  2. Prevents loops from running into the declarations above them.
  3. Keeps bare await calls visually distinct from surrounding variable declarations.
  4. Adds breathing room between sequential method calls and await operations.
  5. Gives switch cases clear visual boundaries so each branch is easy to scan.

Examples

Configuration

Options

warning

ignoreFiles is an escape hatch for files where this rule genuinely does not apply. It is not intended for routine use.

OptionTypeDefaultDescription
bareAwaitbooleantrueRequire a blank line separating bare await from declarations.
beforeLineCommentbooleantrueRequire a blank line before // line comments preceded by code.
beforeLoopsbooleantrueRequire a blank line before for/while/do...while loop statements.
betweenOperationsbooleantrueRequire a blank line between distinct expression-statement operations.
betweenSwitchCasesbooleantrueRequire a blank line between non-empty switch cases.
exitCodeBeforeReturnbooleantrueRequire a blank line between process.exitCode = N and return.
ignoreFilesstring[][]File patterns to skip.

Set any option to false to disable that specific check.

Autofix

This rule provides automatic fixes for the beforeLineComment check. Other checks report errors that must be updated manually. Run ESLint with the --fix flag:

npx eslint --fix . --rule '@cbnventures/nova/require-padding-lines: error'

Troubleshooting

  • Warning fires between two loops — The beforeLoops check only fires when a loop is preceded by a non-loop statement. Consecutive loops do not trigger a warning.
  • Warning fires on an assigned await — The bareAwait check only targets await expressions that appear as standalone expression statements (no assignment). Assigned await like const x = await fn() is not affected.
  • No warning between repeated calls — The betweenOperations check compares callee names. Consecutive calls to the same function (e.g., ok(a); ok(b);) are considered the same operation and do not require a blank line.