Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error message for -descriptors rule is out of sync with accessibility-hint rule setting #139

Open
AlanSl opened this issue Apr 22, 2022 · 0 comments

Comments

@AlanSl
Copy link

AlanSl commented Apr 22, 2022

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

'Missing a11y props. Expected one of: accessibilityRole OR BOTH accessibilityLabel + accessibilityHint OR BOTH accessibilityActions + onAccessibilityAction';
with just accessibilityLabel if the appropriate accessiblityHint rule is not active.

@AlanSl AlanSl changed the title Error for -descriptors rule is out of sync with accessibility-hint rule setting Error message for -descriptors rule is out of sync with accessibility-hint rule setting Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant