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

Feature request: establish syntax to allow users to pass all available config to service through runners #604

Open
calebtr-metro opened this issue Oct 1, 2021 · 3 comments

Comments

@calebtr-metro
Copy link

Currently, pa11y does not appear to pass all configuration options to runners to use with a service.

For example, Axe has configuration options such as "disableOtherRules" and "checks" that do not get passed through the axe runner. I realize I can open a ticket on the axe runner and/or fork it and fix that - but it seems better to have a solution that would work more universally.

One use case to use a custom script, as in #543. I think the solution is good as it clearly distinguishes pa11y config from runner/service config.

My initial use case a user can create a custom rule for axe and run it through pa11y. I didn't get any traction on stack overflow, so apologies if this feature exists and I am just not finding it.

A sample custom rule for axe would be:

{
        rules: [
            {
                id: 'my-cool-rule',
                enabled: true,
                all: ['auto-fail'],
            },
        ],
        checks: [
            {
                id: 'auto-fail',
                metadata: {
                    impact: 'critical',
                    messages: {
                        pass: 'Surprise! This test passed!',
                        fail: 'This test did not pass, sadly.'
                    }
                },
                evaluate: function () {
                    return false;
                }
            }
        ]
    }

Solutions:

Add config objects to the runners property, as in #543. This keeps pa11y and service configs separate.

Alternatively, pa11y could look for a file, axe.config, etc. when passing config to the runner.

We would also need to establish which set of config takes precedence when there is a conflict (ie from my reading, what pa11y calls "rules", axe calls "standards", and axe uses "rules" to mean specific rules that are actually a set of checks).

Runners would have to be updated to actually send the rules on to the services.

Thanks for your time, and again, apologies if there is a way to do this already.

@joeyciechanowicz
Copy link
Member

joeyciechanowicz commented Jan 10, 2022

This would be useful, and would allow users to configure the runners outside of the realm of what pa11y supports.

The two runners we have (HTML_CS and aXe) are both configured a bit differently.

HTML_CS

The only configuration we perform is to enable rules by pushing them on a window object. And then pass a standard at the run call. I'm not aware of any more configuration we can perform on HTML_CS.

aXe

We build the configuration during one function, getAxeOptions(https://github.com/pa11y/pa11y/blob/master/lib/runners/axe.js#L69). Which would mean it would be possible to merge in a runnerConfig object.

Potential approach

IMO we should surface a runnerConfig to the runners, but leave it up to the runner to then do anything with. We would need to name the config after the runner as we pass the same arguments to each runner.

Config would then look like:

{
   "runnerConfig":{
      // must match the name of a runner
      "axe":{
         "rules":[
            {
               "id":"my-cool-rule",
               "enabled":true,
               "all":[
                  "auto-fail"
               ]
            }
         ]
      }
   }
}

And then pass it in as a 3rd optional argument to the runner

runner.run = async (options, pa11y, runnerConfig) => {
};

Regarding the precedence of config options, I think pa11y options should overwrite any extra configuration as that should be the most common path.

@Dikshita25

@calebtr-metro
Copy link
Author

Ah, thanks for looking at this.

What are next steps?

  • update docs in pa11y
  • create a pr in each runner project ?

@joeyciechanowicz
Copy link
Member

Well, al the runners are now part of pa11y in the lib/runners folder. So that's much easier.

So steps (in my mind) would be something like:

  • Add support for a runnerConfig: {axe: {}, htmlcs} section
    • Grab the runners config (if it has one) off the options and pass it as a 3rd argument in the runner.js
  • Tests!
  • Docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants