github / eslint-plugin-github

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

Fix bugs with `getRole` and `getElementType` #461

Closed khiga8 closed 11 months ago

khiga8 commented 11 months ago

We noticed a few unexpected behavior with the latest eslint-plugin-github 4.9.0 release, which all seems to stem from using getPropValue instead of getLiteralPropValue in our methods getElementType and getRole.

getElementType will return a div for the following. It should instead return Box and not try to assess the conditional.

<Box as={isNavigationOpen ? 'div' : 'nav'} />

--

getRole will return a "generic" here. I don't think it should return anything.

<Box role={isNavigationOpen ? 'generic' : 'navigation'} />

--

getRole will return a "role" here. It should retur undefined since this is role is set to a variable.

<Box role={role} />

--

This PR: