oxc-project/oxc · error · OxcDiagnostic

Empty {statement_type} specifier is not allowed

Error message

Empty {statement_type} specifier is not allowed

What it means

Emitted by the unicorn/require-module-specifiers rule when an import or export declaration has a named-specifier list with no entries (`import {} from '...'` or `export {}`). It fires at the declaration span because an empty specifier list has no effect; a bare `import '...'` should be used for side-effect-only imports.

Source

Thrown at crates/oxc_linter/src/rules/unicorn/require_module_specifiers.rs:17

use oxc_ast::{
    AstKind,
    ast::{ExportNamedDeclaration, ImportDeclaration, ImportDeclarationSpecifier},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;

use crate::{
    AstNode,
    context::LintContext,
    fixer::{RuleFix, RuleFixer},
    rule::Rule,
};

fn require_module_specifiers_diagnostic(span: Span, statement_type: &str) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!("Empty {statement_type} specifier is not allowed"))
        .with_help("Remove empty braces")
        .with_label(span)
}

#[derive(Debug, Default, Clone)]
pub struct RequireModuleSpecifiers;

declare_oxc_lint!(
    /// ### What it does
    ///
    /// Enforce a non-empty specifier list in `import` and `export` statements.
    ///
    /// ### Why is this bad?
    ///
    /// Empty `import`/`export` specifiers add no value and can be confusing.
    /// If you want to import a module for side effects, use `import 'module'` instead.
    ///
    /// ### Examples

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Remove the declaration entirely if it is dead code
  2. Use a bare side-effect import `import 'module';` if only side effects are wanted
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/unicorn/require_module_specifiers.rs:17 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/8b07180189dbac98. Report an issue: GitHub.