For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt, and this page is available as Markdown at https://rslint.rs/rules/unicorn/empty-brace-spaces.md.
close

empty-brace-spaces

Added in v0.9.3

Configuration

PresetConfigured Value
✅ unicornPlugin.configs.recommended"error"
rslint.config.ts
import { defineConfig, unicornPlugin } from '@rslint/core';

export default defineConfig([
  unicornPlugin.configs.recommended,
  {
    rules: {
      'unicorn/empty-brace-spaces': 'error',
    },
  },
]);

Rule Details

Enforce no spaces between braces.

Empty blocks and object literals do not need internal whitespace, so this rule enforces a compact, consistent style. It applies to block statements, class bodies, static blocks, and object literals whose braces hold nothing but whitespace.

Examples of incorrect code for this rule:

class Unicorn {
}

try {
	foo();
} catch { }

const object = { };

Examples of correct code for this rule:

class Unicorn {}

try {
	foo();
} catch {}

const object = {};

The rule has no options. It is automatically fixable by removing the whitespace between the braces.

A comment between the braces counts as content, so the whitespace around it is left untouched:

class Unicorn { /* comment */ }

A brace pair in a class header is not mistaken for the class body: class Foo extends mixin({}) { } reports the body's space and fixes it to class Foo extends mixin({}) {}, and a header pair that is itself empty is reported separately.

Differences from ESLint

None.

Original Documentation