oxc-project/oxc · error · OxcDiagnostic
Prop "{prop}" is forbidden on Components
Error message
Prop "{prop}" is forbidden on Components What it means
Raised by react/forbid_component_props when a JSX attribute listed in the rule's forbiddenForProps config appears on a component (an element whose name is a React component name, i.e. capitalized or a member expression resolving to a component). At the throw site the user is passing a prop (commonly something like `className` on a styled wrapper or a context-consuming prop) that the configured policy forbids on components. add_diagnostic_if_invalid_element uses the custom message option if configured, otherwise this generic message.
Source
Thrown at crates/oxc_linter/src/rules/react/forbid_component_props.rs:26
use schemars::JsonSchema;
use serde::Deserialize;
use crate::utils::{get_jsx_element_name, is_react_component_name};
use crate::{
AstNode,
context::{ContextHost, LintContext},
rule::{DefaultRuleConfig, Rule},
};
fn forbid_component_props_diagnostic(
span: Span,
prop: &str,
message: Option<&str>,
) -> OxcDiagnostic {
if let Some(message) = message {
return OxcDiagnostic::warn(message.to_string()).with_label(span);
}
OxcDiagnostic::warn(format!("Prop \"{prop}\" is forbidden on Components")).with_label(span)
}
#[derive(Debug, Default, Clone)]
struct ForbidOption {
/// Whether this entry was defined via `propNamePattern` (glob) instead of `propName`.
is_pattern: bool,
allowed_for: Vec<CompactStr>,
allowed_for_patterns: Vec<CompactStr>,
disallowed_for: Vec<CompactStr>,
disallowed_for_patterns: Vec<CompactStr>,
message: Option<String>,
}
impl ForbidOption {
fn is_forbidden(&self, tag_name: Option<&str>) -> bool {
let Some(tag) = tag_name else {
return true;
};View on GitHub (pinned to e1e7af627c)
Solutions
- Remove the forbidden prop from the JSX/component call.
- Provide a custom message or alternative in the rule configuration to guide the replacement.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/react/forbid_component_props.rs:26 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/592f5b774b8deecd.
Report an issue: GitHub.