JS.TS.SPACE.BEFORE.BLOCKS

Enforce consistent spacing before blocks

Rule Details

This rule extends the base eslint/space-before-blocks (https://eslint.org/docs/rules/space-before-blocks) rule. It adds support for interfaces and enums:

Incorrect

Copy
enum Breakpoint{
  Large, Medium;
}

interface State{
  currentBreakpoint: Breakpoint;
}

Correct

Copy
enum Breakpoint {
  Large, Medium;
}

interface State {
  currentBreakpoint: Breakpoint;
}

In case a more specific options object is passed these blocks will follow classes configuration option.

How to Use

Copy
{
  // note you must disable the base rule as it can report incorrect errors
  "space-before-blocks": "off",
  "@typescript-eslint/space-before-blocks": ["error"]
}

Options

See eslint/space-before-blocks options (https://eslint.org/docs/rules/space-before-blocks#options).

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/