oxc-project/oxc · error · OxcDiagnostic
Do not use AMD `require` and `define` calls.
Error message
Do not use AMD `require` and `define` calls.
What it means
Fires from import/no-amd when an AMD-style define() or require() call (dependency-array callback form) is detected. The run visitor identifies the call by name and passes it to the diagnostic helper, whose help text notes ES imports were expected instead.
Source
Thrown at crates/oxc_linter/src/rules/import/no_amd.rs:12
use oxc_ast::{
AstKind,
ast::{Argument, Expression},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use crate::{AstNode, context::LintContext, rule::Rule};
fn no_amd_diagnostic(span: Span, name: &str) -> OxcDiagnostic {
OxcDiagnostic::warn("Do not use AMD `require` and `define` calls.")
.with_help(format!("Expected imports instead of AMD {name}()"))
.with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct NoAmd;
declare_oxc_lint!(
/// ### What it does
///
/// Forbids the use of AMD `require` and `define` calls.
///
/// ### Why is this bad?
///
/// AMD (Asynchronous Module Definition) is an older module format
/// that is less common in modern JavaScript development, especially
/// with the widespread use of ES modules and CommonJS in Node.js.
/// AMD introduces unnecessary complexity and is often considered outdated.View on GitHub (pinned to e1e7af627c)
Solutions
- Replace the AMD define()/require() call with ES import/export statements
- Use a bundler or loader that supports ES module syntax
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/import/no_amd.rs:12 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/ba7e300856e64627.
Report an issue: GitHub.