{"record":{"id":"adbe6a7947ac640f","repo":"oxc-project/oxc","slug":"missing-padding-before-name-block","errorCode":null,"errorMessage":"Missing padding before {name} block","messagePattern":"Missing padding before (.+?) block","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/utils/jest/padding_around_block.rs","lineNumber":9,"sourceCode":"use oxc_ast::{AstKind, ast::Statement};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_semantic::AstNode;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::context::LintContext;\n\nfn padding_around_jest_block_diagnostic(span: Span, name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"Missing padding before {name} block\"))\n        .with_help(format!(\"Make sure there is an empty new line before the {name} block\"))\n        .with_label(span)\n}\n\npub fn report_missing_padding_before_jest_block<'a>(\n    node: &AstNode<'a>,\n    ctx: &LintContext<'a>,\n    name: &str,\n) {\n    let scope_node = ctx.nodes().get_node(ctx.scoping().get_node_id(node.scope_id()));\n    let prev_statement_span = match scope_node.kind() {\n        AstKind::Program(program) => get_statement_span_before_node(node, program.body.as_slice()),\n        AstKind::ArrowFunctionExpression(arrow_func_expr) => {\n            let Some(body) = arrow_func_expr.get_function_body() else { return };\n            get_statement_span_before_node(node, body.statements.as_slice())\n        }\n        AstKind::Function(function) => {\n            let Some(body) = &function.body else {","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/utils/jest/padding_around_block.rs#L1-L27","documentation":"Diagnostic produced by the shared Jest helper `report_missing_padding_before_jest_block` (crates/oxc_linter/src/utils/jest/padding_around_block.rs), used by the `jest/*padding-around-*-blocks*` style rules (e.g. padding around describe/beforeEach/beforeAll/afterAll blocks). The helper finds the statement immediately before the block, examines the whitespace between them (walking backwards over any comments so a comment directly attached to the block counts as part of it), and reports when the source text between contains fewer than 2 newline characters — i.e. no empty line separates the previous statement from the block.","triggerScenarios":"In a test file, a describe/hook/test block that starts on the line immediately after the previous statement with no blank line: `const x = 1;\\ndescribe('foo', () => {})`. The comment loop adjusts boundaries: `const x = 1;\\n// note\\ndescribe(...)` still fails because the space before the comment has no newline; a blank line anywhere in the gap (2+ newlines in `span_between`) passes. Reported per block, with an auto-fix that replaces the in-between whitespace with `\\n\\n` plus the original indentation.","commonSituations":"Teams adopting `@stylistic/padding-around-test-blocks`-style rules for readable test files; new tests inserted quickly without blank lines; code generated by snippets or AI tools that omit blank lines.","solutions":["Add an empty line before the flagged describe/beforeEach/it block.","Run `oxlint --fix` — the rule's fixer rewrites the gap to `\\n\\n` preserving indentation.","Configure your editor/format-on-save to keep blank lines around test blocks, or turn the specific padding rule off in .oxlintrc.json if the style is unwanted."],"exampleFix":"// before\nconst helper = () => {}\ndescribe('foo', () => {\n  it('works', () => {})\n})\n\n// after\nconst helper = () => {}\n\ndescribe('foo', () => {\n  it('works', () => {})\n})","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `oxlint --fix` on save — the fixer inserts the blank line and preserves indentation.","Keep blank lines around describe/hook/test blocks as a formatting habit (or a .editorconfig / Prettier heuristic).","Turn off the specific jest padding rule in .oxlintrc.json if your team does not want the style."],"tags":["jest","style","formatting","lint","autofix"],"backgroundTag":"lint-formatting-padding","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"}