The function returns all metadata for each rule, but is it useful or helpful?
My company (Google) uses getRules to add extra/custom tags. This is an important use case for us; however, it's clearly not the intended use of the method (this usage would break if the metadata did not include the mutable array of tags which is attached to the real rule, for example). We also use both getRules and _audit.rules in unit tests which validate that test infra (direct access of _audit.rules should suffice for that case).
I would say it's useful and helpful for us to be able to easily patch rules (tags in this case), but given how we use it, I don't have an expectation from the axe project that this keeps working.
Thanks for letting us know. We recently added an axe.utils.getRule function that returns the actual Rule object for a rule (instead of just the metadata). This does include the rules tag array. The goal of the function was to replace the need to access audit._rules, but would it suffice to replace your use-case for getRules?
Also, if I may ask, what's the reason you're adding custom tags to the rules through the rule itself rather than using axe.configure?
Yes, getRule suffices for this as we know the ids we want to augment and it serves as a presence check. Regarding not using axe.configure on its own for this, the axe version in our repo falls behind the version of axe which this library supports (we use a monorepo and upgrading the global version of axe can take awhile). axe.configure would push a new rule in this case w/ just id and tag (I'm not sure what the consequences of that would be w/o trying as this particular use was done back in axe v2 days).
getRules is used by axe CLI for generating custom rule sets @jeeyyy
Can you point me to where? I searched but can't find it being used other than in test dirs or copies of axe-core (I checked both repos). The react one can be refactored to not need to use getRules.