Skip to content

Commit 4274d57

Browse files
committed
Add support for 'standard' input
Also other cleanup.
1 parent 5ad51b6 commit 4274d57

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

manifest.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ inputs:
1111
required: false
1212
- name: runners
1313
default: ['axe']
14+
- name: standard
15+
default: 'WCAG2AA'
1416
- name: testMode
1517
default: false

netlify.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
# # optional config
1313
failWithIssues = false # true by default
1414

15+
standard = 'WCAG2A'
1516
# # Developer only
1617
# debugMode = true # extra logging for plugin developers

plugin/config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const HTMLCS = 'htmlcs';
33
const INSTALLED_RUNNERS = [AXE, HTMLCS];
44

55
const DEFAULT_RUNNERS = [AXE];
6+
const DEFAULT_STANDARD = 'WCAG2AA';
67
const DEFAULT_CHECK_PATHS = ['/'];
78
const DEFAULT_FAIL_WITH_ISSUES = true;
89
const DEFAULT_IGNORE_DIRECTORIES = [];
@@ -15,7 +16,7 @@ const isInvalidRunner = runners => (
1516

1617
const getConfiguration = ({
1718
constants: { PUBLISH_DIR },
18-
inputs: { checkPaths, debugMode, ignoreDirectories, failWithIssues, runners }
19+
inputs: { checkPaths, debugMode, ignoreDirectories, failWithIssues, runners, standard }
1920
}) => {
2021

2122
runners = runners || DEFAULT_RUNNERS;
@@ -32,6 +33,7 @@ const getConfiguration = ({
3233
pa11yOpts: {
3334
runners,
3435
userAgent: PA11Y_USER_AGENT,
36+
standard: standard || DEFAULT_STANDARD,
3537
}
3638
}
3739
}

plugin/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ module.exports = {
2626
console.log({ htmlFilePaths });
2727
}
2828

29-
const { results, issueCount } = await pluginCore.runPa11y({
29+
const { report, issueCount } = await pluginCore.runPa11y({
3030
build,
3131
debugMode,
3232
htmlFilePaths,
3333
pa11yOpts,
3434
});
3535
if (issueCount > 0) {
3636
const postRunMsg = `Pa11y found ${issueCount} accessibility issues with your site! Check the logs above for more information.`
37-
console.log(results);
37+
console.log(report);
3838
if (failWithIssues) {
3939
build.failBuild(postRunMsg)
4040
} else {

plugin/pluginCore.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const { isDirectory, isFile } = require('path-type')
44
const { results: cliReporter } = require('pa11y/lib/reporters/cli');
55
const readdirp = require('readdirp')
66

7-
exports.runPa11y = async function ({ htmlFilePaths, pa11yOpts = {}, build }) {
7+
exports.runPa11y = async function ({ htmlFilePaths, pa11yOpts, build }) {
88
let issueCount = 0;
99
const results = await Promise.all(htmlFilePaths.map(async path => {
1010
try {
@@ -20,14 +20,14 @@ exports.runPa11y = async function ({ htmlFilePaths, pa11yOpts = {}, build }) {
2020

2121
return {
2222
issueCount,
23-
results: results.filter(Boolean)
23+
report: results.filter(Boolean)
2424
.join(''),
2525
};
2626
};
2727

2828
exports.generateFilePaths = async function({
2929
fileAndDirPaths, // array, mix of html and directories
30-
ignoreDirectories = [],
30+
ignoreDirectories,
3131
absolutePublishDir,
3232
testMode,
3333
debugMode

0 commit comments

Comments
 (0)