javascript-unicorn-empty-brace-spaces-enforcement
Normalizes whitespace-only empty brace pairs from { } to {} in JS-family source, aligned with the intent of eslint-plugin-unicorn's empty-brace-spaces rule.
Installation
bash
Usage
By default the codemod rewrites only runtime-syntax empty braces when the interior contains whitespace only:
- Object literals:
const value = { };->const value = {}; - Object patterns:
let { } = source;->let {} = source; - Empty named imports:
import { } from "pkg";->import {} from "pkg"; - Empty named exports:
export { };->export {};
The workflow scans .js, .jsx, .mjs, .cjs, .ts, .mts, .cts, and .tsx files and ignores node_modules, dist, build, and coverage.
Preserve and no-op behavior:
- Non-empty braces stay unchanged.
- JSX expression container braces such as
<Comp prop={ } />stay unchanged. - Type-space braces such as
type T = { };stay unchanged by default. - Braces containing comments stay unchanged by default.
- Empty blocks are excluded by default.
Optional workflow parameters:
include-empty-blocks=true: also normalize same-line emptystatement_blockbraces such asif (x) { }.include-type-braces=true: also normalize empty TypeScriptobject_typebraces.remove-comments-in-empty-braces=true: unsafe mode that removes comment trivia inside otherwise-empty braces.
Run locally:
bash
Development
bash
License
MIT