{"record":{"id":"9666165d1c19a3bb","repo":"oxc-project/oxc","slug":"avoid-positive-integer-values-for-tabindex","errorCode":null,"errorMessage":"Avoid positive integer values for `tabIndex`.","messagePattern":"Avoid positive integer values for `tabIndex`\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/jsx_a11y/tabindex_no_positive.rs","lineNumber":14,"sourceCode":"use oxc_ast::{AstKind, ast::JSXAttributeItem};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::Rule,\n    utils::{has_jsx_prop_ignore_case, parse_jsx_value},\n};\n\nfn tabindex_no_positive_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Avoid positive integer values for `tabIndex`.\")\n        .with_help(\"Change the `tabIndex` prop to a non-positive value.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct TabindexNoPositive;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Enforces that positive values for the `tabIndex` attribute are not used\n    /// in JSX.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Using `tabIndex` values greater than `0` can make navigation and\n    /// interaction difficult for keyboard and assistive technology users,\n    /// disrupting the logical order of content.","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/jsx_a11y/tabindex_no_positive.rs#L1-L32","documentation":"This is the `jsx_a11y/tabindex-no-positive` rule in oxlint. It fires when a `tabIndex` attribute's value (parsed via `parse_jsx_value`) is a positive number, e.g. `tabIndex={1}` or `tabIndex=\"2\"`. Positive values override the document's natural DOM order and create an unpredictable, chaotic tab sequence for keyboard users.","triggerScenarios":"A JSX opening element with a literal `tabIndex` prop whose parsed numeric value is greater than zero — either a JSX expression container with a positive numeric literal or a string literal like \"3\".","commonSituations":"Developers trying to force a specific tab order across a page; legacy forms where fields were tab-ordered manually with 1,2,3...; templates copied from old HTML tutorials; last-minute 'fix the focus order' patches that use positive indexes.","solutions":["Change the value to `0` (joins natural tab order at that DOM position) or `-1` (removable from tab order, focus programmatically).","Reorder the DOM/source so the natural tab order is correct instead of forcing it with indexes.","Sweep the page for other positive tabIndex values — one positive index changes ordering for the whole document."],"exampleFix":"// before\n<input tabIndex={1} ... />\n<input tabIndex={2} ... />\n\n// after\n<input ... />\n<input ... />","handlingStrategy":"validation","validationCode":"npx oxlint --jsx-a11y/tabindex-no-positive src/","typeGuard":"const isSafeTabIndex = (v: number | string | undefined) =>\n  v === undefined || Number(v) <= 0;","tryCatchPattern":null,"preventionTips":["Only ever use tabIndex 0 or -1 in app code.","Fix focus order by reordering DOM, never with positive indexes.","Grep for tabIndex={[1-9] before releases; one positive index disrupts the whole page order."],"tags":["jsx-a11y","react","accessibility","tabindex","keyboard-navigation","lint"],"backgroundTag":"positive-tabindex","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"}