github / eslint-plugin-github

An opinionated collection of ESLint rules used by GitHub.
MIT License
286 stars 51 forks source link

Bug: Don't fallback to checking implicit role if `role` is set #483

Closed khiga8 closed 9 months ago

khiga8 commented 9 months ago

Currently, when role is set to anything other than a literal prop, the rest of the code runs and grabs the implicit role.

As a result, even with something like:

      <div
        id={id}
        role={
          sectionHasHeader && rowIndex.row === 0 ? 'presentation' : 'option'
        }
        aria-label={this.props.ariaLabel}
      >

where we would not expect the a11y-role-supports-props to raise anything, the code might assume that the implicit role is that of a <div> and is generic, and will flag an error.

Instead, when role is explicitly set but is NOT a literal prop, we should return undefined.