{"record":{"id":"ef2d8aa6c25e060d","repo":"oxc-project/oxc","slug":"unexpected-empty-named-import-block","errorCode":null,"errorMessage":"Unexpected empty named `import` block.","messagePattern":"Unexpected empty named `import` block\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/import/no_empty_named_blocks.rs","lineNumber":9,"sourceCode":"use oxc_ast::{AstKind, ast::ImportDeclarationSpecifier};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn no_empty_named_blocks_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Unexpected empty named `import` block.\").with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoEmptyNamedBlocks;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Enforces that named import blocks are not empty.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Empty named imports serve no practical purpose and often\n    /// result from accidental deletions or tool-generated code.\n    ///\n    /// ### Examples\n    ///\n    /// Examples of **incorrect** code for this rule:","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/a3d33dda7cb69da23db4fcaa2c0c05de61e760a1/crates/oxc_linter/src/rules/import/no_empty_named_blocks.rs#L1-L27","documentation":"Diagnostic from the oxlint rule import/no-empty-named-blocks (suspicious category, autofixable). It fires when a named import block has zero specifiers: `import {} from 'mod'` or `import Default, {} from 'mod'` (including `import type {} from 'mod'` and whitespace-free forms like `import{}from'mod'`). Empty blocks do nothing and are usually debris from accidental deletions or tool-generated code. The rule ships a fix: it deletes the whole statement for the bare case, or removes the `, {}` fragment after a default specifier.","triggerScenarios":"An ImportDeclaration whose specifiers array exists but is empty (crates/oxc_linter/src/rules/import/no_empty_named_blocks.rs:56), or a lone default specifier followed by `, {}` before `from` (lines 64-89). Bare side-effect imports (`import 'mod'`) are not flagged.","commonSituations":"Codemods that remove named imports but leave the braces; half-finished refactors where a named import was moved elsewhere; generated files from scaffolding tools.","solutions":["Run `oxlint --fix` — the statement is auto-deleted (`import {} from 'mod'`) or the empty block is removed (`import Default, {} from 'mod'` → `import Default from 'mod'`)","Delete the empty import statement manually if you cannot run the fixer","Check your codemod/generator if these appear repeatedly — fix it at the source"],"exampleFix":"// before\nimport {} from 'mod';\nimport Default, {} from 'mod';\n\n// after\nimport Default from 'mod';","handlingStrategy":"validation","validationCode":"// rg -n \"^\\\\s*import\\\\s+(type\\\\s+)?\\\\{\\\\s*\\\\}\\\\s+from\" src\n// .oxlintrc.json: { \"rules\": { \"import/no-empty-named-blocks\": \"warn\" } }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `oxlint --fix` after codemods that delete imported names — it removes the husk","When removing the last named import, delete the whole statement, not just the specifier","Add the rule to CI so debris never accumulates"],"tags":["lint","oxlint","imports","dead-code","autofix","suspicious"],"backgroundTag":"empty-import-block","analyzedSha":"a3d33dda7cb69da23db4fcaa2c0c05de61e760a1","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}