oxc-project/oxc · error · OxcDiagnostic
Unexpected unnamed {inferred_name_or_description}.
Error message
Unexpected unnamed {inferred_name_or_description}. What it means
Lint diagnostic from eslint/func-names: an anonymous function expression was found in a position where no name can be inferred (e.g. an IIFE or an unassigned expression), so the function will show as '(anonymous)' in stack traces and profilers.
Source
Thrown at crates/oxc_linter/src/rules/eslint/func_names.rs:35
use schemars::JsonSchema;
use serde::Deserialize;
use crate::{
AstNode,
ast_util::get_function_name_with_kind,
context::LintContext,
fixer::{RuleFix, RuleFixer},
rule::{Rule, TupleRuleConfig},
};
fn named_diagnostic(function_name: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("Unexpected named {function_name}."))
.with_label(span)
.with_help("Remove the name on this function expression.")
}
fn unnamed_diagnostic(inferred_name_or_description: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("Unexpected unnamed {inferred_name_or_description}."))
.with_label(span)
.with_help("Consider giving this function expression a name.")
}
#[derive(Debug, Default, Clone, Copy, PartialEq, JsonSchema, Deserialize)]
#[serde(rename_all = "kebab-case")]
enum FuncNamesConfigType {
/// Requires all function expressions to have a name.
#[default]
Always,
/// Requires a name only if one is not automatically inferred.
AsNeeded,
/// Disallows names for function expressions.
Never,
}
#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]
#[serde(default)]View on GitHub (pinned to e1e7af627c)
Solutions
- Give the function expression a name
- Assign the expression to a variable or property so a name can be inferred
- Configure the rule (allowExpressions/allowAnonymousFunctions equivalents) if anonymous functions are intentional in this position
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/eslint/func_names.rs:35 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/d8ec682f0c969001.
Report an issue: GitHub.