Skip to content

linter: Oxlint should not discourage explicit list semantics in no-redundant-roles #22792

Description

@mariusschulz

What version of Oxlint are you using?

1.67.0

What command did you run?

No response

What does your .oxlintrc.json (or oxlint.config.ts) config file look like?

{
  "plugins": [
    "jsx-a11y"
  ],
  "categories": {
    "correctness": "error"
  },
  "rules": {}
}

What happened?

Oxlint should not discourage setting an explicit role="list" on a <ul> or <ol>. When list-style: none is set, Safari removes list semantics which can be undesired from an accessibility perspective.

<style>
  ul, ol {
    list-style: none;
  }
</style>
function Component() {
  return (
    <ul role="list">
      <li role="listitem">Test</li>
    </ul>
  );
}

The no-redundant-roles rule started highlighting this in Oxlint v1.64.0 (see #22069):

× [jsx-a11y(no-redundant-roles)](https://oxc.rs/docs/guide/usage/linter/rules/jsx_a11y/no-redundant-roles.html): The `ul` element has an implicit role of `list`. Defining this explicitly is redundant and should be avoided.
   ╭─[index.tsx:3:9]
 2 │   return (
 3 │     <ul role="list">
   ·         ───────────
 4 │       <li role="listitem">Test</li>
   ╰────
  help: Remove the redundant role `list` from the element `ul`.

  × [jsx-a11y(no-redundant-roles)](https://oxc.rs/docs/guide/usage/linter/rules/jsx_a11y/no-redundant-roles.html): The `li` element has an implicit role of `listitem`. Defining this explicitly is redundant and should be avoided.
   ╭─[index.tsx:4:11]
 3 │     <ul role="list">
 4 │       <li role="listitem">Test</li>
   ·           ───────────────
 5 │     </ul>
   ╰────
  help: Remove the redundant role `listitem` from the element `li`.

I would recommend that we special-case list roles in the no-redundant-roles rule so that the rule won't produce lint warnings/errors for these explicit accessibility fixes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions