Add rule for at least one call to a11y helper #9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey all, thanks for the work on this, nice to see 😍
I was looking into making a custom ESLint rule as a followup to adding some preliminary accessibility auditing so we can ensure each acceptance test file includes at least one audit call and I found your relevant plugin. As it exists, it has some overlap with what I was looking for, but it differs in that we aren’t looking to audit after every page interaction (for now, at least), and
a11y-audit-after-test-helper
wouldn’t quite work anyway because we mostly use page objects in our acceptance tests, which have highly customisable helper names.There’s an undocumented
a11y-audit
rule that looks like an attempt to do something closer to what we would need, but it doesn’t support thesettings
override that would let me specify the custom audit helper wrapper I added to let us centralise our rule overrides, which is imported fromnomad-ui/tests/helpers/a11y-audit
instead of the Ember addon. Also, forthcoming in my accessibility work is adding auditing for integration/component tests, which the existinga11y-audit
rule wouldn’t apply to because of its filename-checking. If you like, I could open another PR to delete thea11y-audit
, as it seems to have been superseded 🤔So this is a prototype new rule that looks for the audit helper import (with name/package override options). I didn’t include autofix because it would have to arbitrarily pick somewhere in the file to make the call, it seems preferable to let the developer insert it where it makes sense. I’ve tested it successfully locally with
--rulesdir [local fork rules directory]
and this addition totests/.eslintrc.js
:This isn’t necessarily a complete PR, it might be that some more test cases would be helpful, for instance, though I didn’t exercise all the import name/package overrides as that seemed well-covered elsewhere. Also, I didn’t love having the
a11yAuditImported
failure, which seemed to overlap too much with theno-globals
rule, but I was near the end of my timebox for this attempt, but if you think it’s inappropriate, I can try to rework things so it’s not needed.One uncertainty is that I put the organisation name as
a11y-tool-sandbox
in the rule file’surl
field despite the others usingjgwhite
; I gather the package was moved from originally belonging to @jgwhite and I see that redirects are working, so for more consistency I could use that as well.Let me know if you think this is something you’d be into including in your plugin and whether there are any changes you’d like to see to make that possible? It would be nice to have it live alongside the existing rules and share base utilities, but if you don’t think it belongs, I can also adapt the helpful utilities and have it instead as an in-repository plugin for Nomad.