{"record":{"id":"099d965609a401bd","repo":"oxc-project/oxc","slug":"interactive-elements-should-not-be-assigned-non-in","errorCode":null,"errorMessage":"Interactive elements should not be assigned non-interactive roles.","messagePattern":"Interactive elements should not be assigned non-interactive roles\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/jsx_a11y/no_interactive_element_to_noninteractive_role.rs","lineNumber":22,"sourceCode":"\nuse oxc_ast::{AstKind, ast::JSXAttributeValue};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\nuse oxc_str::CompactStr;\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    globals::HTML_TAG,\n    rule::{DefaultRuleConfig, Rule},\n    utils::{\n        get_element_type, has_jsx_prop_ignore_case, is_interactive_element, is_non_interactive_role,\n    },\n};\n\nfn no_interactive_element_to_noninteractive_role_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Interactive elements should not be assigned non-interactive roles.\")\n        .with_help(\"WAI-ARIA roles should not be used to convert an interactive element to a non-interactive element. Wrap the element or use a different structure.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct NoInteractiveElementToNoninteractiveRole(\n    Box<NoInteractiveElementToNoninteractiveRoleConfig>,\n);\n\n#[derive(Debug, Clone, Deserialize, JsonSchema)]\npub struct NoInteractiveElementToNoninteractiveRoleConfig {\n    /// A mapping of HTML element names to arrays of ARIA role strings that are\n    /// allowed overrides for that element.\n    #[serde(default, flatten)]\n    pub allowed_roles: FxHashMap<CompactStr, Vec<CompactStr>>,\n}\n\nimpl Default for NoInteractiveElementToNoninteractiveRoleConfig {","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/jsx_a11y/no_interactive_element_to_noninteractive_role.rs#L4-L40","documentation":"This is the `jsx_a11y/no-interactive-element-to-noninteractive-role` rule in oxlint. It fires when a natively interactive HTML element (per `is_interactive_element`, e.g. `<a href>`, `<button>`, `<input>`) is given a non-interactive ARIA role (per `is_non_interactive_role`, e.g. `listitem`, `heading`, `presentation`). Converting an interactive element to a non-interactive one removes expected semantics while it still behaves interactively.","triggerScenarios":"A JSX element resolved as an interactive HTML tag that also has a `role` attribute (found via `has_jsx_prop_ignore_case`) whose literal value is a non-interactive role, and the pair is not whitelisted in the rule's configurable `roles` mapping (HTML element name -> allowed role list).","commonSituations":"`<a href=\"#\" role=\"listitem\">` inside custom lists; `<button role=\"presentation\">` used to hide a control; CSS-framework markup that sprinkles roles on buttons/links; refactors that changed element types without updating roles.","solutions":["Remove the non-interactive `role` from the interactive element.","Restructure: wrap the interactive element in a container that carries the non-interactive role.","If the pairing is intentional, whitelist it in the rule config's per-element allowed roles mapping."],"exampleFix":"// before\n<a href=\"#\" role=\"listitem\" onClick={select}>Item</a>\n\n// after\n<li><a href=\"#\" onClick={select}>Item</a></li>","handlingStrategy":"validation","validationCode":"npx oxlint --jsx_a11y/no-interactive-element-to-noninteractive-role src/","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never override an interactive element's role with a non-interactive one; restructure instead.","Keep the rule's allowed-roles mapping tiny; add entries only with an a11y review.","When changing a tag in JSX, check its role attribute still matches."],"tags":["jsx-a11y","react","accessibility","aria-roles","lint"],"backgroundTag":"invalid-aria-role-assignment","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}