{"record":{"id":"3958fe230d926610","repo":"oxc-project/oxc","slug":"a-control-must-be-associated-with-a-text-label","errorCode":null,"errorMessage":"A control must be associated with a text label.","messagePattern":"A control must be associated with a text label\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/jsx_a11y/control_has_associated_label.rs","lineNumber":28,"sourceCode":"use 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, get_jsx_attribute_name, get_string_literal_prop_value, has_jsx_prop,\n        is_hidden_from_screen_reader, is_interactive_element, is_interactive_role,\n        is_react_component_name,\n    },\n};\n\nfn control_has_associated_label_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"A control must be associated with a text label.\")\n        .with_help(\n            \"Add a text label to the control element. This can be done by adding text content, an `aria-label` attribute, or an `aria-labelledby` attribute.\",\n        )\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct ControlHasAssociatedLabel(Box<ControlHasAssociatedLabelConfig>);\n\n/// Elements that are always ignored (cannot reliably determine label source).\nconst ALWAYS_IGNORE_ELEMENTS: [&str; 1] = [\"link\"];\n\nconst DEFAULT_IGNORE_ELEMENTS: [&str; 7] =\n    [\"audio\", \"canvas\", \"embed\", \"input\", \"textarea\", \"tr\", \"video\"];\n\nconst DEFAULT_IGNORE_ROLES: [&str; 10] = [\n    \"grid\",\n    \"listbox\",","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/jsx_a11y/control_has_associated_label.rs#L10-L46","documentation":"Fires from jsx-a11y/control-has-associated-label when an element classified as a control (per the rule's controls list, e.g. dropdown, menu, autocomplete) has no accessible text label. The run visitor skips hidden elements and interactive elements with roles; unlabeled controls get this diagnostic.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/jsx_a11y/control_has_associated_label.rs:28 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add an aria-label, aria-labelledby, or visible text label to the control","Associate an existing label element with the control via htmlFor/id"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}