oxc-project/oxc · error · OxcDiagnostic

{import_type} with empty attribute list is not allowed.

Error message

{import_type} with empty attribute list is not allowed.

What it means

Emitted by the unicorn/require-module-attributes rule when an import or export declaration carries an empty import-attributes object (`with {}`). It fires on the with-clause span because an empty attribute list is meaningless syntax — either attributes are needed (they must be non-empty) or the `with` clause should be removed entirely.

Source

Thrown at crates/oxc_linter/src/rules/unicorn/require_module_attributes.rs:19

use oxc_allocator::ArenaVec;
use oxc_ast::{
    AstKind,
    ast::{Expression, ObjectProperty, PropertyKind, WithClause},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::{GetSpan, Span};

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

fn require_module_attributes_diagnostic(span: Span, import_type: &str) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!("{import_type} with empty attribute list is not allowed."))
        .with_label(span)
        .with_help("Remove the unused import attribute.")
}

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

declare_oxc_lint!(
    /// ### What it does
    ///
    /// This rule enforces a non-empty attribute list in `import`/`export` statements and `import()` expressions.
    ///
    /// ### Why is this bad?
    ///
    /// Import attributes are meant to provide metadata about how a module should be loaded
    /// (e.g., `with { type: "json" }`). An empty attribute object provides no information
    /// and should be removed.
    ///

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Remove the empty `with {}` clause if no attributes are needed
  2. Add the intended attributes, e.g. `with { type: 'json' }`
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/unicorn/require_module_attributes.rs:19 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/4dd9e37e50718eb2. Report an issue: GitHub.