Skip to content

no-redundant-roles does not detect nullish attributes #1321

Open
@ouuan

Description

@ouuan

For example, I have an <a> tag that is sometimes disabled:

<a
  :href="disabled ? undefined : 'https://example.com'"
  :aria-disabled="disabled"
  role="link"
>
  maybe disabled
</a>

The w3c specification requires a role="link" when it the link is disabled: https://www.w3.org/TR/html-aria/#example-communicate-a-disabled-link-with-aria

But now this plugin does not know that the href is sometimes not set and reports an error for no-redundant-roles.

I'm not familiar with ESLint plugin development, but I'm wondering if this can be fixed by using type information and checking whether the attribute type can be nullish. Alternatively, maybe there can be an option to treat all v-bind attributes as possibly not satisfying the aria constraint, which does not rely on typing information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions