github / eslint-plugin-github

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

Use `getLiteralPropValue` for sr-only class #466

Closed khiga8 closed 11 months ago

khiga8 commented 11 months ago

We caught a scenario where a11y-no-visually-hidden-interactive-element throws an error.

Example code:

<Foo className={({isOn}) => { return isOn || isOnProps ? `${className} selected`.trim() : className ?? ''}}/>

We call getPropValue(getProp(node.openingElement.attributes, 'className')). In this scenario, this function call returns a function. This results in the classes.includes call throwing an error.

This PR updates the logic to use getLiteralPropValueand moves around the logic.