FormidableLabs / FormidableLabs/eslint-plugin-react-native-a11y
Error message for `-descriptors` rule is out of sync with accessibility-hint rule setting
- Dominant language
- JavaScript
- Stars
- 306
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
In short - the `has-valid-accessibility-descriptors`'s rule's error message is static text that doesn't take into account the config's settings on whether `accessibilityHint` is actually required with `accessibilityLabel`.
---
We have eslint-plugin-react-native-a11y set up with `has-accessibility-hint` rule disabled on a library of components intended to be shared between web and native projects, because `accessibilityHint` isn't supported in React Native Web, so mandating its use risks misleading devs into thinking an element has full contextual info when actually the hint part is unavailable on Web. Instead, we advise devs to use complete labels that contain full contextual info across platforms.
We recently updated to `3.x` and were surprised to see an error seemingly complaining about missing hints with labels:
> Missing a11y props. Expected one of: accessibilityRole OR BOTH accessibilityLabel + accessibilityHint OR BOTH accessibilityActions + onAccessibilityAction
...however, it turns out that the rule was correctly following our settings: if the element in question was given an `accessibilityLabel` without an `accessibilityHint`, there was no error as per our disabling of the accessibilityHint rule, but if the `accessibilityLabel` prop was removed, then the error misleadingly implied an `accessibilityHint` was also needed.
So the behaviour is fine, but the error message didn't reflect the behaviour of the rule.
### Proposed fix
Replace the `BOTH accessibilityLabel + accessibilityHint` part of the error message here https://github.com/FormidableLabs/eslint-plugin-react-native-a11y/blob/e5b0f979005849ecdab95d1931d763f6c36d93f3/src/rules/has-valid-accessibility-descriptors.js#L18 with just `accessibilityLabel` if the appropriate accessiblityHint rule is not active.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.