{"record":{"id":"685a78fe2548068b","repo":"oxc-project/oxc","slug":"no-spaces-inside-empty-pair-of-braces-allowed","errorCode":null,"errorMessage":"No spaces inside empty pair of braces allowed","messagePattern":"No spaces inside empty pair of braces allowed","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/unicorn/empty_brace_spaces.rs","lineNumber":9,"sourceCode":"use oxc_ast::AstKind;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn empty_brace_spaces_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"No spaces inside empty pair of braces allowed\")\n        .with_help(\"There should be no spaces or new lines inside a pair of empty braces as it affects the overall readability of the code.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct EmptyBraceSpaces;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Removes the extra spaces or new line characters inside a pair of braces\n    /// that does not contain additional code. This ensures that braces are clean\n    /// and do not contain unnecessary spaces or newlines.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Extra spaces inside braces can negatively impact the readability of the code.\n    /// Keeping braces clean and free of unnecessary characters improves consistency and","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/empty_brace_spaces.rs#L1-L27","documentation":"Diagnostic from oxlint's `unicorn/empty-brace-spaces` rule. It reports braces that are empty but contain whitespace or newlines: empty object literals (`{ }`), empty function bodies, empty class bodies (`class A {\\n}`), empty block statements, and empty `static {}` blocks. Braces containing comments between them are respected and not flagged. The autofix rewrites the whole span to `{}` (or `static {}` for static blocks).","triggerScenarios":"Any empty brace pair whose span is longer than two characters — `const a = {  };`, `class A {\\n}`, `function f() { }`, `if (x) { }`, `static { }` — with no comments inside.","commonSituations":"Formatter divergence (Prettier not run on the file), code pasted from editors that expand braces, and CI lint runs on manually edited files where format-on-save was off.","solutions":["Run `oxlint --fix` (or your formatter) to collapse `{ }` to `{}`.","Enable format-on-save so brace layout is owned by the formatter, not hand edits.","If a comment inside the braces is intentional, the rule already skips it — keep the comment and no diagnostic fires."],"exampleFix":"// before\nconst a = {  };\nclass A {\n}\n// after\nconst a = {};\nclass A {}","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enable format-on-save so the formatter owns brace layout and empty braces stay `{}`.","Run `oxlint --fix` before CI lint so whitespace-only findings never block a build.","Note that braces containing comments are exempt — put the comment inside instead of disabling the rule."],"tags":["oxlint","lint","unicorn","formatting","whitespace","style"],"backgroundTag":"empty-braces-formatting","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}