oxc-project/oxc · error · OxcDiagnostic

File has too many dependencies ({}). Maximum allowed is {}.

Error message

File has too many dependencies ({}). Maximum allowed is {}.

What it means

Raised by import/max_dependencies after run_once counts unique imported module specifiers and the count exceeds the configured max. The span labeled is the first import that pushed the count over the limit, and the message reports both the actual and allowed counts.

Source

Thrown at crates/oxc_linter/src/rules/import/max_dependencies.rs:150

            if dependency_sources.insert(entry.module_request.name()) {
                module_count += 1;
                if module_count > self.max && first_exceeding_span.is_none() {
                    first_exceeding_span = Some(entry.module_request.span);
                }
            }
        }

        if module_count <= self.max {
            return;
        }

        let Some(span) = first_exceeding_span else {
            return;
        };

        let error = format!(
            "File has too many dependencies ({}). Maximum allowed is {}.",
            module_count, self.max,
        );
        ctx.diagnostic(max_dependencies_diagnostic(error, span));
    }
}

#[test]
fn test() {
    use serde_json::json;

    use crate::tester::Tester;

    let pass = vec![
        (
            r"
            import './foo.js';
            ",
            None,

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Split the module into smaller units with fewer imports
  2. Remove unused dependencies
  3. Raise or disable the `max` option if the high count is justified
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/import/max_dependencies.rs:150 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/862d36c9bd7f5593. Report an issue: GitHub.