diff --git a/.eslintrc b/.eslintrc index 53b03e14b4..a11b5d7b69 100644 --- a/.eslintrc +++ b/.eslintrc @@ -74,16 +74,11 @@ "overrides": [ { "files": [ - "lib/commons/aria/*.js", - "lib/commons/color/*.js", - "lib/commons/dom/*.js", - "lib/commons/forms/*.js", - "lib/commons/matches/*.js", - "lib/commons/table/*.js", - "lib/commons/text/*.js", - "lib/commons/utils/*.js", "lib/core/base/*/*.js", - "lib/core/base/*.js" + "lib/core/base/*.js", + "lib/core/reporters/**/*.js", + "lib/core/utils/*.js", + "lib/commons/**/*.js" ], "parserOptions":{ "sourceType": "module" diff --git a/Gruntfile.js b/Gruntfile.js index 0b40512e33..7d015c3a52 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,13 +5,13 @@ camelcase: ["error", {"properties": "never"}] */ var testConfig = require('./build/test/config'); -function createWebpackConfig(input, output) { +function createWebpackConfig(input, output, outputFilename = 'index.js') { return { devtool: false, mode: 'development', entry: path.resolve(__dirname, input), output: { - filename: 'index.js', + filename: outputFilename, path: path.resolve(__dirname, output) } }; @@ -98,7 +98,12 @@ module.exports = function(grunt) { { expand: true, cwd: 'lib/core', - src: ['**/*.js', '!imports/index.js'], + src: [ + '**/*.js', + '!reporters/**/*.js', + '!utils/**/*.js', + '!imports/index.js' + ], dest: 'tmp/core' } ] @@ -108,7 +113,7 @@ module.exports = function(grunt) { { expand: true, cwd: 'tmp', - src: ['*.js'], + src: ['*.js', 'core/reporters/reporters.js', 'core/utils/utils.js'], dest: 'tmp' } ] @@ -129,6 +134,7 @@ module.exports = function(grunt) { }, coreFiles: [ 'tmp/core/index.js', + 'tmp/core/constants.js', 'tmp/core/*/index.js', 'tmp/core/**/index.js', 'tmp/core/**/*.js' @@ -149,22 +155,9 @@ module.exports = function(grunt) { commons: { src: [ 'lib/commons/intro.stub', - 'lib/commons/index.js', - 'lib/commons/*/index.js', - 'lib/commons/**/*.js', - - // directories we've converted to ES Modules - '!lib/commons/aria/*.js', - '!lib/commons/color/*.js', - '!lib/commons/dom/*.js', - '!lib/commons/forms/*.js', - '!lib/commons/matches/*.js', - '!lib/commons/table/*.js', - '!lib/commons/text/*.js', - '!lib/commons/utils/*.js', // output of webpack directories - 'tmp/commons/**/*.js', + 'tmp/commons/index.js', 'lib/commons/outro.stub' ], @@ -172,38 +165,19 @@ module.exports = function(grunt) { } }, webpack: { - commonsUtils: createWebpackConfig( - 'lib/commons/utils/index.js', - 'tmp/commons/utils' - ), - commonsAria: createWebpackConfig( - 'lib/commons/aria/index.js', - 'tmp/commons/aria' - ), - commonsColor: createWebpackConfig( - 'lib/commons/color/index.js', - 'tmp/commons/color' - ), - commonsDOM: createWebpackConfig( - 'lib/commons/dom/index.js', - 'tmp/commons/dom' - ), - commonsForms: createWebpackConfig( - 'lib/commons/forms/index.js', - 'tmp/commons/forms' - ), - commonsMatches: createWebpackConfig( - 'lib/commons/matches/index.js', - 'tmp/commons/matches' + coreReporters: createWebpackConfig( + 'lib/core/reporters/reporters.js', + 'tmp/core/reporters', + // Due to how the Babel/concat stuff works, this cannot be called `index.js`. + 'reporters.js' ), - commonsTable: createWebpackConfig( - 'lib/commons/table/index.js', - 'tmp/commons/table' + coreUtils: createWebpackConfig( + 'lib/core/utils/utils.js', + 'tmp/core/utils', + // Due to how the Babel/concat stuff works, this cannot be called `index.js`. + 'utils.js' ), - commonsText: createWebpackConfig( - 'lib/commons/text/index.js', - 'tmp/commons/text' - ) + commons: createWebpackConfig('lib/commons/index.js', 'tmp/commons') }, 'aria-supported': { data: { diff --git a/lib/checks/aria/abstractrole.js b/lib/checks/aria/abstractrole-evaluate.js similarity index 100% rename from lib/checks/aria/abstractrole.js rename to lib/checks/aria/abstractrole-evaluate.js diff --git a/lib/checks/aria/abstractrole.json b/lib/checks/aria/abstractrole.json index 9030d21b7a..6c25bbbfab 100644 --- a/lib/checks/aria/abstractrole.json +++ b/lib/checks/aria/abstractrole.json @@ -1,6 +1,6 @@ { "id": "abstractrole", - "evaluate": "abstractrole.js", + "evaluate": "abstractrole-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/aria/allowed-attr.js b/lib/checks/aria/aria-allowed-attr-evaluate.js similarity index 100% rename from lib/checks/aria/allowed-attr.js rename to lib/checks/aria/aria-allowed-attr-evaluate.js diff --git a/lib/checks/aria/allowed-attr.json b/lib/checks/aria/aria-allowed-attr.json similarity index 87% rename from lib/checks/aria/allowed-attr.json rename to lib/checks/aria/aria-allowed-attr.json index 7311b3e2cb..ae40da81a5 100644 --- a/lib/checks/aria/allowed-attr.json +++ b/lib/checks/aria/aria-allowed-attr.json @@ -1,6 +1,6 @@ { "id": "aria-allowed-attr", - "evaluate": "allowed-attr.js", + "evaluate": "aria-allowed-attr-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/aria/aria-allowed-role.js b/lib/checks/aria/aria-allowed-role-evaluate.js similarity index 100% rename from lib/checks/aria/aria-allowed-role.js rename to lib/checks/aria/aria-allowed-role-evaluate.js diff --git a/lib/checks/aria/aria-allowed-role.json b/lib/checks/aria/aria-allowed-role.json index 83415c420b..b35e65836a 100644 --- a/lib/checks/aria/aria-allowed-role.json +++ b/lib/checks/aria/aria-allowed-role.json @@ -1,6 +1,6 @@ { "id": "aria-allowed-role", - "evaluate": "aria-allowed-role.js", + "evaluate": "aria-allowed-role-evaluate.js", "options": { "allowImplicit": true, "ignoredTags": [] diff --git a/lib/checks/aria/errormessage.js b/lib/checks/aria/aria-errormessage-evaluate.js similarity index 100% rename from lib/checks/aria/errormessage.js rename to lib/checks/aria/aria-errormessage-evaluate.js diff --git a/lib/checks/aria/errormessage.json b/lib/checks/aria/aria-errormessage.json similarity index 91% rename from lib/checks/aria/errormessage.json rename to lib/checks/aria/aria-errormessage.json index f334ef8ff3..858c7cfdb0 100644 --- a/lib/checks/aria/errormessage.json +++ b/lib/checks/aria/aria-errormessage.json @@ -1,6 +1,6 @@ { "id": "aria-errormessage", - "evaluate": "errormessage.js", + "evaluate": "aria-errormessage-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/aria/aria-hidden-body.js b/lib/checks/aria/aria-hidden-body-evaluate.js similarity index 100% rename from lib/checks/aria/aria-hidden-body.js rename to lib/checks/aria/aria-hidden-body-evaluate.js diff --git a/lib/checks/aria/aria-hidden-body.json b/lib/checks/aria/aria-hidden-body.json index 09a2cebc11..a121818554 100644 --- a/lib/checks/aria/aria-hidden-body.json +++ b/lib/checks/aria/aria-hidden-body.json @@ -1,6 +1,6 @@ { "id": "aria-hidden-body", - "evaluate": "aria-hidden-body.js", + "evaluate": "aria-hidden-body-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/aria/required-attr.js b/lib/checks/aria/aria-required-attr-evaluate.js similarity index 100% rename from lib/checks/aria/required-attr.js rename to lib/checks/aria/aria-required-attr-evaluate.js diff --git a/lib/checks/aria/required-attr.json b/lib/checks/aria/aria-required-attr.json similarity index 86% rename from lib/checks/aria/required-attr.json rename to lib/checks/aria/aria-required-attr.json index f825c317f3..589a600736 100644 --- a/lib/checks/aria/required-attr.json +++ b/lib/checks/aria/aria-required-attr.json @@ -1,6 +1,6 @@ { "id": "aria-required-attr", - "evaluate": "required-attr.js", + "evaluate": "aria-required-attr-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/aria/required-children.js b/lib/checks/aria/aria-required-children-evaluate.js similarity index 100% rename from lib/checks/aria/required-children.js rename to lib/checks/aria/aria-required-children-evaluate.js diff --git a/lib/checks/aria/required-children.json b/lib/checks/aria/aria-required-children.json similarity index 92% rename from lib/checks/aria/required-children.json rename to lib/checks/aria/aria-required-children.json index 9dae8cb625..4284fb8215 100644 --- a/lib/checks/aria/required-children.json +++ b/lib/checks/aria/aria-required-children.json @@ -1,6 +1,6 @@ { "id": "aria-required-children", - "evaluate": "required-children.js", + "evaluate": "aria-required-children-evaluate.js", "options": { "reviewEmpty": [ "doc-bibliography", diff --git a/lib/checks/aria/required-parent.js b/lib/checks/aria/aria-required-parent-evaluate.js similarity index 100% rename from lib/checks/aria/required-parent.js rename to lib/checks/aria/aria-required-parent-evaluate.js diff --git a/lib/checks/aria/required-parent.json b/lib/checks/aria/aria-required-parent.json similarity index 86% rename from lib/checks/aria/required-parent.json rename to lib/checks/aria/aria-required-parent.json index 53a6010a9d..8cdfb1332d 100644 --- a/lib/checks/aria/required-parent.json +++ b/lib/checks/aria/aria-required-parent.json @@ -1,6 +1,6 @@ { "id": "aria-required-parent", - "evaluate": "required-parent.js", + "evaluate": "aria-required-parent-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/aria/aria-roledescription.js b/lib/checks/aria/aria-roledescription-evaluate.js similarity index 100% rename from lib/checks/aria/aria-roledescription.js rename to lib/checks/aria/aria-roledescription-evaluate.js diff --git a/lib/checks/aria/aria-roledescription.json b/lib/checks/aria/aria-roledescription.json index d86395dcfc..ff31053044 100644 --- a/lib/checks/aria/aria-roledescription.json +++ b/lib/checks/aria/aria-roledescription.json @@ -1,6 +1,6 @@ { "id": "aria-roledescription", - "evaluate": "aria-roledescription.js", + "evaluate": "aria-roledescription-evaluate.js", "options": { "supportedRoles": [ "button", diff --git a/lib/checks/aria/unsupportedattr.js b/lib/checks/aria/aria-unsupported-attr-evaluate.js similarity index 100% rename from lib/checks/aria/unsupportedattr.js rename to lib/checks/aria/aria-unsupported-attr-evaluate.js diff --git a/lib/checks/aria/unsupportedattr.json b/lib/checks/aria/aria-unsupported-attr.json similarity index 83% rename from lib/checks/aria/unsupportedattr.json rename to lib/checks/aria/aria-unsupported-attr.json index e55f6ee974..05f39b4607 100644 --- a/lib/checks/aria/unsupportedattr.json +++ b/lib/checks/aria/aria-unsupported-attr.json @@ -1,6 +1,6 @@ { "id": "aria-unsupported-attr", - "evaluate": "unsupportedattr.js", + "evaluate": "aria-unsupported-attr-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/aria/valid-attr.js b/lib/checks/aria/aria-valid-attr-evaluate.js similarity index 100% rename from lib/checks/aria/valid-attr.js rename to lib/checks/aria/aria-valid-attr-evaluate.js diff --git a/lib/checks/aria/valid-attr-value.js b/lib/checks/aria/aria-valid-attr-value-evaluate.js similarity index 100% rename from lib/checks/aria/valid-attr-value.js rename to lib/checks/aria/aria-valid-attr-value-evaluate.js diff --git a/lib/checks/aria/valid-attr-value.json b/lib/checks/aria/aria-valid-attr-value.json similarity index 91% rename from lib/checks/aria/valid-attr-value.json rename to lib/checks/aria/aria-valid-attr-value.json index 746d9e3b8d..fcb62e7b18 100644 --- a/lib/checks/aria/valid-attr-value.json +++ b/lib/checks/aria/aria-valid-attr-value.json @@ -1,6 +1,6 @@ { "id": "aria-valid-attr-value", - "evaluate": "valid-attr-value.js", + "evaluate": "aria-valid-attr-value-evaluate.js", "options": [], "metadata": { "impact": "critical", diff --git a/lib/checks/aria/valid-attr.json b/lib/checks/aria/aria-valid-attr.json similarity index 86% rename from lib/checks/aria/valid-attr.json rename to lib/checks/aria/aria-valid-attr.json index 1d1a582352..221f39dfc9 100644 --- a/lib/checks/aria/valid-attr.json +++ b/lib/checks/aria/aria-valid-attr.json @@ -1,6 +1,6 @@ { "id": "aria-valid-attr", - "evaluate": "valid-attr.js", + "evaluate": "aria-valid-attr-evaluate.js", "options": [], "metadata": { "impact": "critical", diff --git a/lib/checks/aria/fallbackrole.js b/lib/checks/aria/fallbackrole-evaluate.js similarity index 100% rename from lib/checks/aria/fallbackrole.js rename to lib/checks/aria/fallbackrole-evaluate.js diff --git a/lib/checks/aria/fallbackrole.json b/lib/checks/aria/fallbackrole.json index f30109955f..91deef7239 100644 --- a/lib/checks/aria/fallbackrole.json +++ b/lib/checks/aria/fallbackrole.json @@ -1,6 +1,6 @@ { "id": "fallbackrole", - "evaluate": "fallbackrole.js", + "evaluate": "fallbackrole-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/aria/has-widget-role.js b/lib/checks/aria/has-widget-role-evaluate.js similarity index 100% rename from lib/checks/aria/has-widget-role.js rename to lib/checks/aria/has-widget-role-evaluate.js diff --git a/lib/checks/aria/has-widget-role.json b/lib/checks/aria/has-widget-role.json index 448c42f1c8..1392802b8c 100644 --- a/lib/checks/aria/has-widget-role.json +++ b/lib/checks/aria/has-widget-role.json @@ -1,6 +1,6 @@ { "id": "has-widget-role", - "evaluate": "has-widget-role.js", + "evaluate": "has-widget-role-evaluate.js", "options": [], "metadata": { "impact": "minor", diff --git a/lib/checks/aria/implicit-role-fallback.js b/lib/checks/aria/implicit-role-fallback-evaluate.js similarity index 100% rename from lib/checks/aria/implicit-role-fallback.js rename to lib/checks/aria/implicit-role-fallback-evaluate.js diff --git a/lib/checks/aria/implicit-role-fallback.json b/lib/checks/aria/implicit-role-fallback.json index 0834dc9259..eda61145b9 100644 --- a/lib/checks/aria/implicit-role-fallback.json +++ b/lib/checks/aria/implicit-role-fallback.json @@ -1,6 +1,6 @@ { "id": "implicit-role-fallback", - "evaluate": "implicit-role-fallback.js", + "evaluate": "implicit-role-fallback-evaluate.js", "deprecated": true, "metadata": { "impact": "moderate", diff --git a/lib/checks/aria/invalidrole.js b/lib/checks/aria/invalidrole-evaluate.js similarity index 100% rename from lib/checks/aria/invalidrole.js rename to lib/checks/aria/invalidrole-evaluate.js diff --git a/lib/checks/aria/invalidrole.json b/lib/checks/aria/invalidrole.json index 4cf26216cd..51a1593052 100644 --- a/lib/checks/aria/invalidrole.json +++ b/lib/checks/aria/invalidrole.json @@ -1,6 +1,6 @@ { "id": "invalidrole", - "evaluate": "invalidrole.js", + "evaluate": "invalidrole-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/aria/no-implicit-explicit-label.js b/lib/checks/aria/no-implicit-explicit-label-evaluate.js similarity index 100% rename from lib/checks/aria/no-implicit-explicit-label.js rename to lib/checks/aria/no-implicit-explicit-label-evaluate.js diff --git a/lib/checks/aria/no-implicit-explicit-label.json b/lib/checks/aria/no-implicit-explicit-label.json index 3a277ca42e..234259a064 100644 --- a/lib/checks/aria/no-implicit-explicit-label.json +++ b/lib/checks/aria/no-implicit-explicit-label.json @@ -1,6 +1,6 @@ { "id": "no-implicit-explicit-label", - "evaluate": "no-implicit-explicit-label.js", + "evaluate": "no-implicit-explicit-label-evaluate.js", "metadata": { "impact": "moderate", "messages": { diff --git a/lib/checks/aria/unsupportedrole.js b/lib/checks/aria/unsupportedrole-evaluate.js similarity index 100% rename from lib/checks/aria/unsupportedrole.js rename to lib/checks/aria/unsupportedrole-evaluate.js diff --git a/lib/checks/aria/unsupportedrole.json b/lib/checks/aria/unsupportedrole.json index e109a6e65b..a3b156dedd 100644 --- a/lib/checks/aria/unsupportedrole.json +++ b/lib/checks/aria/unsupportedrole.json @@ -1,6 +1,6 @@ { "id": "unsupportedrole", - "evaluate": "unsupportedrole.js", + "evaluate": "unsupportedrole-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/aria/valid-scrollable-semantics.js b/lib/checks/aria/valid-scrollable-semantics-evaluate.js similarity index 100% rename from lib/checks/aria/valid-scrollable-semantics.js rename to lib/checks/aria/valid-scrollable-semantics-evaluate.js diff --git a/lib/checks/aria/valid-scrollable-semantics.json b/lib/checks/aria/valid-scrollable-semantics.json index 9784e2d966..b4e85bfa41 100644 --- a/lib/checks/aria/valid-scrollable-semantics.json +++ b/lib/checks/aria/valid-scrollable-semantics.json @@ -1,6 +1,6 @@ { "id": "valid-scrollable-semantics", - "evaluate": "valid-scrollable-semantics.js", + "evaluate": "valid-scrollable-semantics-evaluate.js", "options": [], "metadata": { "impact": "minor", diff --git a/lib/checks/color/color-contrast.js b/lib/checks/color/color-contrast-evaluate.js similarity index 100% rename from lib/checks/color/color-contrast.js rename to lib/checks/color/color-contrast-evaluate.js diff --git a/lib/checks/color/color-contrast.json b/lib/checks/color/color-contrast.json index 39f32c90e6..f2a8a7ee55 100644 --- a/lib/checks/color/color-contrast.json +++ b/lib/checks/color/color-contrast.json @@ -1,6 +1,6 @@ { "id": "color-contrast", - "evaluate": "color-contrast.js", + "evaluate": "color-contrast-evaluate.js", "options": { "noScroll": false, "ignoreUnicode": true, diff --git a/lib/checks/color/link-in-text-block.js b/lib/checks/color/link-in-text-block-evaluate.js similarity index 100% rename from lib/checks/color/link-in-text-block.js rename to lib/checks/color/link-in-text-block-evaluate.js diff --git a/lib/checks/color/link-in-text-block.json b/lib/checks/color/link-in-text-block.json index 7aa1433654..7808844d00 100644 --- a/lib/checks/color/link-in-text-block.json +++ b/lib/checks/color/link-in-text-block.json @@ -1,6 +1,6 @@ { "id": "link-in-text-block", - "evaluate": "link-in-text-block.js", + "evaluate": "link-in-text-block-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/forms/autocomplete-appropriate.js b/lib/checks/forms/autocomplete-appropriate-evaluate.js similarity index 100% rename from lib/checks/forms/autocomplete-appropriate.js rename to lib/checks/forms/autocomplete-appropriate-evaluate.js diff --git a/lib/checks/forms/autocomplete-appropriate.json b/lib/checks/forms/autocomplete-appropriate.json index 1ea1dffa79..2b9fef44c0 100644 --- a/lib/checks/forms/autocomplete-appropriate.json +++ b/lib/checks/forms/autocomplete-appropriate.json @@ -1,6 +1,6 @@ { "id": "autocomplete-appropriate", - "evaluate": "autocomplete-appropriate.js", + "evaluate": "autocomplete-appropriate-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/forms/autocomplete-valid.js b/lib/checks/forms/autocomplete-valid-evaluate.js similarity index 100% rename from lib/checks/forms/autocomplete-valid.js rename to lib/checks/forms/autocomplete-valid-evaluate.js diff --git a/lib/checks/forms/autocomplete-valid.json b/lib/checks/forms/autocomplete-valid.json index 32208184d7..95ad06ffc4 100644 --- a/lib/checks/forms/autocomplete-valid.json +++ b/lib/checks/forms/autocomplete-valid.json @@ -1,6 +1,6 @@ { "id": "autocomplete-valid", - "evaluate": "autocomplete-valid.js", + "evaluate": "autocomplete-valid-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/forms/fieldset.js b/lib/checks/forms/fieldset-evaluate.js similarity index 100% rename from lib/checks/forms/fieldset.js rename to lib/checks/forms/fieldset-evaluate.js diff --git a/lib/checks/forms/fieldset.json b/lib/checks/forms/fieldset.json index 8e40aa2ed8..4c98dd1032 100644 --- a/lib/checks/forms/fieldset.json +++ b/lib/checks/forms/fieldset.json @@ -1,6 +1,6 @@ { "id": "fieldset", - "evaluate": "fieldset.js", + "evaluate": "fieldset-evaluate.js", "after": "fieldset-after.js", "deprecated": true, "metadata": { diff --git a/lib/checks/forms/group-labelledby.js b/lib/checks/forms/group-labelledby-evaluate.js similarity index 100% rename from lib/checks/forms/group-labelledby.js rename to lib/checks/forms/group-labelledby-evaluate.js diff --git a/lib/checks/forms/group-labelledby.json b/lib/checks/forms/group-labelledby.json index d13892c382..56ae65eb7a 100644 --- a/lib/checks/forms/group-labelledby.json +++ b/lib/checks/forms/group-labelledby.json @@ -1,6 +1,6 @@ { "id": "group-labelledby", - "evaluate": "group-labelledby.js", + "evaluate": "group-labelledby-evaluate.js", "after": "group-labelledby-after.js", "deprecated": true, "metadata": { diff --git a/lib/checks/keyboard/accesskeys.js b/lib/checks/keyboard/accesskeys-evaluate.js similarity index 100% rename from lib/checks/keyboard/accesskeys.js rename to lib/checks/keyboard/accesskeys-evaluate.js diff --git a/lib/checks/keyboard/accesskeys.json b/lib/checks/keyboard/accesskeys.json index 518699f5e3..851affea5b 100644 --- a/lib/checks/keyboard/accesskeys.json +++ b/lib/checks/keyboard/accesskeys.json @@ -1,6 +1,6 @@ { "id": "accesskeys", - "evaluate": "accesskeys.js", + "evaluate": "accesskeys-evaluate.js", "after": "accesskeys-after.js", "metadata": { "impact": "serious", diff --git a/lib/checks/keyboard/focusable-content.js b/lib/checks/keyboard/focusable-content-evaluate.js similarity index 100% rename from lib/checks/keyboard/focusable-content.js rename to lib/checks/keyboard/focusable-content-evaluate.js diff --git a/lib/checks/keyboard/focusable-content.json b/lib/checks/keyboard/focusable-content.json index 7998b4ba3d..08dddbae73 100644 --- a/lib/checks/keyboard/focusable-content.json +++ b/lib/checks/keyboard/focusable-content.json @@ -1,6 +1,6 @@ { "id": "focusable-content", - "evaluate": "focusable-content.js", + "evaluate": "focusable-content-evaluate.js", "metadata": { "impact": "moderate", "messages": { diff --git a/lib/checks/keyboard/focusable-disabled.js b/lib/checks/keyboard/focusable-disabled-evaluate.js similarity index 100% rename from lib/checks/keyboard/focusable-disabled.js rename to lib/checks/keyboard/focusable-disabled-evaluate.js diff --git a/lib/checks/keyboard/focusable-disabled.json b/lib/checks/keyboard/focusable-disabled.json index 3011c39902..12b47650a9 100644 --- a/lib/checks/keyboard/focusable-disabled.json +++ b/lib/checks/keyboard/focusable-disabled.json @@ -1,6 +1,6 @@ { "id": "focusable-disabled", - "evaluate": "focusable-disabled.js", + "evaluate": "focusable-disabled-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/keyboard/focusable-element.js b/lib/checks/keyboard/focusable-element-evaluate.js similarity index 100% rename from lib/checks/keyboard/focusable-element.js rename to lib/checks/keyboard/focusable-element-evaluate.js diff --git a/lib/checks/keyboard/focusable-element.json b/lib/checks/keyboard/focusable-element.json index 64a23b37e7..e78873261b 100644 --- a/lib/checks/keyboard/focusable-element.json +++ b/lib/checks/keyboard/focusable-element.json @@ -1,6 +1,6 @@ { "id": "focusable-element", - "evaluate": "focusable-element.js", + "evaluate": "focusable-element-evaluate.js", "metadata": { "impact": "moderate", "messages": { diff --git a/lib/checks/keyboard/focusable-modal-open.js b/lib/checks/keyboard/focusable-modal-open-evaluate.js similarity index 100% rename from lib/checks/keyboard/focusable-modal-open.js rename to lib/checks/keyboard/focusable-modal-open-evaluate.js diff --git a/lib/checks/keyboard/focusable-modal-open.json b/lib/checks/keyboard/focusable-modal-open.json index 3ba9530893..b1d00e99e4 100644 --- a/lib/checks/keyboard/focusable-modal-open.json +++ b/lib/checks/keyboard/focusable-modal-open.json @@ -1,6 +1,6 @@ { "id": "focusable-modal-open", - "evaluate": "focusable-modal-open.js", + "evaluate": "focusable-modal-open-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/keyboard/focusable-no-name.js b/lib/checks/keyboard/focusable-no-name-evaluate.js similarity index 100% rename from lib/checks/keyboard/focusable-no-name.js rename to lib/checks/keyboard/focusable-no-name-evaluate.js diff --git a/lib/checks/keyboard/focusable-no-name.json b/lib/checks/keyboard/focusable-no-name.json index 44bf06a785..c2e9ac7474 100644 --- a/lib/checks/keyboard/focusable-no-name.json +++ b/lib/checks/keyboard/focusable-no-name.json @@ -1,6 +1,6 @@ { "id": "focusable-no-name", - "evaluate": "focusable-no-name.js", + "evaluate": "focusable-no-name-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/keyboard/focusable-not-tabbable.js b/lib/checks/keyboard/focusable-not-tabbable-evaluate.js similarity index 100% rename from lib/checks/keyboard/focusable-not-tabbable.js rename to lib/checks/keyboard/focusable-not-tabbable-evaluate.js diff --git a/lib/checks/keyboard/focusable-not-tabbable.json b/lib/checks/keyboard/focusable-not-tabbable.json index fea1a07f70..273e031901 100644 --- a/lib/checks/keyboard/focusable-not-tabbable.json +++ b/lib/checks/keyboard/focusable-not-tabbable.json @@ -1,6 +1,6 @@ { "id": "focusable-not-tabbable", - "evaluate": "focusable-not-tabbable.js", + "evaluate": "focusable-not-tabbable-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/keyboard/landmark-is-top-level.js b/lib/checks/keyboard/landmark-is-top-level-evaluate.js similarity index 100% rename from lib/checks/keyboard/landmark-is-top-level.js rename to lib/checks/keyboard/landmark-is-top-level-evaluate.js diff --git a/lib/checks/keyboard/landmark-is-top-level.json b/lib/checks/keyboard/landmark-is-top-level.json index 3169697bf9..2886d67890 100644 --- a/lib/checks/keyboard/landmark-is-top-level.json +++ b/lib/checks/keyboard/landmark-is-top-level.json @@ -1,6 +1,6 @@ { "id": "landmark-is-top-level", - "evaluate": "landmark-is-top-level.js", + "evaluate": "landmark-is-top-level-evaluate.js", "metadata": { "impact": "moderate", "messages": { diff --git a/lib/checks/keyboard/page-has-elm.js b/lib/checks/keyboard/page-has-elm-evaluate.js similarity index 100% rename from lib/checks/keyboard/page-has-elm.js rename to lib/checks/keyboard/page-has-elm-evaluate.js diff --git a/lib/checks/keyboard/page-has-heading-one.json b/lib/checks/keyboard/page-has-heading-one.json index dea8a905eb..d2c8459bb0 100644 --- a/lib/checks/keyboard/page-has-heading-one.json +++ b/lib/checks/keyboard/page-has-heading-one.json @@ -1,6 +1,6 @@ { "id": "page-has-heading-one", - "evaluate": "page-has-elm.js", + "evaluate": "page-has-elm-evaluate.js", "after": "page-has-elm-after.js", "options": { "selector": "h1:not([role]), [role=\"heading\"][aria-level=\"1\"]" diff --git a/lib/checks/keyboard/page-has-main.json b/lib/checks/keyboard/page-has-main.json index b1088fe9fa..e9262ef094 100644 --- a/lib/checks/keyboard/page-has-main.json +++ b/lib/checks/keyboard/page-has-main.json @@ -1,6 +1,6 @@ { "id": "page-has-main", - "evaluate": "page-has-elm.js", + "evaluate": "page-has-elm-evaluate.js", "after": "page-has-elm-after.js", "options": { "selector": "main:not([role]), [role='main']" diff --git a/lib/checks/keyboard/page-no-duplicate-banner.json b/lib/checks/keyboard/page-no-duplicate-banner.json index ee947ff1d8..f3dff42011 100644 --- a/lib/checks/keyboard/page-no-duplicate-banner.json +++ b/lib/checks/keyboard/page-no-duplicate-banner.json @@ -1,6 +1,6 @@ { "id": "page-no-duplicate-banner", - "evaluate": "page-no-duplicate.js", + "evaluate": "page-no-duplicate-evaluate.js", "after": "page-no-duplicate-after.js", "options": { "selector": "header:not([role]), [role=banner]", diff --git a/lib/checks/keyboard/page-no-duplicate-contentinfo.json b/lib/checks/keyboard/page-no-duplicate-contentinfo.json index a18431f03f..155f54acb9 100644 --- a/lib/checks/keyboard/page-no-duplicate-contentinfo.json +++ b/lib/checks/keyboard/page-no-duplicate-contentinfo.json @@ -1,6 +1,6 @@ { "id": "page-no-duplicate-contentinfo", - "evaluate": "page-no-duplicate.js", + "evaluate": "page-no-duplicate-evaluate.js", "after": "page-no-duplicate-after.js", "options": { "selector": "footer:not([role]), [role=contentinfo]", diff --git a/lib/checks/keyboard/page-no-duplicate.js b/lib/checks/keyboard/page-no-duplicate-evaluate.js similarity index 100% rename from lib/checks/keyboard/page-no-duplicate.js rename to lib/checks/keyboard/page-no-duplicate-evaluate.js diff --git a/lib/checks/keyboard/page-no-duplicate-main.json b/lib/checks/keyboard/page-no-duplicate-main.json index 93198f4862..41ad269208 100644 --- a/lib/checks/keyboard/page-no-duplicate-main.json +++ b/lib/checks/keyboard/page-no-duplicate-main.json @@ -1,6 +1,6 @@ { "id": "page-no-duplicate-main", - "evaluate": "page-no-duplicate.js", + "evaluate": "page-no-duplicate-evaluate.js", "after": "page-no-duplicate-after.js", "options": { "selector": "main:not([role]), [role='main']" diff --git a/lib/checks/keyboard/tabindex.js b/lib/checks/keyboard/tabindex-evaluate.js similarity index 100% rename from lib/checks/keyboard/tabindex.js rename to lib/checks/keyboard/tabindex-evaluate.js diff --git a/lib/checks/keyboard/tabindex.json b/lib/checks/keyboard/tabindex.json index 52fadfe4be..ad8d2df531 100644 --- a/lib/checks/keyboard/tabindex.json +++ b/lib/checks/keyboard/tabindex.json @@ -1,6 +1,6 @@ { "id": "tabindex", - "evaluate": "tabindex.js", + "evaluate": "tabindex-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/label/alt-space-value.js b/lib/checks/label/alt-space-value-evaluate.js similarity index 100% rename from lib/checks/label/alt-space-value.js rename to lib/checks/label/alt-space-value-evaluate.js diff --git a/lib/checks/label/alt-space-value.json b/lib/checks/label/alt-space-value.json index 11813fe00b..8683c38dde 100644 --- a/lib/checks/label/alt-space-value.json +++ b/lib/checks/label/alt-space-value.json @@ -1,6 +1,6 @@ { "id": "alt-space-value", - "evaluate": "alt-space-value.js", + "evaluate": "alt-space-value-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/label/duplicate-img-label.js b/lib/checks/label/duplicate-img-label-evaluate.js similarity index 100% rename from lib/checks/label/duplicate-img-label.js rename to lib/checks/label/duplicate-img-label-evaluate.js diff --git a/lib/checks/label/duplicate-img-label.json b/lib/checks/label/duplicate-img-label.json index 8b6cab1033..42d2395ece 100644 --- a/lib/checks/label/duplicate-img-label.json +++ b/lib/checks/label/duplicate-img-label.json @@ -1,6 +1,6 @@ { "id": "duplicate-img-label", - "evaluate": "duplicate-img-label.js", + "evaluate": "duplicate-img-label-evaluate.js", "metadata": { "impact": "minor", "messages": { diff --git a/lib/checks/label/explicit.js b/lib/checks/label/explicit-evaluate.js similarity index 100% rename from lib/checks/label/explicit.js rename to lib/checks/label/explicit-evaluate.js diff --git a/lib/checks/label/explicit.json b/lib/checks/label/explicit.json index 34c623d4c3..cb8fdefbf4 100644 --- a/lib/checks/label/explicit.json +++ b/lib/checks/label/explicit.json @@ -1,6 +1,6 @@ { "id": "explicit-label", - "evaluate": "explicit.js", + "evaluate": "explicit-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/label/help-same-as-label.js b/lib/checks/label/help-same-as-label-evaluate.js similarity index 100% rename from lib/checks/label/help-same-as-label.js rename to lib/checks/label/help-same-as-label-evaluate.js diff --git a/lib/checks/label/help-same-as-label.json b/lib/checks/label/help-same-as-label.json index fc44d829ef..e30091100d 100644 --- a/lib/checks/label/help-same-as-label.json +++ b/lib/checks/label/help-same-as-label.json @@ -1,6 +1,6 @@ { "id": "help-same-as-label", - "evaluate": "help-same-as-label.js", + "evaluate": "help-same-as-label-evaluate.js", "enabled": false, "metadata": { "impact": "minor", diff --git a/lib/checks/label/hidden-explicit-label.js b/lib/checks/label/hidden-explicit-label-evaluate.js similarity index 100% rename from lib/checks/label/hidden-explicit-label.js rename to lib/checks/label/hidden-explicit-label-evaluate.js diff --git a/lib/checks/label/hidden-explicit-label.json b/lib/checks/label/hidden-explicit-label.json index 4c015324c7..5ed59ac660 100644 --- a/lib/checks/label/hidden-explicit-label.json +++ b/lib/checks/label/hidden-explicit-label.json @@ -1,6 +1,6 @@ { "id": "hidden-explicit-label", - "evaluate": "hidden-explicit-label.js", + "evaluate": "hidden-explicit-label-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/label/implicit.js b/lib/checks/label/implicit-evaluate.js similarity index 100% rename from lib/checks/label/implicit.js rename to lib/checks/label/implicit-evaluate.js diff --git a/lib/checks/label/implicit.json b/lib/checks/label/implicit.json index 3154602a9a..79f855bc83 100644 --- a/lib/checks/label/implicit.json +++ b/lib/checks/label/implicit.json @@ -1,6 +1,6 @@ { "id": "implicit-label", - "evaluate": "implicit.js", + "evaluate": "implicit-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/label/label-content-name-mismatch.js b/lib/checks/label/label-content-name-mismatch-evaluate.js similarity index 100% rename from lib/checks/label/label-content-name-mismatch.js rename to lib/checks/label/label-content-name-mismatch-evaluate.js diff --git a/lib/checks/label/label-content-name-mismatch.json b/lib/checks/label/label-content-name-mismatch.json index a8da4c1a26..54943e1a03 100644 --- a/lib/checks/label/label-content-name-mismatch.json +++ b/lib/checks/label/label-content-name-mismatch.json @@ -1,6 +1,6 @@ { "id": "label-content-name-mismatch", - "evaluate": "label-content-name-mismatch.js", + "evaluate": "label-content-name-mismatch-evaluate.js", "options": { "pixelThreshold": 0.1, "occuranceThreshold": 3 diff --git a/lib/checks/label/multiple-label.js b/lib/checks/label/multiple-label-evaluate.js similarity index 100% rename from lib/checks/label/multiple-label.js rename to lib/checks/label/multiple-label-evaluate.js diff --git a/lib/checks/label/multiple-label.json b/lib/checks/label/multiple-label.json index c72706a22a..df5b3b4b07 100644 --- a/lib/checks/label/multiple-label.json +++ b/lib/checks/label/multiple-label.json @@ -1,6 +1,6 @@ { "id": "multiple-label", - "evaluate": "multiple-label.js", + "evaluate": "multiple-label-evaluate.js", "metadata": { "impact": "moderate", "messages": { diff --git a/lib/checks/label/title-only.js b/lib/checks/label/title-only-evaluate.js similarity index 100% rename from lib/checks/label/title-only.js rename to lib/checks/label/title-only-evaluate.js diff --git a/lib/checks/label/title-only.json b/lib/checks/label/title-only.json index 9b7ebef384..8cfe835f44 100644 --- a/lib/checks/label/title-only.json +++ b/lib/checks/label/title-only.json @@ -1,6 +1,6 @@ { "id": "title-only", - "evaluate": "title-only.js", + "evaluate": "title-only-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/landmarks/landmark-is-unique.js b/lib/checks/landmarks/landmark-is-unique-evaluate.js similarity index 100% rename from lib/checks/landmarks/landmark-is-unique.js rename to lib/checks/landmarks/landmark-is-unique-evaluate.js diff --git a/lib/checks/landmarks/landmark-is-unique.json b/lib/checks/landmarks/landmark-is-unique.json index 05cf5d2933..56208bfe2c 100644 --- a/lib/checks/landmarks/landmark-is-unique.json +++ b/lib/checks/landmarks/landmark-is-unique.json @@ -1,6 +1,6 @@ { "id": "landmark-is-unique", - "evaluate": "landmark-is-unique.js", + "evaluate": "landmark-is-unique-evaluate.js", "after": "landmark-is-unique-after.js", "metadata": { "impact": "moderate", diff --git a/lib/checks/language/has-lang.js b/lib/checks/language/has-lang-evaluate.js similarity index 100% rename from lib/checks/language/has-lang.js rename to lib/checks/language/has-lang-evaluate.js diff --git a/lib/checks/language/has-lang.json b/lib/checks/language/has-lang.json index 151cfc4d5b..b17ad4dbe9 100644 --- a/lib/checks/language/has-lang.json +++ b/lib/checks/language/has-lang.json @@ -1,6 +1,6 @@ { "id": "has-lang", - "evaluate": "has-lang.js", + "evaluate": "has-lang-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/language/valid-lang.js b/lib/checks/language/valid-lang-evaluate.js similarity index 100% rename from lib/checks/language/valid-lang.js rename to lib/checks/language/valid-lang-evaluate.js diff --git a/lib/checks/language/valid-lang.json b/lib/checks/language/valid-lang.json index 61515f7fda..931b7d31b3 100644 --- a/lib/checks/language/valid-lang.json +++ b/lib/checks/language/valid-lang.json @@ -1,6 +1,6 @@ { "id": "valid-lang", - "evaluate": "valid-lang.js", + "evaluate": "valid-lang-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/language/xml-lang-mismatch.js b/lib/checks/language/xml-lang-mismatch-evaluate.js similarity index 100% rename from lib/checks/language/xml-lang-mismatch.js rename to lib/checks/language/xml-lang-mismatch-evaluate.js diff --git a/lib/checks/language/xml-lang-mismatch.json b/lib/checks/language/xml-lang-mismatch.json index 3b26b8496e..02c3bc6bfa 100644 --- a/lib/checks/language/xml-lang-mismatch.json +++ b/lib/checks/language/xml-lang-mismatch.json @@ -1,6 +1,6 @@ { "id": "xml-lang-mismatch", - "evaluate": "xml-lang-mismatch.js", + "evaluate": "xml-lang-mismatch-evaluate.js", "metadata": { "impact": "moderate", "messages": { diff --git a/lib/checks/lists/dlitem.js b/lib/checks/lists/dlitem-evaluate.js similarity index 100% rename from lib/checks/lists/dlitem.js rename to lib/checks/lists/dlitem-evaluate.js diff --git a/lib/checks/lists/dlitem.json b/lib/checks/lists/dlitem.json index c90f86a203..88a99b63e1 100644 --- a/lib/checks/lists/dlitem.json +++ b/lib/checks/lists/dlitem.json @@ -1,6 +1,6 @@ { "id": "dlitem", - "evaluate": "dlitem.js", + "evaluate": "dlitem-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/lists/listitem.js b/lib/checks/lists/listitem-evaluate.js similarity index 100% rename from lib/checks/lists/listitem.js rename to lib/checks/lists/listitem-evaluate.js diff --git a/lib/checks/lists/listitem.json b/lib/checks/lists/listitem.json index 6588ff336e..a3ed69ff66 100644 --- a/lib/checks/lists/listitem.json +++ b/lib/checks/lists/listitem.json @@ -1,6 +1,6 @@ { "id": "listitem", - "evaluate": "listitem.js", + "evaluate": "listitem-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/lists/only-dlitems.js b/lib/checks/lists/only-dlitems-evaluate.js similarity index 100% rename from lib/checks/lists/only-dlitems.js rename to lib/checks/lists/only-dlitems-evaluate.js diff --git a/lib/checks/lists/only-dlitems.json b/lib/checks/lists/only-dlitems.json index 5ee044d743..525d5b7c2b 100644 --- a/lib/checks/lists/only-dlitems.json +++ b/lib/checks/lists/only-dlitems.json @@ -1,6 +1,6 @@ { "id": "only-dlitems", - "evaluate": "only-dlitems.js", + "evaluate": "only-dlitems-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/lists/only-listitems.js b/lib/checks/lists/only-listitems-evaluate.js similarity index 100% rename from lib/checks/lists/only-listitems.js rename to lib/checks/lists/only-listitems-evaluate.js diff --git a/lib/checks/lists/only-listitems.json b/lib/checks/lists/only-listitems.json index 541eb006fe..de5cf9fd40 100644 --- a/lib/checks/lists/only-listitems.json +++ b/lib/checks/lists/only-listitems.json @@ -1,6 +1,6 @@ { "id": "only-listitems", - "evaluate": "only-listitems.js", + "evaluate": "only-listitems-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/lists/structured-dlitems.js b/lib/checks/lists/structured-dlitems-evaluate.js similarity index 100% rename from lib/checks/lists/structured-dlitems.js rename to lib/checks/lists/structured-dlitems-evaluate.js diff --git a/lib/checks/lists/structured-dlitems.json b/lib/checks/lists/structured-dlitems.json index 9e5ed0a261..5311488c1a 100644 --- a/lib/checks/lists/structured-dlitems.json +++ b/lib/checks/lists/structured-dlitems.json @@ -1,6 +1,6 @@ { "id": "structured-dlitems", - "evaluate": "structured-dlitems.js", + "evaluate": "structured-dlitems-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/media/caption.js b/lib/checks/media/caption-evaluate.js similarity index 100% rename from lib/checks/media/caption.js rename to lib/checks/media/caption-evaluate.js diff --git a/lib/checks/media/caption.json b/lib/checks/media/caption.json index 52423d2cbe..ee26bd4322 100644 --- a/lib/checks/media/caption.json +++ b/lib/checks/media/caption.json @@ -1,6 +1,6 @@ { "id": "caption", - "evaluate": "caption.js", + "evaluate": "caption-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/media/description.js b/lib/checks/media/description-evaluate.js similarity index 100% rename from lib/checks/media/description.js rename to lib/checks/media/description-evaluate.js diff --git a/lib/checks/media/description.json b/lib/checks/media/description.json index 9a262db3bf..339054c5d5 100644 --- a/lib/checks/media/description.json +++ b/lib/checks/media/description.json @@ -1,6 +1,6 @@ { "id": "description", - "evaluate": "description.js", + "evaluate": "description-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/media/frame-tested.js b/lib/checks/media/frame-tested-evaluate.js similarity index 100% rename from lib/checks/media/frame-tested.js rename to lib/checks/media/frame-tested-evaluate.js diff --git a/lib/checks/media/frame-tested.json b/lib/checks/media/frame-tested.json index de02df6593..04477c210f 100644 --- a/lib/checks/media/frame-tested.json +++ b/lib/checks/media/frame-tested.json @@ -1,6 +1,6 @@ { "id": "frame-tested", - "evaluate": "frame-tested.js", + "evaluate": "frame-tested-evaluate.js", "options": { "isViolation": false }, diff --git a/lib/checks/media/no-autoplay-audio.js b/lib/checks/media/no-autoplay-audio-evaluate.js similarity index 100% rename from lib/checks/media/no-autoplay-audio.js rename to lib/checks/media/no-autoplay-audio-evaluate.js diff --git a/lib/checks/media/no-autoplay-audio.json b/lib/checks/media/no-autoplay-audio.json index 94ea6b177e..d14a7cc222 100644 --- a/lib/checks/media/no-autoplay-audio.json +++ b/lib/checks/media/no-autoplay-audio.json @@ -1,6 +1,6 @@ { "id": "no-autoplay-audio", - "evaluate": "no-autoplay-audio.js", + "evaluate": "no-autoplay-audio-evaluate.js", "options": { "allowedDuration": 3 }, diff --git a/lib/checks/mobile/css-orientation-lock.js b/lib/checks/mobile/css-orientation-lock-evaluate.js similarity index 100% rename from lib/checks/mobile/css-orientation-lock.js rename to lib/checks/mobile/css-orientation-lock-evaluate.js diff --git a/lib/checks/mobile/css-orientation-lock.json b/lib/checks/mobile/css-orientation-lock.json index 93acdb2bdf..6a510b4b5d 100644 --- a/lib/checks/mobile/css-orientation-lock.json +++ b/lib/checks/mobile/css-orientation-lock.json @@ -1,6 +1,6 @@ { "id": "css-orientation-lock", - "evaluate": "css-orientation-lock.js", + "evaluate": "css-orientation-lock-evaluate.js", "options": { "degreeThreshold": 2 }, diff --git a/lib/checks/mobile/meta-viewport-large.json b/lib/checks/mobile/meta-viewport-large.json index 21551ce666..799991ab72 100644 --- a/lib/checks/mobile/meta-viewport-large.json +++ b/lib/checks/mobile/meta-viewport-large.json @@ -1,6 +1,6 @@ { "id": "meta-viewport-large", - "evaluate": "meta-viewport-scale.js", + "evaluate": "meta-viewport-scale-evaluate.js", "options": { "scaleMinimum": 5, "lowerBound": 2 diff --git a/lib/checks/mobile/meta-viewport-scale.js b/lib/checks/mobile/meta-viewport-scale-evaluate.js similarity index 100% rename from lib/checks/mobile/meta-viewport-scale.js rename to lib/checks/mobile/meta-viewport-scale-evaluate.js diff --git a/lib/checks/mobile/meta-viewport.json b/lib/checks/mobile/meta-viewport.json index 1a3e4332b6..593332a25e 100644 --- a/lib/checks/mobile/meta-viewport.json +++ b/lib/checks/mobile/meta-viewport.json @@ -1,6 +1,6 @@ { "id": "meta-viewport", - "evaluate": "meta-viewport-scale.js", + "evaluate": "meta-viewport-scale-evaluate.js", "options": { "scaleMinimum": 2 }, diff --git a/lib/checks/navigation/header-present.js b/lib/checks/navigation/header-present-evaluate.js similarity index 100% rename from lib/checks/navigation/header-present.js rename to lib/checks/navigation/header-present-evaluate.js diff --git a/lib/checks/navigation/header-present.json b/lib/checks/navigation/header-present.json index 57770a43ae..1e91f23e10 100644 --- a/lib/checks/navigation/header-present.json +++ b/lib/checks/navigation/header-present.json @@ -1,6 +1,6 @@ { "id": "header-present", - "evaluate": "header-present.js", + "evaluate": "header-present-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/navigation/heading-order.js b/lib/checks/navigation/heading-order-evaluate.js similarity index 100% rename from lib/checks/navigation/heading-order.js rename to lib/checks/navigation/heading-order-evaluate.js diff --git a/lib/checks/navigation/heading-order.json b/lib/checks/navigation/heading-order.json index 45ec9fd962..5370b4464b 100644 --- a/lib/checks/navigation/heading-order.json +++ b/lib/checks/navigation/heading-order.json @@ -1,6 +1,6 @@ { "id": "heading-order", - "evaluate": "heading-order.js", + "evaluate": "heading-order-evaluate.js", "after": "heading-order-after.js", "metadata": { "impact": "moderate", diff --git a/lib/checks/navigation/identical-links-same-purpose.js b/lib/checks/navigation/identical-links-same-purpose-evaluate.js similarity index 100% rename from lib/checks/navigation/identical-links-same-purpose.js rename to lib/checks/navigation/identical-links-same-purpose-evaluate.js diff --git a/lib/checks/navigation/identical-links-same-purpose.json b/lib/checks/navigation/identical-links-same-purpose.json index 305bf45f4f..af3a63c688 100644 --- a/lib/checks/navigation/identical-links-same-purpose.json +++ b/lib/checks/navigation/identical-links-same-purpose.json @@ -1,6 +1,6 @@ { "id": "identical-links-same-purpose", - "evaluate": "identical-links-same-purpose.js", + "evaluate": "identical-links-same-purpose-evaluate.js", "after": "identical-links-same-purpose-after.js", "metadata": { "impact": "minor", diff --git a/lib/checks/navigation/internal-link-present.js b/lib/checks/navigation/internal-link-present-evaluate.js similarity index 100% rename from lib/checks/navigation/internal-link-present.js rename to lib/checks/navigation/internal-link-present-evaluate.js diff --git a/lib/checks/navigation/internal-link-present.json b/lib/checks/navigation/internal-link-present.json index 415a65228f..a7c16a306d 100644 --- a/lib/checks/navigation/internal-link-present.json +++ b/lib/checks/navigation/internal-link-present.json @@ -1,6 +1,6 @@ { "id": "internal-link-present", - "evaluate": "internal-link-present.js", + "evaluate": "internal-link-present-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/navigation/landmark.js b/lib/checks/navigation/landmark-evaluate.js similarity index 100% rename from lib/checks/navigation/landmark.js rename to lib/checks/navigation/landmark-evaluate.js diff --git a/lib/checks/navigation/landmark.json b/lib/checks/navigation/landmark.json index 7a15c3f795..ba3a3c5ebf 100644 --- a/lib/checks/navigation/landmark.json +++ b/lib/checks/navigation/landmark.json @@ -1,6 +1,6 @@ { "id": "landmark", - "evaluate": "landmark.js", + "evaluate": "landmark-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/navigation/meta-refresh.js b/lib/checks/navigation/meta-refresh-evaluate.js similarity index 100% rename from lib/checks/navigation/meta-refresh.js rename to lib/checks/navigation/meta-refresh-evaluate.js diff --git a/lib/checks/navigation/meta-refresh.json b/lib/checks/navigation/meta-refresh.json index 4e4f95d7d1..c436ef2302 100644 --- a/lib/checks/navigation/meta-refresh.json +++ b/lib/checks/navigation/meta-refresh.json @@ -1,6 +1,6 @@ { "id": "meta-refresh", - "evaluate": "meta-refresh.js", + "evaluate": "meta-refresh-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/navigation/p-as-heading.js b/lib/checks/navigation/p-as-heading-evaluate.js similarity index 100% rename from lib/checks/navigation/p-as-heading.js rename to lib/checks/navigation/p-as-heading-evaluate.js diff --git a/lib/checks/navigation/p-as-heading.json b/lib/checks/navigation/p-as-heading.json index cbb08f2cb9..f61a32bb7a 100644 --- a/lib/checks/navigation/p-as-heading.json +++ b/lib/checks/navigation/p-as-heading.json @@ -1,6 +1,6 @@ { "id": "p-as-heading", - "evaluate": "p-as-heading.js", + "evaluate": "p-as-heading-evaluate.js", "options": { "margins": [ { diff --git a/lib/checks/navigation/region.js b/lib/checks/navigation/region-evaluate.js similarity index 100% rename from lib/checks/navigation/region.js rename to lib/checks/navigation/region-evaluate.js diff --git a/lib/checks/navigation/region.json b/lib/checks/navigation/region.json index 98b5612cf8..f9fc03cc7c 100644 --- a/lib/checks/navigation/region.json +++ b/lib/checks/navigation/region.json @@ -1,6 +1,6 @@ { "id": "region", - "evaluate": "region.js", + "evaluate": "region-evaluate.js", "metadata": { "impact": "moderate", "messages": { diff --git a/lib/checks/navigation/skip-link.js b/lib/checks/navigation/skip-link-evaluate.js similarity index 100% rename from lib/checks/navigation/skip-link.js rename to lib/checks/navigation/skip-link-evaluate.js diff --git a/lib/checks/navigation/skip-link.json b/lib/checks/navigation/skip-link.json index b2a2964267..867406a9a9 100644 --- a/lib/checks/navigation/skip-link.json +++ b/lib/checks/navigation/skip-link.json @@ -1,6 +1,6 @@ { "id": "skip-link", - "evaluate": "skip-link.js", + "evaluate": "skip-link-evaluate.js", "metadata": { "impact": "moderate", "messages": { diff --git a/lib/checks/navigation/unique-frame-title.js b/lib/checks/navigation/unique-frame-title-evaluate.js similarity index 100% rename from lib/checks/navigation/unique-frame-title.js rename to lib/checks/navigation/unique-frame-title-evaluate.js diff --git a/lib/checks/navigation/unique-frame-title.json b/lib/checks/navigation/unique-frame-title.json index 78fbef3514..35f12f1536 100644 --- a/lib/checks/navigation/unique-frame-title.json +++ b/lib/checks/navigation/unique-frame-title.json @@ -1,6 +1,6 @@ { "id": "unique-frame-title", - "evaluate": "unique-frame-title.js", + "evaluate": "unique-frame-title-evaluate.js", "after": "unique-frame-title-after.js", "metadata": { "impact": "serious", diff --git a/lib/checks/parsing/duplicate-id-active.json b/lib/checks/parsing/duplicate-id-active.json index 3c90070aa3..404f6b0e56 100644 --- a/lib/checks/parsing/duplicate-id-active.json +++ b/lib/checks/parsing/duplicate-id-active.json @@ -1,6 +1,6 @@ { "id": "duplicate-id-active", - "evaluate": "duplicate-id.js", + "evaluate": "duplicate-id-evaluate.js", "after": "duplicate-id-after.js", "metadata": { "impact": "serious", diff --git a/lib/checks/parsing/duplicate-id-aria.json b/lib/checks/parsing/duplicate-id-aria.json index c80c957949..d86008126c 100644 --- a/lib/checks/parsing/duplicate-id-aria.json +++ b/lib/checks/parsing/duplicate-id-aria.json @@ -1,6 +1,6 @@ { "id": "duplicate-id-aria", - "evaluate": "duplicate-id.js", + "evaluate": "duplicate-id-evaluate.js", "after": "duplicate-id-after.js", "metadata": { "impact": "critical", diff --git a/lib/checks/parsing/duplicate-id.js b/lib/checks/parsing/duplicate-id-evaluate.js similarity index 100% rename from lib/checks/parsing/duplicate-id.js rename to lib/checks/parsing/duplicate-id-evaluate.js diff --git a/lib/checks/parsing/duplicate-id.json b/lib/checks/parsing/duplicate-id.json index 351437fab3..1f9fd1c420 100644 --- a/lib/checks/parsing/duplicate-id.json +++ b/lib/checks/parsing/duplicate-id.json @@ -1,12 +1,12 @@ { "id": "duplicate-id", - "evaluate": "duplicate-id.js", + "evaluate": "duplicate-id-evaluate.js", "after": "duplicate-id-after.js", "metadata": { "impact": "minor", "messages": { "pass": "Document has no static elements that share the same id attribute", - "fail": "Document has multiple static elements with the same id attribute" + "fail": "Document has multiple static elements with the same id attribute: ${data}" } } } diff --git a/lib/checks/shared/aria-label.js b/lib/checks/shared/aria-label-evaluate.js similarity index 100% rename from lib/checks/shared/aria-label.js rename to lib/checks/shared/aria-label-evaluate.js diff --git a/lib/checks/shared/aria-label.json b/lib/checks/shared/aria-label.json index c6db8a6c95..953279a1f9 100644 --- a/lib/checks/shared/aria-label.json +++ b/lib/checks/shared/aria-label.json @@ -1,6 +1,6 @@ { "id": "aria-label", - "evaluate": "aria-label.js", + "evaluate": "aria-label-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/shared/aria-labelledby.js b/lib/checks/shared/aria-labelledby-evaluate.js similarity index 100% rename from lib/checks/shared/aria-labelledby.js rename to lib/checks/shared/aria-labelledby-evaluate.js diff --git a/lib/checks/shared/aria-labelledby.json b/lib/checks/shared/aria-labelledby.json index 8ef7e6cbf3..0bbc6117e7 100644 --- a/lib/checks/shared/aria-labelledby.json +++ b/lib/checks/shared/aria-labelledby.json @@ -1,6 +1,6 @@ { "id": "aria-labelledby", - "evaluate": "aria-labelledby.js", + "evaluate": "aria-labelledby-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/shared/avoid-inline-spacing.js b/lib/checks/shared/avoid-inline-spacing-evaluate.js similarity index 100% rename from lib/checks/shared/avoid-inline-spacing.js rename to lib/checks/shared/avoid-inline-spacing-evaluate.js diff --git a/lib/checks/shared/avoid-inline-spacing.json b/lib/checks/shared/avoid-inline-spacing.json index a530cfa5ee..cbb5d3b2a0 100644 --- a/lib/checks/shared/avoid-inline-spacing.json +++ b/lib/checks/shared/avoid-inline-spacing.json @@ -1,6 +1,6 @@ { "id": "avoid-inline-spacing", - "evaluate": "avoid-inline-spacing.js", + "evaluate": "avoid-inline-spacing-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/shared/button-has-visible-text.js b/lib/checks/shared/button-has-visible-text-evaluate.js similarity index 100% rename from lib/checks/shared/button-has-visible-text.js rename to lib/checks/shared/button-has-visible-text-evaluate.js diff --git a/lib/checks/shared/button-has-visible-text.json b/lib/checks/shared/button-has-visible-text.json index c23cc7448b..a1329c5a74 100644 --- a/lib/checks/shared/button-has-visible-text.json +++ b/lib/checks/shared/button-has-visible-text.json @@ -1,6 +1,6 @@ { "id": "button-has-visible-text", - "evaluate": "button-has-visible-text.js", + "evaluate": "button-has-visible-text-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/shared/doc-has-title.js b/lib/checks/shared/doc-has-title-evaluate.js similarity index 100% rename from lib/checks/shared/doc-has-title.js rename to lib/checks/shared/doc-has-title-evaluate.js diff --git a/lib/checks/shared/doc-has-title.json b/lib/checks/shared/doc-has-title.json index b99b391a9d..1a07fc8f9e 100644 --- a/lib/checks/shared/doc-has-title.json +++ b/lib/checks/shared/doc-has-title.json @@ -1,6 +1,6 @@ { "id": "doc-has-title", - "evaluate": "doc-has-title.js", + "evaluate": "doc-has-title-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/shared/exists.js b/lib/checks/shared/exists-evaluate.js similarity index 100% rename from lib/checks/shared/exists.js rename to lib/checks/shared/exists-evaluate.js diff --git a/lib/checks/shared/exists.json b/lib/checks/shared/exists.json index 6eb8efacd4..49857971ca 100644 --- a/lib/checks/shared/exists.json +++ b/lib/checks/shared/exists.json @@ -1,6 +1,6 @@ { "id": "exists", - "evaluate": "exists.js", + "evaluate": "exists-evaluate.js", "metadata": { "impact": "minor", "messages": { diff --git a/lib/checks/shared/has-alt.js b/lib/checks/shared/has-alt-evaluate.js similarity index 100% rename from lib/checks/shared/has-alt.js rename to lib/checks/shared/has-alt-evaluate.js diff --git a/lib/checks/shared/has-alt.json b/lib/checks/shared/has-alt.json index 8fa030fe75..705b53cdd4 100644 --- a/lib/checks/shared/has-alt.json +++ b/lib/checks/shared/has-alt.json @@ -1,6 +1,6 @@ { "id": "has-alt", - "evaluate": "has-alt.js", + "evaluate": "has-alt-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/shared/has-visible-text.js b/lib/checks/shared/has-visible-text-evaluate.js similarity index 100% rename from lib/checks/shared/has-visible-text.js rename to lib/checks/shared/has-visible-text-evaluate.js diff --git a/lib/checks/shared/has-visible-text.json b/lib/checks/shared/has-visible-text.json index 3bfef545c0..205516d1f7 100644 --- a/lib/checks/shared/has-visible-text.json +++ b/lib/checks/shared/has-visible-text.json @@ -1,6 +1,6 @@ { "id": "has-visible-text", - "evaluate": "has-visible-text.js", + "evaluate": "has-visible-text-evaluate.js", "metadata": { "impact": "minor", "messages": { diff --git a/lib/checks/shared/is-on-screen.js b/lib/checks/shared/is-on-screen-evaluate.js similarity index 100% rename from lib/checks/shared/is-on-screen.js rename to lib/checks/shared/is-on-screen-evaluate.js diff --git a/lib/checks/shared/is-on-screen.json b/lib/checks/shared/is-on-screen.json index c0ce398078..92da8fb142 100644 --- a/lib/checks/shared/is-on-screen.json +++ b/lib/checks/shared/is-on-screen.json @@ -1,6 +1,6 @@ { "id": "is-on-screen", - "evaluate": "is-on-screen.js", + "evaluate": "is-on-screen-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/shared/non-empty-alt.js b/lib/checks/shared/non-empty-alt-evaluate.js similarity index 100% rename from lib/checks/shared/non-empty-alt.js rename to lib/checks/shared/non-empty-alt-evaluate.js diff --git a/lib/checks/shared/non-empty-alt.json b/lib/checks/shared/non-empty-alt.json index 2340746c87..54639a861e 100644 --- a/lib/checks/shared/non-empty-alt.json +++ b/lib/checks/shared/non-empty-alt.json @@ -1,6 +1,6 @@ { "id": "non-empty-alt", - "evaluate": "non-empty-alt.js", + "evaluate": "non-empty-alt-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/shared/non-empty-if-present.js b/lib/checks/shared/non-empty-if-present-evaluate.js similarity index 100% rename from lib/checks/shared/non-empty-if-present.js rename to lib/checks/shared/non-empty-if-present-evaluate.js diff --git a/lib/checks/shared/non-empty-if-present.json b/lib/checks/shared/non-empty-if-present.json index a2ba00f395..a2ceba8c0f 100644 --- a/lib/checks/shared/non-empty-if-present.json +++ b/lib/checks/shared/non-empty-if-present.json @@ -1,6 +1,6 @@ { "id": "non-empty-if-present", - "evaluate": "non-empty-if-present.js", + "evaluate": "non-empty-if-present-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/shared/non-empty-title.js b/lib/checks/shared/non-empty-title-evaluate.js similarity index 100% rename from lib/checks/shared/non-empty-title.js rename to lib/checks/shared/non-empty-title-evaluate.js diff --git a/lib/checks/shared/non-empty-title.json b/lib/checks/shared/non-empty-title.json index 4af9551cc2..3d5ce25b1f 100644 --- a/lib/checks/shared/non-empty-title.json +++ b/lib/checks/shared/non-empty-title.json @@ -1,6 +1,6 @@ { "id": "non-empty-title", - "evaluate": "non-empty-title.js", + "evaluate": "non-empty-title-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/shared/non-empty-value.js b/lib/checks/shared/non-empty-value-evaluate.js similarity index 100% rename from lib/checks/shared/non-empty-value.js rename to lib/checks/shared/non-empty-value-evaluate.js diff --git a/lib/checks/shared/non-empty-value.json b/lib/checks/shared/non-empty-value.json index ac4ab5246c..404b7fb26f 100644 --- a/lib/checks/shared/non-empty-value.json +++ b/lib/checks/shared/non-empty-value.json @@ -1,6 +1,6 @@ { "id": "non-empty-value", - "evaluate": "non-empty-value.js", + "evaluate": "non-empty-value-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/shared/role-none.js b/lib/checks/shared/role-none-evaluate.js similarity index 100% rename from lib/checks/shared/role-none.js rename to lib/checks/shared/role-none-evaluate.js diff --git a/lib/checks/shared/role-none.json b/lib/checks/shared/role-none.json index 875ed30540..7d660ed370 100644 --- a/lib/checks/shared/role-none.json +++ b/lib/checks/shared/role-none.json @@ -1,6 +1,6 @@ { "id": "role-none", - "evaluate": "role-none.js", + "evaluate": "role-none-evaluate.js", "metadata": { "impact": "minor", "messages": { diff --git a/lib/checks/shared/role-presentation.js b/lib/checks/shared/role-presentation-evaluate.js similarity index 100% rename from lib/checks/shared/role-presentation.js rename to lib/checks/shared/role-presentation-evaluate.js diff --git a/lib/checks/shared/role-presentation.json b/lib/checks/shared/role-presentation.json index a24ad51098..5e18137aea 100644 --- a/lib/checks/shared/role-presentation.json +++ b/lib/checks/shared/role-presentation.json @@ -1,6 +1,6 @@ { "id": "role-presentation", - "evaluate": "role-presentation.js", + "evaluate": "role-presentation-evaluate.js", "metadata": { "impact": "minor", "messages": { diff --git a/lib/checks/shared/svg-non-empty-title.js b/lib/checks/shared/svg-non-empty-title-evaluate.js similarity index 100% rename from lib/checks/shared/svg-non-empty-title.js rename to lib/checks/shared/svg-non-empty-title-evaluate.js diff --git a/lib/checks/shared/svg-non-empty-title.json b/lib/checks/shared/svg-non-empty-title.json index 9f929992cc..6493ff26b0 100644 --- a/lib/checks/shared/svg-non-empty-title.json +++ b/lib/checks/shared/svg-non-empty-title.json @@ -1,6 +1,6 @@ { "id": "svg-non-empty-title", - "evaluate": "svg-non-empty-title.js", + "evaluate": "svg-non-empty-title-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/tables/caption-faked.js b/lib/checks/tables/caption-faked-evaluate.js similarity index 100% rename from lib/checks/tables/caption-faked.js rename to lib/checks/tables/caption-faked-evaluate.js diff --git a/lib/checks/tables/caption-faked.json b/lib/checks/tables/caption-faked.json index 79d20774f4..b763690384 100644 --- a/lib/checks/tables/caption-faked.json +++ b/lib/checks/tables/caption-faked.json @@ -1,6 +1,6 @@ { "id": "caption-faked", - "evaluate": "caption-faked.js", + "evaluate": "caption-faked-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/tables/has-caption.js b/lib/checks/tables/has-caption-evaluate.js similarity index 100% rename from lib/checks/tables/has-caption.js rename to lib/checks/tables/has-caption-evaluate.js diff --git a/lib/checks/tables/has-caption.json b/lib/checks/tables/has-caption.json index 8bab37c55f..d408562100 100644 --- a/lib/checks/tables/has-caption.json +++ b/lib/checks/tables/has-caption.json @@ -1,6 +1,6 @@ { "id": "has-caption", - "evaluate": "has-caption.js", + "evaluate": "has-caption-evaluate.js", "deprecated": true, "metadata": { "impact": "serious", diff --git a/lib/checks/tables/has-summary.js b/lib/checks/tables/has-summary-evaluate.js similarity index 100% rename from lib/checks/tables/has-summary.js rename to lib/checks/tables/has-summary-evaluate.js diff --git a/lib/checks/tables/has-summary.json b/lib/checks/tables/has-summary.json index 4e9a6f680c..ea37c91b6d 100644 --- a/lib/checks/tables/has-summary.json +++ b/lib/checks/tables/has-summary.json @@ -1,6 +1,6 @@ { "id": "has-summary", - "evaluate": "has-summary.js", + "evaluate": "has-summary-evaluate.js", "deprecated": true, "metadata": { "impact": "serious", diff --git a/lib/checks/tables/has-th.js b/lib/checks/tables/has-th-evaluate.js similarity index 100% rename from lib/checks/tables/has-th.js rename to lib/checks/tables/has-th-evaluate.js diff --git a/lib/checks/tables/has-th.json b/lib/checks/tables/has-th.json index 61bfafdf05..a438b83053 100644 --- a/lib/checks/tables/has-th.json +++ b/lib/checks/tables/has-th.json @@ -1,6 +1,6 @@ { "id": "has-th", - "evaluate": "has-th.js", + "evaluate": "has-th-evaluate.js", "deprecated": true, "metadata": { "impact": "serious", diff --git a/lib/checks/tables/html5-scope.js b/lib/checks/tables/html5-scope-evaluate.js similarity index 100% rename from lib/checks/tables/html5-scope.js rename to lib/checks/tables/html5-scope-evaluate.js diff --git a/lib/checks/tables/html5-scope.json b/lib/checks/tables/html5-scope.json index 021a1b2343..b36d756aaa 100644 --- a/lib/checks/tables/html5-scope.json +++ b/lib/checks/tables/html5-scope.json @@ -1,6 +1,6 @@ { "id": "html5-scope", - "evaluate": "html5-scope.js", + "evaluate": "html5-scope-evaluate.js", "metadata": { "impact": "moderate", "messages": { diff --git a/lib/checks/tables/same-caption-summary.js b/lib/checks/tables/same-caption-summary-evaluate.js similarity index 100% rename from lib/checks/tables/same-caption-summary.js rename to lib/checks/tables/same-caption-summary-evaluate.js diff --git a/lib/checks/tables/same-caption-summary.json b/lib/checks/tables/same-caption-summary.json index caa3da4215..3d2bda1b3b 100644 --- a/lib/checks/tables/same-caption-summary.json +++ b/lib/checks/tables/same-caption-summary.json @@ -1,6 +1,6 @@ { "id": "same-caption-summary", - "evaluate": "same-caption-summary.js", + "evaluate": "same-caption-summary-evaluate.js", "metadata": { "impact": "minor", "messages": { diff --git a/lib/checks/tables/scope-value.js b/lib/checks/tables/scope-value-evaluate.js similarity index 100% rename from lib/checks/tables/scope-value.js rename to lib/checks/tables/scope-value-evaluate.js diff --git a/lib/checks/tables/scope-value.json b/lib/checks/tables/scope-value.json index 66a139ad50..a4920ce99b 100644 --- a/lib/checks/tables/scope-value.json +++ b/lib/checks/tables/scope-value.json @@ -1,6 +1,6 @@ { "id": "scope-value", - "evaluate": "scope-value.js", + "evaluate": "scope-value-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/tables/td-has-header.js b/lib/checks/tables/td-has-header-evaluate.js similarity index 100% rename from lib/checks/tables/td-has-header.js rename to lib/checks/tables/td-has-header-evaluate.js diff --git a/lib/checks/tables/td-has-header.json b/lib/checks/tables/td-has-header.json index f68c850135..95c7ccb51e 100644 --- a/lib/checks/tables/td-has-header.json +++ b/lib/checks/tables/td-has-header.json @@ -1,6 +1,6 @@ { "id": "td-has-header", - "evaluate": "td-has-header.js", + "evaluate": "td-has-header-evaluate.js", "metadata": { "impact": "critical", "messages": { diff --git a/lib/checks/tables/td-headers-attr.js b/lib/checks/tables/td-headers-attr-evaluate.js similarity index 100% rename from lib/checks/tables/td-headers-attr.js rename to lib/checks/tables/td-headers-attr-evaluate.js diff --git a/lib/checks/tables/td-headers-attr.json b/lib/checks/tables/td-headers-attr.json index c044cb483d..38a9dca9a7 100644 --- a/lib/checks/tables/td-headers-attr.json +++ b/lib/checks/tables/td-headers-attr.json @@ -1,6 +1,6 @@ { "id": "td-headers-attr", - "evaluate": "td-headers-attr.js", + "evaluate": "td-headers-attr-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/tables/th-has-data-cells.js b/lib/checks/tables/th-has-data-cells-evaluate.js similarity index 100% rename from lib/checks/tables/th-has-data-cells.js rename to lib/checks/tables/th-has-data-cells-evaluate.js diff --git a/lib/checks/tables/th-has-data-cells.json b/lib/checks/tables/th-has-data-cells.json index f4aef88a45..ec7cab50c0 100644 --- a/lib/checks/tables/th-has-data-cells.json +++ b/lib/checks/tables/th-has-data-cells.json @@ -1,6 +1,6 @@ { "id": "th-has-data-cells", - "evaluate": "th-has-data-cells.js", + "evaluate": "th-has-data-cells-evaluate.js", "metadata": { "impact": "serious", "messages": { diff --git a/lib/checks/visibility/hidden-content.js b/lib/checks/visibility/hidden-content-evaluate.js similarity index 100% rename from lib/checks/visibility/hidden-content.js rename to lib/checks/visibility/hidden-content-evaluate.js diff --git a/lib/checks/visibility/hidden-content.json b/lib/checks/visibility/hidden-content.json index 69850ad770..5220359d42 100644 --- a/lib/checks/visibility/hidden-content.json +++ b/lib/checks/visibility/hidden-content.json @@ -1,6 +1,6 @@ { "id": "hidden-content", - "evaluate": "hidden-content.js", + "evaluate": "hidden-content-evaluate.js", "metadata": { "impact": "minor", "messages": { diff --git a/lib/commons/aria/index.js b/lib/commons/aria/index.js index 58a44cae95..9c96fa80db 100644 --- a/lib/commons/aria/index.js +++ b/lib/commons/aria/index.js @@ -1,62 +1,29 @@ -/* global aria */ - -// TODO: es-module-commons. convert to: -// export { default as allowedAttr } from 'path' -import allowedAttr from './allowed-attr'; -import arialabelText from './arialabel-text'; -import arialabelledbyText from './arialabelledby-text'; -import getElementUnallowedRoles from './get-element-unallowed-roles'; -import getOwnedVirtual from './get-owned-virtual'; -import getRoleType from './get-role-type'; -import getRole from './get-role'; -import getRolesByType from './get-roles-by-type'; -import getRolesWithNameFromContents from './get-roles-with-name-from-contents'; -import implicitNodes from './implicit-nodes'; -import getImplicitRole from './implicit-role'; -import isAccessibleRef from './is-accessible-ref'; -import isAriaRoleAllowedOnElement from './is-aria-role-allowed-on-element'; -import isUnsupportedRole from './is-unsupported-role'; -import isValidRole from './is-valid-role'; -import labelVirtual from './label-virtual'; -import label from './label'; -import lookupTable from './lookup-table'; -import namedFromContents from './named-from-contents'; -import requiredAttr from './required-attr'; -import requiredContext from './required-context'; -import requiredOwned from './required-owned'; -import validateAttrValue from './validate-attr-value'; -import validateAttr from './validate-attr'; - /** * Namespace for aria-related utilities. * @namespace commons.aria * @memberof axe */ -// TODO: es-module-commons. don't rely on global -aria = { - allowedAttr, - arialabelText, - arialabelledbyText, - getElementUnallowedRoles, - getOwnedVirtual, - getRoleType, - getRole, - getRolesByType, - getRolesWithNameFromContents, - implicitNodes, - implicitRole: getImplicitRole, - isAccessibleRef, - isAriaRoleAllowedOnElement, - isUnsupportedRole, - isValidRole, - labelVirtual, - label, - lookupTable, - namedFromContents, - requiredAttr, - requiredContext, - requiredOwned, - validateAttrValue, - validateAttr -}; -commons.aria = aria; +export { default as allowedAttr } from './allowed-attr'; +export { default as arialabelText } from './arialabel-text'; +export { default as arialabelledbyText } from './arialabelledby-text'; +export { default as getElementUnallowedRoles } from './get-element-unallowed-roles'; +export { default as getOwnedVirtual } from './get-owned-virtual'; +export { default as getRoleType } from './get-role-type'; +export { default as getRole } from './get-role'; +export { default as getRolesByType } from './get-roles-by-type'; +export { default as getRolesWithNameFromContents } from './get-roles-with-name-from-contents'; +export { default as implicitNodes } from './implicit-nodes'; +export { default as implicitRole } from './implicit-role'; +export { default as isAccessibleRef } from './is-accessible-ref'; +export { default as isAriaRoleAllowedOnElement } from './is-aria-role-allowed-on-element'; +export { default as isUnsupportedRole } from './is-unsupported-role'; +export { default as isValidRole } from './is-valid-role'; +export { default as labelVirtual } from './label-virtual'; +export { default as label } from './label'; +export { default as lookupTable } from './lookup-table'; +export { default as namedFromContents } from './named-from-contents'; +export { default as requiredAttr } from './required-attr'; +export { default as requiredContext } from './required-context'; +export { default as requiredOwned } from './required-owned'; +export { default as validateAttrValue } from './validate-attr-value'; +export { default as validateAttr } from './validate-attr'; diff --git a/lib/commons/color/index.js b/lib/commons/color/index.js index 20b394856e..f650d3427d 100644 --- a/lib/commons/color/index.js +++ b/lib/commons/color/index.js @@ -1,39 +1,19 @@ -// TODO: es-module-commons. convert to: -// export { default as isAriaCombobox } from 'path' -import centerPointOfRect from './center-point-of-rect'; -import Color from './color'; -import elementHasImage from './element-has-image'; -import elementIsDistinct from './element-is-distinct'; -import filteredRectStack from './filtered-rect-stack'; -import flattenColors from './flatten-colors'; -import getBackgroundColor from './get-background-color'; -import getBackgroundStack from './get-background-stack'; -import getContrast from './get-contrast'; -import getForegroundColor from './get-foreground-color'; -import getOwnBackgroundColor from './get-own-background-color'; -import getRectStack from './get-rect-stack'; -import hasValidContrastRatio from './has-valid-contrast-ratio'; -import incompleteData from './incomplete-data'; - /** * Namespace for color-related utilities. * @namespace commons.color * @memberof axe */ -const color = { - centerPointOfRect, - Color, - elementHasImage, - elementIsDistinct, - filteredRectStack, - flattenColors, - getBackgroundColor, - getBackgroundStack, - getContrast, - getForegroundColor, - getOwnBackgroundColor, - getRectStack, - hasValidContrastRatio, - incompleteData -}; -commons.color = color; +export { default as centerPointOfRect } from './center-point-of-rect'; +export { default as Color } from './color'; +export { default as elementHasImage } from './element-has-image'; +export { default as elementIsDistinct } from './element-is-distinct'; +export { default as filteredRectStack } from './filtered-rect-stack'; +export { default as flattenColors } from './flatten-colors'; +export { default as getBackgroundColor } from './get-background-color'; +export { default as getBackgroundStack } from './get-background-stack'; +export { default as getContrast } from './get-contrast'; +export { default as getForegroundColor } from './get-foreground-color'; +export { default as getOwnBackgroundColor } from './get-own-background-color'; +export { default as getRectStack } from './get-rect-stack'; +export { default as hasValidContrastRatio } from './has-valid-contrast-ratio'; +export { default as incompleteData } from './incomplete-data'; diff --git a/lib/commons/dom/index.js b/lib/commons/dom/index.js index 32c33b9cb2..025d2d0a67 100644 --- a/lib/commons/dom/index.js +++ b/lib/commons/dom/index.js @@ -1,77 +1,38 @@ -// TODO: es-module-commons. convert to: -// export { default as isAriaCombobox } from 'path' -import findElmsInContext from './find-elms-in-context'; -import findUpVirtual from './find-up-virtual'; -import findUp from './find-up'; -import getComposedParent from './get-composed-parent'; -import getElementByReference from './get-element-by-reference'; -import getElementCoordinates from './get-element-coordinates'; -import getElementStack from './get-element-stack'; -import getRootNode from './get-root-node'; -import getScrollOffset from './get-scroll-offset'; -import getTabbableElements from './get-tabbable-elements'; -import getTextElementStack from './get-text-element-stack'; -import getViewportSize from './get-viewport-size'; -import hasContentVirtual from './has-content-virtual'; -import hasContent from './has-content'; -import idrefs from './idrefs'; -import insertedIntoFocusOrder from './inserted-into-focus-order'; -import isFocusable from './is-focusable'; -import isHiddenWithCSS from './is-hidden-with-css'; -import isHTML5 from './is-html5'; -import isInTextBlock from './is-in-text-block'; -import isModalOpen from './is-modal-open'; -import isNativelyFocusable from './is-natively-focusable'; -import isNode from './is-node'; -import isOffscreen from './is-offscreen'; -import isOpaque from './is-opaque'; -import isSkipLink from './is-skip-link'; -import isVisible from './is-visible'; -import isVisualContent from './is-visual-content'; -import reduceToElementsBelowFloating from './reduce-to-elements-below-floating'; -import shadowElementsFromPoint from './shadow-elements-from-point'; -import urlPropsFromAttribute from './url-props-from-attribute'; -import visuallyContains from './visually-contains'; -import visuallyOverlaps from './visually-overlaps'; - /** * Namespace for dom-related utilities. * @namespace dom * @memberof axe.commons */ -const dom = { - findElmsInContext, - findUpVirtual, - findUp, - getComposedParent, - getElementByReference, - getElementCoordinates, - getElementStack, - getRootNode, - getScrollOffset, - getTabbableElements, - getTextElementStack, - getViewportSize, - hasContentVirtual, - hasContent, - idrefs, - insertedIntoFocusOrder, - isFocusable, - isHiddenWithCSS, - isHTML5, - isInTextBlock, - isModalOpen, - isNativelyFocusable, - isNode, - isOffscreen, - isOpaque, - isSkipLink, - isVisible, - isVisualContent, - reduceToElementsBelowFloating, - shadowElementsFromPoint, - urlPropsFromAttribute, - visuallyContains, - visuallyOverlaps -}; -commons.dom = dom; +export { default as findElmsInContext } from './find-elms-in-context'; +export { default as findUpVirtual } from './find-up-virtual'; +export { default as findUp } from './find-up'; +export { default as getComposedParent } from './get-composed-parent'; +export { default as getElementByReference } from './get-element-by-reference'; +export { default as getElementCoordinates } from './get-element-coordinates'; +export { default as getElementStack } from './get-element-stack'; +export { default as getRootNode } from './get-root-node'; +export { default as getScrollOffset } from './get-scroll-offset'; +export { default as getTabbableElements } from './get-tabbable-elements'; +export { default as getTextElementStack } from './get-text-element-stack'; +export { default as getViewportSize } from './get-viewport-size'; +export { default as hasContentVirtual } from './has-content-virtual'; +export { default as hasContent } from './has-content'; +export { default as idrefs } from './idrefs'; +export { default as insertedIntoFocusOrder } from './inserted-into-focus-order'; +export { default as isFocusable } from './is-focusable'; +export { default as isHiddenWithCSS } from './is-hidden-with-css'; +export { default as isHTML5 } from './is-html5'; +export { default as isInTextBlock } from './is-in-text-block'; +export { default as isModalOpen } from './is-modal-open'; +export { default as isNativelyFocusable } from './is-natively-focusable'; +export { default as isNode } from './is-node'; +export { default as isOffscreen } from './is-offscreen'; +export { default as isOpaque } from './is-opaque'; +export { default as isSkipLink } from './is-skip-link'; +export { default as isVisible } from './is-visible'; +export { default as isVisualContent } from './is-visual-content'; +export { default as reduceToElementsBelowFloating } from './reduce-to-elements-below-floating'; +export { default as shadowElementsFromPoint } from './shadow-elements-from-point'; +export { default as urlPropsFromAttribute } from './url-props-from-attribute'; +export { default as visuallyContains } from './visually-contains'; +export { default as visuallyOverlaps } from './visually-overlaps'; diff --git a/lib/commons/forms/index.js b/lib/commons/forms/index.js index 4ed5ebf81e..f8ad8e9a33 100644 --- a/lib/commons/forms/index.js +++ b/lib/commons/forms/index.js @@ -1,23 +1,11 @@ -// TODO: es-module-commons. convert to: -// export { default as isAriaCombobox } from 'path' -import isAriaCombobox from './is-aria-combobox'; -import isAriaListbox from './is-aria-listbox'; -import isAriaRange from './is-aria-range'; -import isAriaTextbox from './is-aria-textbox'; -import isNativeSelect from './is-native-select'; -import isNativeTextbox from './is-native-textbox'; - /** * Namespace for forms-related utilities. * @namespace commons.forms * @memberof axe */ -const forms = { - isAriaCombobox, - isAriaListbox, - isAriaRange, - isAriaTextbox, - isNativeSelect, - isNativeTextbox -}; -commons.forms = forms; +export { default as isAriaCombobox } from './is-aria-combobox'; +export { default as isAriaListbox } from './is-aria-listbox'; +export { default as isAriaRange } from './is-aria-range'; +export { default as isAriaTextbox } from './is-aria-textbox'; +export { default as isNativeSelect } from './is-native-select'; +export { default as isNativeTextbox } from './is-native-textbox'; diff --git a/lib/commons/index.js b/lib/commons/index.js index 19cdbb10a9..3fee9ede58 100644 --- a/lib/commons/index.js +++ b/lib/commons/index.js @@ -1,14 +1,27 @@ -/*exported commons */ +/* global commons */ /*eslint no-unused-vars: 0*/ -/** @namespace axe */ /** * Namespace for axe common methods. * @namespace commons * @memberof axe */ +import * as aria from './aria'; +import * as color from './color'; +import * as dom from './dom'; +import * as forms from './forms'; +import matches from './matches'; +import * as table from './table'; +import * as text from './text'; +import utils from './utils'; -var commons = {}; -var aria = {}; -var text = {}; -var matches; +commons = { + aria, + color, + dom, + forms, + matches, + table, + text, + utils +}; diff --git a/lib/commons/matches/index.js b/lib/commons/matches/index.js index b24065946d..ad0d39a9b3 100644 --- a/lib/commons/matches/index.js +++ b/lib/commons/matches/index.js @@ -1,5 +1,3 @@ -/* global matches */ - /** * Namespace for matching utilities. * @namespace commons.matches @@ -10,14 +8,10 @@ import condition from './condition'; import fromDefinition from './from-definition'; import fromFunction from './from-function'; import fromPrimative from './from-primative'; -// TODO: es-module-commons. change to: -// import matches from './matches' -import matchesFn from './matches'; +import matches from './matches'; import nodeName from './node-name'; import properties from './properties'; -// TODO: es-module-commons. remove matches setter -matches = matchesFn; matches.attributes = attributes; matches.condition = condition; matches.fromDefinition = fromDefinition; @@ -26,5 +20,4 @@ matches.fromPrimative = fromPrimative; matches.nodeName = nodeName; matches.properties = properties; -// TODO: es-module-commons. remove -commons.matches = matchesFn; +export default matches; diff --git a/lib/commons/table/index.js b/lib/commons/table/index.js index 4eaea2dc28..5686e87e00 100644 --- a/lib/commons/table/index.js +++ b/lib/commons/table/index.js @@ -1,36 +1,19 @@ -// TODO: es-module-commons. convert to: -// export { default as isAriaCombobox } from 'path' -import getAllCells from './get-all-cells'; -import getCellPosition from './get-cell-position'; -import getHeaders from './get-headers'; -import getScope from './get-scope'; -import isColumnHeader from './is-column-header'; -import isDataCell from './is-data-cell'; -import isDataTable from './is-data-table'; -import isHeader from './is-header'; -import isRowHeader from './is-row-header'; -import toGrid from './to-grid'; -import traverse from './traverse'; - /** * Namespace for table-related utilities. * @namespace table * @memberof axe.commons */ -const table = { - getAllCells, - getCellPosition, - getHeaders, - getScope, - isColumnHeader, - isDataCell, - isDataTable, - isHeader, - isRowHeader, - toGrid, - traverse, +export { default as getAllCells } from './get-all-cells'; +export { default as getCellPosition } from './get-cell-position'; +export { default as getHeaders } from './get-headers'; +export { default as getScope } from './get-scope'; +export { default as isColumnHeader } from './is-column-header'; +export { default as isDataCell } from './is-data-cell'; +export { default as isDataTable } from './is-data-table'; +export { default as isHeader } from './is-header'; +export { default as isRowHeader } from './is-row-header'; +export { default as toGrid } from './to-grid'; +export { default as traverse } from './traverse'; - // This was the old name - toArray: toGrid -}; -commons.table = table; +// This was the old name +export { default as toArray } from './to-grid'; diff --git a/lib/commons/text/index.js b/lib/commons/text/index.js index 27b81230f0..15359848f1 100644 --- a/lib/commons/text/index.js +++ b/lib/commons/text/index.js @@ -1,60 +1,32 @@ -/* global text */ - -// TODO: es-module-commons. convert to: -// export { default as isAriaCombobox } from 'path' -import accessibleTextVirtual from './accessible-text-virtual'; -import accessibleText from './accessible-text'; -import formControlValue, { - formControlValueMethods -} from './form-control-value'; -import hasUnicode from './has-unicode'; -import isHumanInterpretable from './is-human-interpretable'; -import isIconLigature from './is-icon-ligature'; -import isValidAutocomplete, { autocomplete } from './is-valid-autocomplete'; -import labelText from './label-text'; -import labelVirtual from './label-virtual'; -import label from './label'; -import nativeElementType from './native-element-type'; -import nativeTextAlternative from './native-text-alternative'; -import nativeTextMethods from './native-text-methods'; -import removeUnicode from './remove-unicode'; -import sanitize from './sanitize'; -import subtreeText from './subtree-text'; -import titleText from './title-text'; -import unsupported from './unsupported'; -import visibleTextNodes from './visible-text-nodes'; -import visibleVirtual from './visible-virtual'; -import visible from './visible'; - /** * Namespace for text-related utilities. * @namespace text * @memberof axe.commons */ -// TODO: es-module-commons. don't rely on global -text = { - accessibleTextVirtual, - accessibleText, - formControlValue, - formControlValueMethods, - hasUnicode, - isHumanInterpretable, - isIconLigature, - isValidAutocomplete, - autocomplete, - labelText, - labelVirtual, - label, - nativeElementType, - nativeTextAlternative, - nativeTextMethods, - removeUnicode, - sanitize, - subtreeText, - titleText, - unsupported, - visibleTextNodes, - visibleVirtual, - visible -}; -commons.text = text; +export { default as accessibleTextVirtual } from './accessible-text-virtual'; +export { default as accessibleText } from './accessible-text'; +export { + default as formControlValue, + formControlValueMethods +} from './form-control-value'; +export { default as hasUnicode } from './has-unicode'; +export { default as isHumanInterpretable } from './is-human-interpretable'; +export { default as isIconLigature } from './is-icon-ligature'; +export { + default as isValidAutocomplete, + autocomplete +} from './is-valid-autocomplete'; +export { default as labelText } from './label-text'; +export { default as labelVirtual } from './label-virtual'; +export { default as label } from './label'; +export { default as nativeElementType } from './native-element-type'; +export { default as nativeTextAlternative } from './native-text-alternative'; +export { default as nativeTextMethods } from './native-text-methods'; +export { default as removeUnicode } from './remove-unicode'; +export { default as sanitize } from './sanitize'; +export { default as subtreeText } from './subtree-text'; +export { default as titleText } from './title-text'; +export { default as unsupported } from './unsupported'; +export { default as visibleTextNodes } from './visible-text-nodes'; +export { default as visibleVirtual } from './visible-virtual'; +export { default as visible } from './visible'; diff --git a/lib/commons/utils/index.js b/lib/commons/utils/index.js index 463e99c54d..bdc51109b9 100644 --- a/lib/commons/utils/index.js +++ b/lib/commons/utils/index.js @@ -1,12 +1,6 @@ -/* exported utils */ -/* global axe */ -/*eslint no-unused-vars: 0*/ /** * Namespace for general utilities. * @namespace utils * @memberof axe.commons */ - -const utils = (commons.utils = axe.utils); - -export default utils; +export default axe.utils; diff --git a/lib/core/base/audit.js b/lib/core/base/audit.js index 5c9e8a80f7..4fd8c80421 100644 --- a/lib/core/base/audit.js +++ b/lib/core/base/audit.js @@ -35,94 +35,6 @@ function unpackToObject(collection, audit, method) { } } -/** - * Constructor which holds configured rules and information about the document under test - */ -function Audit(audit) { - // defaults - this.brand = 'axe'; - this.application = 'axeAPI'; - this.tagExclude = ['experimental']; - this.lang = 'en'; - - this.defaultConfig = audit; - this._init(); - - // A copy of the "default" locale. This will be set if the user - // provides a new locale to `axe.configure()` and used to undo - // changes in `axe.reset()`. - this._defaultLocale = null; -} - -/** - * Build and set the previous locale. Will noop if a previous - * locale was already set, as we want the ability to "reset" - * to the default ("first") configuration. - */ - -Audit.prototype._setDefaultLocale = function() { - if (this._defaultLocale) { - return; - } - - const locale = { - checks: {}, - rules: {}, - failureSummaries: {}, - incompleteFallbackMessage: '', - lang: this.lang - }; - - // XXX: unable to use `for-of` here, as doing so would - // require us to polyfill `Symbol`. - const checkIDs = Object.keys(this.data.checks); - for (let i = 0; i < checkIDs.length; i++) { - const id = checkIDs[i]; - const check = this.data.checks[id]; - const { pass, fail, incomplete } = check.messages; - locale.checks[id] = { - pass, - fail, - incomplete - }; - } - - const ruleIDs = Object.keys(this.data.rules); - for (let i = 0; i < ruleIDs.length; i++) { - const id = ruleIDs[i]; - const rule = this.data.rules[id]; - const { description, help } = rule; - locale.rules[id] = { description, help }; - } - - const failureSummaries = Object.keys(this.data.failureSummaries); - for (let i = 0; i < failureSummaries.length; i++) { - const type = failureSummaries[i]; - const failureSummary = this.data.failureSummaries[type]; - const { failureMessage } = failureSummary; - locale.failureSummaries[type] = { failureMessage }; - } - - locale.incompleteFallbackMessage = this.data.incompleteFallbackMessage; - - this._defaultLocale = locale; -}; - -/** - * Reset the locale to the "default". - */ - -Audit.prototype._resetLocale = function() { - // If the default locale has not already been set, we can exit early. - const defaultLocale = this._defaultLocale; - if (!defaultLocale) { - return; - } - - // Apply the default locale - this.applyLocale(defaultLocale); -}; - /** * Merge two check locales (a, b), favoring `b`. * @@ -225,180 +137,480 @@ const mergeFallbackMessage = (a, b) => { }; /** - * Apply locale for the given `checks`. + * Constructor which holds configured rules and information about the document under test */ - -Audit.prototype._applyCheckLocale = function(checks) { - const keys = Object.keys(checks); - for (let i = 0; i < keys.length; i++) { - const id = keys[i]; - if (!this.data.checks[id]) { - throw new Error(`Locale provided for unknown check: "${id}"`); +class Audit { + constructor(audit) { + // defaults + this.brand = 'axe'; + this.application = 'axeAPI'; + this.tagExclude = ['experimental']; + this.lang = 'en'; + this.defaultConfig = audit; + this._init(); + // A copy of the "default" locale. This will be set if the user + // provides a new locale to `axe.configure()` and used to undo + // changes in `axe.reset()`. + this._defaultLocale = null; + } + /** + * Build and set the previous locale. Will noop if a previous + * locale was already set, as we want the ability to "reset" + * to the default ("first") configuration. + */ + _setDefaultLocale() { + if (this._defaultLocale) { + return; } - - this.data.checks[id] = mergeCheckLocale(this.data.checks[id], checks[id]); + const locale = { + checks: {}, + rules: {}, + failureSummaries: {}, + incompleteFallbackMessage: '', + lang: this.lang + }; + // XXX: unable to use `for-of` here, as doing so would + // require us to polyfill `Symbol`. + const checkIDs = Object.keys(this.data.checks); + for (let i = 0; i < checkIDs.length; i++) { + const id = checkIDs[i]; + const check = this.data.checks[id]; + const { pass, fail, incomplete } = check.messages; + locale.checks[id] = { + pass, + fail, + incomplete + }; + } + const ruleIDs = Object.keys(this.data.rules); + for (let i = 0; i < ruleIDs.length; i++) { + const id = ruleIDs[i]; + const rule = this.data.rules[id]; + const { description, help } = rule; + locale.rules[id] = { description, help }; + } + const failureSummaries = Object.keys(this.data.failureSummaries); + for (let i = 0; i < failureSummaries.length; i++) { + const type = failureSummaries[i]; + const failureSummary = this.data.failureSummaries[type]; + const { failureMessage } = failureSummary; + locale.failureSummaries[type] = { failureMessage }; + } + locale.incompleteFallbackMessage = this.data.incompleteFallbackMessage; + this._defaultLocale = locale; } -}; - -/** - * Apply locale for the given `rules`. - */ - -Audit.prototype._applyRuleLocale = function(rules) { - const keys = Object.keys(rules); - for (let i = 0; i < keys.length; i++) { - const id = keys[i]; - if (!this.data.rules[id]) { - throw new Error(`Locale provided for unknown rule: "${id}"`); + /** + * Reset the locale to the "default". + */ + _resetLocale() { + // If the default locale has not already been set, we can exit early. + const defaultLocale = this._defaultLocale; + if (!defaultLocale) { + return; } - this.data.rules[id] = mergeRuleLocale(this.data.rules[id], rules[id]); + // Apply the default locale + this.applyLocale(defaultLocale); } -}; - -/** - * Apply locale for the given failureMessage - */ - -Audit.prototype._applyFailureSummaries = function(messages) { - const keys = Object.keys(messages); - for (let i = 0; i < keys.length; i++) { - const key = keys[i]; - if (!this.data.failureSummaries[key]) { - throw new Error(`Locale provided for unknown failureMessage: "${key}"`); + /** + * Apply locale for the given `checks`. + */ + _applyCheckLocale(checks) { + const keys = Object.keys(checks); + for (let i = 0; i < keys.length; i++) { + const id = keys[i]; + if (!this.data.checks[id]) { + throw new Error(`Locale provided for unknown check: "${id}"`); + } + this.data.checks[id] = mergeCheckLocale(this.data.checks[id], checks[id]); } - this.data.failureSummaries[key] = mergeFailureMessage( - this.data.failureSummaries[key], - messages[key] - ); } -}; - -/** - * Apply the given `locale`. - * - * @param {axe.Locale} - */ - -Audit.prototype.applyLocale = function(locale) { - this._setDefaultLocale(); - - if (locale.checks) { - this._applyCheckLocale(locale.checks); + /** + * Apply locale for the given `rules`. + */ + _applyRuleLocale(rules) { + const keys = Object.keys(rules); + for (let i = 0; i < keys.length; i++) { + const id = keys[i]; + if (!this.data.rules[id]) { + throw new Error(`Locale provided for unknown rule: "${id}"`); + } + this.data.rules[id] = mergeRuleLocale(this.data.rules[id], rules[id]); + } } - - if (locale.rules) { - this._applyRuleLocale(locale.rules); + /** + * Apply locale for the given failureMessage + */ + _applyFailureSummaries(messages) { + const keys = Object.keys(messages); + for (let i = 0; i < keys.length; i++) { + const key = keys[i]; + if (!this.data.failureSummaries[key]) { + throw new Error(`Locale provided for unknown failureMessage: "${key}"`); + } + this.data.failureSummaries[key] = mergeFailureMessage( + this.data.failureSummaries[key], + messages[key] + ); + } } - - if (locale.failureSummaries) { - this._applyFailureSummaries(locale.failureSummaries, 'failureSummaries'); + /** + * Apply the given `locale`. + * + * @param {axe.Locale} + */ + applyLocale(locale) { + this._setDefaultLocale(); + if (locale.checks) { + this._applyCheckLocale(locale.checks); + } + if (locale.rules) { + this._applyRuleLocale(locale.rules); + } + if (locale.failureSummaries) { + this._applyFailureSummaries(locale.failureSummaries, 'failureSummaries'); + } + if (locale.incompleteFallbackMessage) { + this.data.incompleteFallbackMessage = mergeFallbackMessage( + this.data.incompleteFallbackMessage, + locale.incompleteFallbackMessage + ); + } + if (locale.lang) { + this.lang = locale.lang; + } } - - if (locale.incompleteFallbackMessage) { - this.data.incompleteFallbackMessage = mergeFallbackMessage( - this.data.incompleteFallbackMessage, - locale.incompleteFallbackMessage - ); + /** + * Initializes the rules and checks + */ + _init() { + var audit = getDefaultConfiguration(this.defaultConfig); + axe.commons = commons = audit.commons; + this.lang = audit.lang || 'en'; + this.reporter = audit.reporter; + this.commands = {}; + this.rules = []; + this.checks = {}; + unpackToObject(audit.rules, this, 'addRule'); + unpackToObject(audit.checks, this, 'addCheck'); + this.data = {}; + this.data.checks = (audit.data && audit.data.checks) || {}; + this.data.rules = (audit.data && audit.data.rules) || {}; + this.data.failureSummaries = + (audit.data && audit.data.failureSummaries) || {}; + this.data.incompleteFallbackMessage = + (audit.data && audit.data.incompleteFallbackMessage) || ''; + this._constructHelpUrls(); // create default helpUrls } - - if (locale.lang) { - this.lang = locale.lang; + /** + * Adds a new command to the audit + */ + registerCommand(command) { + 'use strict'; + this.commands[command.id] = command.callback; } -}; - -/** - * Initializes the rules and checks - */ -Audit.prototype._init = function() { - var audit = getDefaultConfiguration(this.defaultConfig); - - axe.commons = commons = audit.commons; - - this.lang = audit.lang || 'en'; - this.reporter = audit.reporter; - this.commands = {}; - this.rules = []; - this.checks = {}; - - unpackToObject(audit.rules, this, 'addRule'); - unpackToObject(audit.checks, this, 'addCheck'); - - this.data = {}; - this.data.checks = (audit.data && audit.data.checks) || {}; - this.data.rules = (audit.data && audit.data.rules) || {}; - this.data.failureSummaries = - (audit.data && audit.data.failureSummaries) || {}; - this.data.incompleteFallbackMessage = - (audit.data && audit.data.incompleteFallbackMessage) || ''; - - this._constructHelpUrls(); // create default helpUrls -}; - -/** - * Adds a new command to the audit - */ - -Audit.prototype.registerCommand = function(command) { - 'use strict'; - this.commands[command.id] = command.callback; -}; - -/** - * Adds a new rule to the Audit. If a rule with specified ID already exists, it will be overridden - * @param {Object} spec Rule specification object - */ -Audit.prototype.addRule = function(spec) { - 'use strict'; - - if (spec.metadata) { - this.data.rules[spec.id] = spec.metadata; + /** + * Adds a new rule to the Audit. If a rule with specified ID already exists, it will be overridden + * @param {Object} spec Rule specification object + */ + addRule(spec) { + 'use strict'; + if (spec.metadata) { + this.data.rules[spec.id] = spec.metadata; + } + let rule = this.getRule(spec.id); + if (rule) { + rule.configure(spec); + } else { + this.rules.push(new Rule(spec, this)); + } } - - let rule = this.getRule(spec.id); - if (rule) { - rule.configure(spec); - } else { - this.rules.push(new Rule(spec, this)); + /** + * Adds a new check to the Audit. If a Check with specified ID already exists, it will be + * reconfigured + * + * @param {Object} spec Check specification object + */ + addCheck(spec) { + /*eslint no-eval: 0 */ + 'use strict'; + let metadata = spec.metadata; + if (typeof metadata === 'object') { + this.data.checks[spec.id] = metadata; + // Transform messages into functions: + if (typeof metadata.messages === 'object') { + Object.keys(metadata.messages) + .filter( + prop => + metadata.messages.hasOwnProperty(prop) && + typeof metadata.messages[prop] === 'string' + ) + .forEach(prop => { + if (metadata.messages[prop].indexOf('function') === 0) { + metadata.messages[prop] = new Function( + 'return ' + metadata.messages[prop] + ';' + )(); + } + }); + } + } + if (this.checks[spec.id]) { + this.checks[spec.id].configure(spec); + } else { + this.checks[spec.id] = new Check(spec); + } } -}; - -/** - * Adds a new check to the Audit. If a Check with specified ID already exists, it will be - * reconfigured - * - * @param {Object} spec Check specification object - */ -Audit.prototype.addCheck = function(spec) { - /*eslint no-eval: 0 */ - 'use strict'; - let metadata = spec.metadata; - - if (typeof metadata === 'object') { - this.data.checks[spec.id] = metadata; - // Transform messages into functions: - if (typeof metadata.messages === 'object') { - Object.keys(metadata.messages) - .filter( - prop => - metadata.messages.hasOwnProperty(prop) && - typeof metadata.messages[prop] === 'string' - ) - .forEach(prop => { - if (metadata.messages[prop].indexOf('function') === 0) { - metadata.messages[prop] = new Function( - 'return ' + metadata.messages[prop] + ';' - )(); + /** + * Runs the Audit; which in turn should call `run` on each rule. + * @async + * @param {Context} context The scope definition/context for analysis (include/exclude) + * @param {Object} options Options object to pass into rules and/or disable rules or checks + * @param {Function} fn Callback function to fire when audit is complete + */ + run(context, options, resolve, reject) { + 'use strict'; + this.normalizeOptions(options); + axe._selectCache = []; + // get a list of rules to run NOW vs. LATER (later are preload assets dependent rules) + const allRulesToRun = getRulesToRun(this.rules, context, options); + const runNowRules = allRulesToRun.now; + const runLaterRules = allRulesToRun.later; + // init a NOW queue for rules to run immediately + const nowRulesQueue = axe.utils.queue(); + // construct can run NOW rules into NOW queue + runNowRules.forEach(rule => { + nowRulesQueue.defer(getDefferedRule(rule, context, options)); + }); + // init a PRELOADER queue to start preloading assets + const preloaderQueue = axe.utils.queue(); + // defer preload if preload dependent rules exist + if (runLaterRules.length) { + preloaderQueue.defer(resolve => { + // handle both success and fail of preload + // and resolve, to allow to run all checks + axe.utils + .preload(options) + .then(assets => resolve(assets)) + .catch(err => { + /** + * Note: + * we do not reject, to allow other (non-preload) rules to `run` + * -> instead we resolve as `undefined` + */ + console.warn(`Couldn't load preload assets: `, err); + resolve(undefined); + }); + }); + } + // defer now and preload queue to run immediately + const queueForNowRulesAndPreloader = axe.utils.queue(); + queueForNowRulesAndPreloader.defer(nowRulesQueue); + queueForNowRulesAndPreloader.defer(preloaderQueue); + // invoke the now queue + queueForNowRulesAndPreloader + .then(nowRulesAndPreloaderResults => { + // interpolate results into separate variables + const assetsFromQueue = nowRulesAndPreloaderResults.pop(); + if (assetsFromQueue && assetsFromQueue.length) { + // result is a queue (again), hence the index resolution + // assets is either an object of key value pairs of asset type and values + // eg: cssom: [stylesheets] + // or undefined if preload failed + const assets = assetsFromQueue[0]; + // extend context with preloaded assets + if (assets) { + context = { + ...context, + ...assets + }; + } + } + // the reminder of the results are RuleResults + const nowRulesResults = nowRulesAndPreloaderResults[0]; + // if there are no rules to run LATER - resolve with rule results + if (!runLaterRules.length) { + // remove the cache + axe._selectCache = undefined; + // resolve + resolve(nowRulesResults.filter(result => !!result)); + return; + } + // init a LATER queue for rules that are dependant on preloaded assets + const laterRulesQueue = axe.utils.queue(); + runLaterRules.forEach(rule => { + const deferredRule = getDefferedRule(rule, context, options); + laterRulesQueue.defer(deferredRule); + }); + // invoke the later queue + laterRulesQueue + .then(laterRuleResults => { + // remove the cache + axe._selectCache = undefined; + // resolve + resolve( + nowRulesResults + .concat(laterRuleResults) + .filter(result => !!result) + ); + }) + .catch(reject); + }) + .catch(reject); + } + /** + * Runs Rule `after` post processing functions + * @param {Array} results Array of RuleResults to postprocess + * @param {Mixed} options Options object to pass into rules and/or disable rules or checks + */ + after(results, options) { + 'use strict'; + var rules = this.rules; + return results.map(function(ruleResult) { + var rule = axe.utils.findBy(rules, 'id', ruleResult.id); + if (!rule) { + // If you see this, you're probably running the Mocha tests with the axe extension installed + throw new Error( + 'Result for unknown rule. You may be running mismatch axe-core versions' + ); + } + return rule.after(ruleResult, options); + }); + } + /** + * Get the rule with a given ID + * @param {string} + * @return {Rule} + */ + getRule(ruleId) { + return this.rules.find(rule => rule.id === ruleId); + } + /** + * Ensure all rules that are expected to run exist + * @throws {Error} If any tag or rule specified in options is unknown + * @param {Object} options Options object + * @return {Object} Validated options object + */ + normalizeOptions(options) { + 'use strict'; + var audit = this; + const tags = []; + const ruleIds = []; + audit.rules.forEach(rule => { + ruleIds.push(rule.id); + rule.tags.forEach(tag => { + if (!tags.includes(tag)) { + tags.push(tag); + } + }); + }); + // Validate runOnly + if (typeof options.runOnly === 'object') { + if (Array.isArray(options.runOnly)) { + const hasTag = options.runOnly.find(value => tags.includes(value)); + const hasRule = options.runOnly.find(value => ruleIds.includes(value)); + if (hasTag && hasRule) { + throw new Error('runOnly cannot be both rules and tags'); + } + if (hasRule) { + options.runOnly = { + type: 'rule', + values: options.runOnly + }; + } else { + options.runOnly = { + type: 'tag', + values: options.runOnly + }; + } + } + const only = options.runOnly; + if (only.value && !only.values) { + only.values = only.value; + delete only.value; + } + if (!Array.isArray(only.values) || only.values.length === 0) { + throw new Error('runOnly.values must be a non-empty array'); + } + // Check if every value in options.runOnly is a known rule ID + if (['rule', 'rules'].includes(only.type)) { + only.type = 'rule'; + only.values.forEach(function(ruleId) { + if (!ruleIds.includes(ruleId)) { + throw new Error('unknown rule `' + ruleId + '` in options.runOnly'); } }); + // Validate 'tags' (e.g. anything not 'rule') + } else if (['tag', 'tags', undefined].includes(only.type)) { + only.type = 'tag'; + const unmatchedTags = only.values.filter(tag => !tags.includes(tag)); + if (unmatchedTags.length !== 0) { + axe.log('Could not find tags `' + unmatchedTags.join('`, `') + '`'); + } + } else { + throw new Error(`Unknown runOnly type '${only.type}'`); + } + } + if (typeof options.rules === 'object') { + Object.keys(options.rules).forEach(function(ruleId) { + if (!ruleIds.includes(ruleId)) { + throw new Error('unknown rule `' + ruleId + '` in options.rules'); + } + }); } + return options; } - - if (this.checks[spec.id]) { - this.checks[spec.id].configure(spec); - } else { - this.checks[spec.id] = new Check(spec); + /* + * Updates the default options and then applies them + * @param {Mixed} options Options object + */ + setBranding(branding) { + 'use strict'; + let previous = { + brand: this.brand, + application: this.application + }; + if ( + branding && + branding.hasOwnProperty('brand') && + branding.brand && + typeof branding.brand === 'string' + ) { + this.brand = branding.brand; + } + if ( + branding && + branding.hasOwnProperty('application') && + branding.application && + typeof branding.application === 'string' + ) { + this.application = branding.application; + } + this._constructHelpUrls(previous); } -}; + _constructHelpUrls(previous = null) { + var version = (axe.version.match(/^[1-9][0-9]*\.[0-9]+/) || ['x.y'])[0]; + this.rules.forEach(rule => { + if (!this.data.rules[rule.id]) { + this.data.rules[rule.id] = {}; + } + let metaData = this.data.rules[rule.id]; + if ( + typeof metaData.helpUrl !== 'string' || + (previous && + metaData.helpUrl === getHelpUrl(previous, rule.id, version)) + ) { + metaData.helpUrl = getHelpUrl(this, rule.id, version); + } + }); + } + /** + * Reset the default rules, checks and meta data + */ + resetRulesAndChecks() { + 'use strict'; + this._init(); + this._resetLocale(); + } +} /** * Splits a given array of rules to two, with rules that can be run immediately and one's that are dependent on preloadedAssets @@ -489,258 +701,6 @@ function getDefferedRule(rule, context, options) { }; } -/** - * Runs the Audit; which in turn should call `run` on each rule. - * @async - * @param {Context} context The scope definition/context for analysis (include/exclude) - * @param {Object} options Options object to pass into rules and/or disable rules or checks - * @param {Function} fn Callback function to fire when audit is complete - */ -Audit.prototype.run = function(context, options, resolve, reject) { - 'use strict'; - - this.normalizeOptions(options); - axe._selectCache = []; - - // get a list of rules to run NOW vs. LATER (later are preload assets dependent rules) - const allRulesToRun = getRulesToRun(this.rules, context, options); - const runNowRules = allRulesToRun.now; - const runLaterRules = allRulesToRun.later; - - // init a NOW queue for rules to run immediately - const nowRulesQueue = axe.utils.queue(); - // construct can run NOW rules into NOW queue - runNowRules.forEach(rule => { - nowRulesQueue.defer(getDefferedRule(rule, context, options)); - }); - - // init a PRELOADER queue to start preloading assets - const preloaderQueue = axe.utils.queue(); - // defer preload if preload dependent rules exist - if (runLaterRules.length) { - preloaderQueue.defer(resolve => { - // handle both success and fail of preload - // and resolve, to allow to run all checks - axe.utils - .preload(options) - .then(assets => resolve(assets)) - .catch(err => { - /** - * Note: - * we do not reject, to allow other (non-preload) rules to `run` - * -> instead we resolve as `undefined` - */ - console.warn(`Couldn't load preload assets: `, err); - resolve(undefined); - }); - }); - } - - // defer now and preload queue to run immediately - const queueForNowRulesAndPreloader = axe.utils.queue(); - queueForNowRulesAndPreloader.defer(nowRulesQueue); - queueForNowRulesAndPreloader.defer(preloaderQueue); - - // invoke the now queue - queueForNowRulesAndPreloader - .then(nowRulesAndPreloaderResults => { - // interpolate results into separate variables - const assetsFromQueue = nowRulesAndPreloaderResults.pop(); - if (assetsFromQueue && assetsFromQueue.length) { - // result is a queue (again), hence the index resolution - // assets is either an object of key value pairs of asset type and values - // eg: cssom: [stylesheets] - // or undefined if preload failed - const assets = assetsFromQueue[0]; - // extend context with preloaded assets - if (assets) { - context = { - ...context, - ...assets - }; - } - } - - // the reminder of the results are RuleResults - const nowRulesResults = nowRulesAndPreloaderResults[0]; - - // if there are no rules to run LATER - resolve with rule results - if (!runLaterRules.length) { - // remove the cache - axe._selectCache = undefined; - // resolve - resolve(nowRulesResults.filter(result => !!result)); - return; - } - - // init a LATER queue for rules that are dependant on preloaded assets - const laterRulesQueue = axe.utils.queue(); - runLaterRules.forEach(rule => { - const deferredRule = getDefferedRule(rule, context, options); - laterRulesQueue.defer(deferredRule); - }); - // invoke the later queue - laterRulesQueue - .then(laterRuleResults => { - // remove the cache - axe._selectCache = undefined; - // resolve - resolve( - nowRulesResults.concat(laterRuleResults).filter(result => !!result) - ); - }) - .catch(reject); - }) - .catch(reject); -}; - -/** - * Runs Rule `after` post processing functions - * @param {Array} results Array of RuleResults to postprocess - * @param {Mixed} options Options object to pass into rules and/or disable rules or checks - */ -Audit.prototype.after = function(results, options) { - 'use strict'; - - var rules = this.rules; - - return results.map(function(ruleResult) { - var rule = axe.utils.findBy(rules, 'id', ruleResult.id); - if (!rule) { - // If you see this, you're probably running the Mocha tests with the axe extension installed - throw new Error( - 'Result for unknown rule. You may be running mismatch axe-core versions' - ); - } - - return rule.after(ruleResult, options); - }); -}; - -/** - * Get the rule with a given ID - * @param {string} - * @return {Rule} - */ -Audit.prototype.getRule = function(ruleId) { - return this.rules.find(rule => rule.id === ruleId); -}; - -/** - * Ensure all rules that are expected to run exist - * @throws {Error} If any tag or rule specified in options is unknown - * @param {Object} options Options object - * @return {Object} Validated options object - */ -Audit.prototype.normalizeOptions = function(options) { - 'use strict'; - var audit = this; - - const tags = []; - const ruleIds = []; - audit.rules.forEach(rule => { - ruleIds.push(rule.id); - rule.tags.forEach(tag => { - if (!tags.includes(tag)) { - tags.push(tag); - } - }); - }); - - // Validate runOnly - if (typeof options.runOnly === 'object') { - if (Array.isArray(options.runOnly)) { - const hasTag = options.runOnly.find(value => tags.includes(value)); - const hasRule = options.runOnly.find(value => ruleIds.includes(value)); - - if (hasTag && hasRule) { - throw new Error('runOnly cannot be both rules and tags'); - } - if (hasRule) { - options.runOnly = { - type: 'rule', - values: options.runOnly - }; - } else { - options.runOnly = { - type: 'tag', - values: options.runOnly - }; - } - } - const only = options.runOnly; - if (only.value && !only.values) { - only.values = only.value; - delete only.value; - } - - if (!Array.isArray(only.values) || only.values.length === 0) { - throw new Error('runOnly.values must be a non-empty array'); - } - - // Check if every value in options.runOnly is a known rule ID - if (['rule', 'rules'].includes(only.type)) { - only.type = 'rule'; - only.values.forEach(function(ruleId) { - if (!ruleIds.includes(ruleId)) { - throw new Error('unknown rule `' + ruleId + '` in options.runOnly'); - } - }); - - // Validate 'tags' (e.g. anything not 'rule') - } else if (['tag', 'tags', undefined].includes(only.type)) { - only.type = 'tag'; - const unmatchedTags = only.values.filter(tag => !tags.includes(tag)); - - if (unmatchedTags.length !== 0) { - axe.log('Could not find tags `' + unmatchedTags.join('`, `') + '`'); - } - } else { - throw new Error(`Unknown runOnly type '${only.type}'`); - } - } - - if (typeof options.rules === 'object') { - Object.keys(options.rules).forEach(function(ruleId) { - if (!ruleIds.includes(ruleId)) { - throw new Error('unknown rule `' + ruleId + '` in options.rules'); - } - }); - } - - return options; -}; - -/* - * Updates the default options and then applies them - * @param {Mixed} options Options object - */ - -Audit.prototype.setBranding = function(branding) { - 'use strict'; - let previous = { - brand: this.brand, - application: this.application - }; - if ( - branding && - branding.hasOwnProperty('brand') && - branding.brand && - typeof branding.brand === 'string' - ) { - this.brand = branding.brand; - } - if ( - branding && - branding.hasOwnProperty('application') && - branding.application && - typeof branding.application === 'string' - ) { - this.application = branding.application; - } - this._constructHelpUrls(previous); -}; - /** * For all the rules, create the helpUrl and add it to the data for that rule */ diff --git a/lib/core/base/check.js b/lib/core/base/check.js index dd4acd5c6d..b59f66d858 100644 --- a/lib/core/base/check.js +++ b/lib/core/base/check.js @@ -1,10 +1,14 @@ -/*global DqElement */ +/*global DqElement, metadataFunctionMap */ import CheckResult from './check-result'; export function createExecutionContext(spec) { /*eslint no-eval:0 */ if (typeof spec === 'string') { + if (metadataFunctionMap.has(spec)) { + return metadataFunctionMap.get(spec); + } + return new Function('return ' + spec + ';')(); } return spec; @@ -58,7 +62,7 @@ Check.prototype.enabled = true; * information for the check * @param {Function} callback Function to fire when check is complete */ -Check.prototype.run = function(node, options, context, resolve, reject) { +Check.prototype.run = function (node, options, context, resolve, reject) { 'use strict'; options = options || {}; var enabled = options.hasOwnProperty('enabled') @@ -90,7 +94,7 @@ Check.prototype.run = function(node, options, context, resolve, reject) { // possible reference error. if (node && node.actualNode) { // Save a reference to the node we errored on for futher debugging. - e.errorNode = new DqElement(node.actualNode).toJSON(); + e.errorNode = new axe.utils.DqElement(node.actualNode).toJSON(); } reject(e); return; @@ -111,7 +115,7 @@ Check.prototype.run = function(node, options, context, resolve, reject) { * @param {Object} options The options that override the defaults and provide additional * information for the check */ -Check.prototype.runSync = function(node, options, context) { +Check.prototype.runSync = function (node, options, context) { options = options || {}; const { enabled = this.enabled } = options; @@ -124,7 +128,7 @@ Check.prototype.runSync = function(node, options, context) { const checkHelper = axe.utils.checkHelper(checkResult, options); // throw error if a check is run that requires async behavior - checkHelper.async = function() { + checkHelper.async = function () { throw new Error('Cannot run async check while in a synchronous run'); }; @@ -144,7 +148,7 @@ Check.prototype.runSync = function(node, options, context) { // possible reference error. if (node && node.actualNode) { // Save a reference to the node we errored on for futher debugging. - e.errorNode = new DqElement(node.actualNode).toJSON(); + e.errorNode = new axe.utils.DqElement(node.actualNode).toJSON(); } throw e; } @@ -160,7 +164,7 @@ Check.prototype.runSync = function(node, options, context) { * @param {Object} spec - the specification of the attributes to be changed */ -Check.prototype.configure = function(spec) { +Check.prototype.configure = function (spec) { ['options', 'enabled'] .filter(prop => spec.hasOwnProperty(prop)) .forEach(prop => (this[prop] = spec[prop])); diff --git a/lib/core/base/context.js b/lib/core/base/context.js index 2294d63f64..a2fb553d77 100644 --- a/lib/core/base/context.js +++ b/lib/core/base/context.js @@ -1,4 +1,5 @@ /*global isNodeInContext */ + /** * Pushes a unique frame onto `frames` array, filtering any hidden iframes * @private @@ -237,7 +238,7 @@ function Context(spec) { this.exclude = parseSelectorArray(this, 'exclude'); axe.utils.select('frame, iframe', this).forEach(frame => { - if (isNodeInContext(frame, this)) { + if (axe.utils.isNodeInContext(frame, this)) { pushUniqueFrame(this.frames, frame.actualNode); } }); diff --git a/lib/core/base/metadata-function-map.js b/lib/core/base/metadata-function-map.js new file mode 100644 index 0000000000..9d4efd2d6f --- /dev/null +++ b/lib/core/base/metadata-function-map.js @@ -0,0 +1,9 @@ +/*eslint no-unused-vars:0*/ +// TODO: es-modules-checks +// TODO: es-modules-rules +// import all check evaluate and after functions, and all rule matches functions + +const metadataFunctionMap = new Map(); + +// TODO: es-modules-core +// export default metadataFunctionMap; diff --git a/lib/core/reporters/helpers/failure-summary.js b/lib/core/reporters/helpers/failure-summary.js index cb247c5521..4e2f24dd01 100644 --- a/lib/core/reporters/helpers/failure-summary.js +++ b/lib/core/reporters/helpers/failure-summary.js @@ -1,13 +1,9 @@ -/*global helpers */ - /** * Finds failing Checks and combines each help message into an array * @param {Object} nodeData Individual "detail" object to generate help messages for * @return {String} failure messages */ -helpers.failureSummary = function failureSummary(nodeData) { - 'use strict'; - +function failureSummary(nodeData) { var failingChecks = {}; // combine "all" and "none" as messaging is the same failingChecks.none = nodeData.none.concat(nodeData.all); @@ -32,4 +28,6 @@ helpers.failureSummary = function failureSummary(nodeData) { return i !== undefined; }) .join('\n\n'); -}; +} + +export default failureSummary; diff --git a/lib/core/reporters/helpers/get-environment-data.js b/lib/core/reporters/helpers/get-environment-data.js index dcce379d60..77f14b52c9 100644 --- a/lib/core/reporters/helpers/get-environment-data.js +++ b/lib/core/reporters/helpers/get-environment-data.js @@ -1,10 +1,8 @@ -/*global helpers */ - /** * Add information about the environment axe was run in. * @return {Object} */ -helpers.getEnvironmentData = function getEnvironmentData(win = window) { +function getEnvironmentData(win = window) { // TODO: remove parameter once we are testing axe-core in jsdom and other // supported environments const { @@ -36,4 +34,6 @@ helpers.getEnvironmentData = function getEnvironmentData(win = window) { timestamp: new Date().toISOString(), url: location.href }; -}; +} + +export default getEnvironmentData; diff --git a/lib/core/reporters/helpers/incomplete-fallback-msg.js b/lib/core/reporters/helpers/incomplete-fallback-msg.js index 60b7686a77..f2c61f1855 100644 --- a/lib/core/reporters/helpers/incomplete-fallback-msg.js +++ b/lib/core/reporters/helpers/incomplete-fallback-msg.js @@ -1,13 +1,12 @@ -/*global helpers */ - /** * Provides a fallback message in case incomplete checks don't provide one * This mechanism allows the string to be localized. * @return {String} */ -helpers.incompleteFallbackMessage = function incompleteFallbackMessage() { - 'use strict'; +function incompleteFallbackMessage() { return typeof axe._audit.data.incompleteFallbackMessage === 'function' ? axe._audit.data.incompleteFallbackMessage() : axe._audit.data.incompleteFallbackMessage; -}; +} + +export default incompleteFallbackMessage; diff --git a/lib/core/reporters/helpers/index.js b/lib/core/reporters/helpers/index.js index 38a2ffe12c..a1b4bed60d 100644 --- a/lib/core/reporters/helpers/index.js +++ b/lib/core/reporters/helpers/index.js @@ -1,3 +1,21 @@ -/*eslint no-unused-vars: 0*/ -/*exported helpers */ -var helpers = {}; +import failureSummary from './failure-summary'; +import getEnvironmentData from './get-environment-data'; +import incompleteFallbackMessage from './incomplete-fallback-msg'; +import processAggregate from './process-aggregate'; + +// Setting up this private/temp namespace for the tests (which cannot yet `import/export` things). +// TODO: remove `_thisWillBeDeletedDoNotUse` +axe._thisWillBeDeletedDoNotUse = axe._thisWillBeDeletedDoNotUse || {}; +axe._thisWillBeDeletedDoNotUse.helpers = { + failureSummary, + getEnvironmentData, + incompleteFallbackMessage, + processAggregate +}; + +export { + failureSummary, + getEnvironmentData, + incompleteFallbackMessage, + processAggregate +}; diff --git a/lib/core/reporters/helpers/process-aggregate.js b/lib/core/reporters/helpers/process-aggregate.js index 99331fea28..f265bb996e 100644 --- a/lib/core/reporters/helpers/process-aggregate.js +++ b/lib/core/reporters/helpers/process-aggregate.js @@ -1,6 +1,4 @@ -/*global helpers */ function normalizeRelatedNodes(node, options) { - 'use strict'; ['any', 'all', 'none'].forEach(type => { if (!Array.isArray(node[type])) { return; @@ -40,7 +38,7 @@ var resultKeys = axe.constants.resultGroups; */ /** - * Aggregrate and process the axe results, + * Aggregate and process the axe results, * adding desired data to nodes and relatedNodes in each rule result. * * Prepares result data for reporters. @@ -52,7 +50,7 @@ var resultKeys = axe.constants.resultGroups; * @return {Object} * */ -helpers.processAggregate = function(results, options) { +function processAggregate(results, options) { var resultObject = axe.utils.aggregateResult(results); resultKeys.forEach(function(key) { @@ -99,4 +97,6 @@ helpers.processAggregate = function(results, options) { }); return resultObject; -}; +} + +export default processAggregate; diff --git a/lib/core/reporters/na.js b/lib/core/reporters/na.js index 407b0cc85b..6b1716117d 100644 --- a/lib/core/reporters/na.js +++ b/lib/core/reporters/na.js @@ -1,8 +1,6 @@ -/*global helpers */ - -axe.addReporter('na', function(results, options, callback) { - 'use strict'; +import { processAggregate, getEnvironmentData } from './helpers'; +const naReporter = (results, options, callback) => { console.warn( '"na" reporter will be deprecated in axe v4.0. Use the "v2" reporter instead.' ); @@ -12,13 +10,15 @@ axe.addReporter('na', function(results, options, callback) { options = {}; } - var out = helpers.processAggregate(results, options); + var out = processAggregate(results, options); callback({ - ...helpers.getEnvironmentData(), + ...getEnvironmentData(), toolOptions: options, violations: out.violations, passes: out.passes, incomplete: out.incomplete, inapplicable: out.inapplicable }); -}); +}; + +export default naReporter; diff --git a/lib/core/reporters/no-passes.js b/lib/core/reporters/no-passes.js index ad94610494..ead0125b5e 100644 --- a/lib/core/reporters/no-passes.js +++ b/lib/core/reporters/no-passes.js @@ -1,6 +1,6 @@ -/*global helpers */ -axe.addReporter('no-passes', function(results, options, callback) { - 'use strict'; +import { processAggregate, getEnvironmentData } from './helpers'; + +const noPassesReporter = (results, options, callback) => { if (typeof options === 'function') { callback = options; options = {}; @@ -8,11 +8,13 @@ axe.addReporter('no-passes', function(results, options, callback) { // limit result processing to types we want to include in the output options.resultTypes = ['violations']; - var out = helpers.processAggregate(results, options); + var out = processAggregate(results, options); callback({ - ...helpers.getEnvironmentData(), + ...getEnvironmentData(), toolOptions: options, violations: out.violations }); -}); +}; + +export default noPassesReporter; diff --git a/lib/core/reporters/raw-env.js b/lib/core/reporters/raw-env.js index 092b549427..7193c5fc44 100644 --- a/lib/core/reporters/raw-env.js +++ b/lib/core/reporters/raw-env.js @@ -1,12 +1,17 @@ -/*global helpers */ -axe.addReporter('rawEnv', function(results, options, callback) { +import { getEnvironmentData } from './helpers'; +import rawReporter from './raw'; + +const rawEnvReporter = (results, options, callback) => { if (typeof options === 'function') { callback = options; options = {}; } function rawCallback(raw) { - const env = helpers.getEnvironmentData(); + const env = getEnvironmentData(); callback({ raw, env }); } - axe.getReporter('raw')(results, options, rawCallback); -}); + + rawReporter(results, options, rawCallback); +}; + +export default rawEnvReporter; diff --git a/lib/core/reporters/raw.js b/lib/core/reporters/raw.js index 8ceab31d3a..3800b821b2 100644 --- a/lib/core/reporters/raw.js +++ b/lib/core/reporters/raw.js @@ -1,6 +1,4 @@ -axe.addReporter('raw', function(results, options, callback) { - 'use strict'; - +const rawReporter = (results, options, callback) => { if (typeof options === 'function') { callback = options; options = {}; @@ -29,4 +27,6 @@ axe.addReporter('raw', function(results, options, callback) { }); callback(transformedResults); -}); +}; + +export default rawReporter; diff --git a/lib/core/reporters/reporters.js b/lib/core/reporters/reporters.js new file mode 100644 index 0000000000..6f43a4aa00 --- /dev/null +++ b/lib/core/reporters/reporters.js @@ -0,0 +1,13 @@ +import naReporter from './na'; +import noPassesReporter from './no-passes'; +import rawEnvReporter from './raw-env'; +import rawReporter from './raw'; +import v1Reporter from './v1'; +import v2Reporter from './v2'; + +axe.addReporter('na', naReporter); +axe.addReporter('no-passes', noPassesReporter); +axe.addReporter('rawEnv', rawEnvReporter); +axe.addReporter('raw', rawReporter); +axe.addReporter('v1', v1Reporter); +axe.addReporter('v2', v2Reporter, true); diff --git a/lib/core/reporters/v1.js b/lib/core/reporters/v1.js index ac1c137617..e5dfef5b91 100644 --- a/lib/core/reporters/v1.js +++ b/lib/core/reporters/v1.js @@ -1,17 +1,19 @@ -/*global helpers */ - -axe.addReporter('v1', function(results, options, callback) { - 'use strict'; +import { + processAggregate, + failureSummary, + getEnvironmentData +} from './helpers'; +const v1Reporter = (results, options, callback) => { if (typeof options === 'function') { callback = options; options = {}; } - var out = helpers.processAggregate(results, options); + var out = processAggregate(results, options); const addFailureSummaries = result => { result.nodes.forEach(nodeResult => { - nodeResult.failureSummary = helpers.failureSummary(nodeResult); + nodeResult.failureSummary = failureSummary(nodeResult); }); }; @@ -19,11 +21,13 @@ axe.addReporter('v1', function(results, options, callback) { out.violations.forEach(addFailureSummaries); callback({ - ...helpers.getEnvironmentData(), + ...getEnvironmentData(), toolOptions: options, violations: out.violations, passes: out.passes, incomplete: out.incomplete, inapplicable: out.inapplicable }); -}); +}; + +export default v1Reporter; diff --git a/lib/core/reporters/v2.js b/lib/core/reporters/v2.js index 50fc198ad3..0433b97a54 100644 --- a/lib/core/reporters/v2.js +++ b/lib/core/reporters/v2.js @@ -1,22 +1,19 @@ -/*global helpers */ +import { processAggregate, getEnvironmentData } from './helpers'; -axe.addReporter( - 'v2', - function(results, options, callback) { - 'use strict'; - if (typeof options === 'function') { - callback = options; - options = {}; - } - var out = helpers.processAggregate(results, options); - callback({ - ...helpers.getEnvironmentData(), - toolOptions: options, - violations: out.violations, - passes: out.passes, - incomplete: out.incomplete, - inapplicable: out.inapplicable - }); - }, - true -); +const v2Reporter = (results, options, callback) => { + if (typeof options === 'function') { + callback = options; + options = {}; + } + var out = processAggregate(results, options); + callback({ + ...getEnvironmentData(), + toolOptions: options, + violations: out.violations, + passes: out.passes, + incomplete: out.incomplete, + inapplicable: out.inapplicable + }); +}; + +export default v2Reporter; diff --git a/lib/core/utils/aggregateChecks.js b/lib/core/utils/aggregate-checks.js similarity index 92% rename from lib/core/utils/aggregateChecks.js rename to lib/core/utils/aggregate-checks.js index 2e54ab0657..40790d9ce9 100644 --- a/lib/core/utils/aggregateChecks.js +++ b/lib/core/utils/aggregate-checks.js @@ -1,3 +1,6 @@ +import aggregate from './aggregate'; + +// TODO: es-modules-constants const { CANTTELL_PRIO, FAIL_PRIO } = axe.constants; let checkMap = []; checkMap[axe.constants.PASS_PRIO] = true; @@ -15,7 +18,7 @@ function anyAllNone(obj, functor) { }, {}); } -axe.utils.aggregateChecks = function(nodeResOriginal) { +function aggregateChecks(nodeResOriginal) { // Create a copy let nodeResult = Object.assign({}, nodeResOriginal); @@ -66,7 +69,7 @@ axe.utils.aggregateChecks = function(nodeResOriginal) { // for failed nodes, define the impact if ([CANTTELL_PRIO, FAIL_PRIO].includes(nodeResult.priority)) { - nodeResult.impact = axe.utils.aggregate(axe.constants.impact, impacts); + nodeResult.impact = aggregate(axe.constants.impact, impacts); } else { nodeResult.impact = null; } @@ -82,4 +85,6 @@ axe.utils.aggregateChecks = function(nodeResOriginal) { delete nodeResult.priority; return nodeResult; -}; +} + +export default aggregateChecks; diff --git a/lib/core/utils/aggregate-node-results.js b/lib/core/utils/aggregate-node-results.js new file mode 100644 index 0000000000..bd9fc3451b --- /dev/null +++ b/lib/core/utils/aggregate-node-results.js @@ -0,0 +1,65 @@ +import aggregateChecks from './aggregate-checks'; +import aggregate from './aggregate'; +import finalizeRuleResult from './finalize-result'; + +/** + * Calculates the result of a Rule based on its types and the result of its child Checks + * @param {Array} nodeResults The array of nodes tested by the Rule + */ +function aggregateNodeResults(nodeResults) { + let ruleResult = {}; + + // For each node, retrieve the result and impact + nodeResults = nodeResults.map(function(nodeResult) { + // Known result + if (nodeResult.any && nodeResult.all && nodeResult.none) { + return aggregateChecks(nodeResult); + } else if (Array.isArray(nodeResult.node)) { + return finalizeRuleResult(nodeResult); + } else { + throw new TypeError('Invalid Result type'); + } + }); + + // Aggregate the result + // If there were no nodes passed in, mark the test as inapplicable + if (nodeResults && nodeResults.length) { + let resultList = nodeResults.map(node => node.result); + ruleResult.result = aggregate( + // TODO: es-modules-constants + axe.constants.results, + resultList, + ruleResult.result + ); + } else { + ruleResult.result = 'inapplicable'; + } + + // Create an array for each type + axe.constants.resultGroups.forEach(group => (ruleResult[group] = [])); + + // Fill the array with nodes + nodeResults.forEach(function(nodeResult) { + var groupName = axe.constants.resultGroupMap[nodeResult.result]; + ruleResult[groupName].push(nodeResult); + }); + + // Take the highest impact of failed or canttell rules + var impactGroup = axe.constants.FAIL_GROUP; + if (ruleResult[impactGroup].length === 0) { + impactGroup = axe.constants.CANTTELL_GROUP; + } + + if (ruleResult[impactGroup].length > 0) { + // Get the impact of all issues + let impactList = ruleResult[impactGroup].map(failure => failure.impact); + + ruleResult.impact = aggregate(axe.constants.impact, impactList) || null; + } else { + ruleResult.impact = null; + } + + return ruleResult; +} + +export default aggregateNodeResults; diff --git a/lib/core/utils/aggregateResult.js b/lib/core/utils/aggregate-result.js similarity index 91% rename from lib/core/utils/aggregateResult.js rename to lib/core/utils/aggregate-result.js index c7b5d6aaad..18e0092e02 100644 --- a/lib/core/utils/aggregateResult.js +++ b/lib/core/utils/aggregate-result.js @@ -1,6 +1,7 @@ function copyToGroup(resultObject, subResult, group) { var resultCopy = Object.assign({}, subResult); resultCopy.nodes = (resultCopy[group] || []).concat(); + // TODO: es-modules-constants axe.constants.resultGroups.forEach(group => { delete resultCopy[group]; }); @@ -11,7 +12,7 @@ function copyToGroup(resultObject, subResult, group) { * Calculates the result of a Rule based on its types and the result of its child Checks * @param {RuleResult} ruleResult The RuleResult to calculate the result of */ -axe.utils.aggregateResult = function(results) { +function aggregateResult(results) { let resultObject = {}; // Create an array for each type @@ -34,4 +35,6 @@ axe.utils.aggregateResult = function(results) { } }); return resultObject; -}; +} + +export default aggregateResult; diff --git a/lib/core/utils/aggregate.js b/lib/core/utils/aggregate.js index 138df31764..336355f0fd 100644 --- a/lib/core/utils/aggregate.js +++ b/lib/core/utils/aggregate.js @@ -7,7 +7,7 @@ * - values: Array of values to take the highest from * - initial: optional starting value */ -axe.utils.aggregate = function(map, values, initial) { +function aggregate(map, values, initial) { values = values.slice(); if (initial) { values.push(initial); @@ -16,4 +16,6 @@ axe.utils.aggregate = function(map, values, initial) { var sorting = values.map(val => map.indexOf(val)).sort(); // Stupid NodeJS array.sort functor doesn't work!! return map[sorting.pop()]; -}; +} + +export default aggregate; diff --git a/lib/core/utils/aggregateNodeResults.js b/lib/core/utils/aggregateNodeResults.js deleted file mode 100644 index 61fd83ebdf..0000000000 --- a/lib/core/utils/aggregateNodeResults.js +++ /dev/null @@ -1,61 +0,0 @@ -(function() { - /** - * Calculates the result of a Rule based on its types and the result of its child Checks - * @param {Array} nodeResults The array of nodes tested by the Rule - */ - axe.utils.aggregateNodeResults = function(nodeResults) { - let ruleResult = {}; - - // For each node, retrieve the result and impact - nodeResults = nodeResults.map(function(nodeResult) { - // Known result - if (nodeResult.any && nodeResult.all && nodeResult.none) { - return axe.utils.aggregateChecks(nodeResult); - } else if (Array.isArray(nodeResult.node)) { - return axe.utils.finalizeRuleResult(nodeResult); - } else { - throw new TypeError('Invalid Result type'); - } - }); - - // Aggregate the result - // If there were no nodes passed in, mark the test as inapplicable - if (nodeResults && nodeResults.length) { - let resultList = nodeResults.map(node => node.result); - ruleResult.result = axe.utils.aggregate( - axe.constants.results, - resultList, - ruleResult.result - ); - } else { - ruleResult.result = 'inapplicable'; - } - - // Create an array for each type - axe.constants.resultGroups.forEach(group => (ruleResult[group] = [])); - - // Fill the array with nodes - nodeResults.forEach(function(nodeResult) { - var groupName = axe.constants.resultGroupMap[nodeResult.result]; - ruleResult[groupName].push(nodeResult); - }); - - // Take the highest impact of failed or canttell rules - var impactGroup = axe.constants.FAIL_GROUP; - if (ruleResult[impactGroup].length === 0) { - impactGroup = axe.constants.CANTTELL_GROUP; - } - - if (ruleResult[impactGroup].length > 0) { - // Get the impact of all issues - let impactList = ruleResult[impactGroup].map(failure => failure.impact); - - ruleResult.impact = - axe.utils.aggregate(axe.constants.impact, impactList) || null; - } else { - ruleResult.impact = null; - } - - return ruleResult; - }; -})(); diff --git a/lib/core/utils/are-styles-set.js b/lib/core/utils/are-styles-set.js index 692d4a9903..3183aa1eeb 100644 --- a/lib/core/utils/are-styles-set.js +++ b/lib/core/utils/are-styles-set.js @@ -1,7 +1,4 @@ -/* global axe*/ - function areStylesSet(el, styles, stopAt) { - 'use strict'; var styl = window.getComputedStyle(el, null); if (!styl) { return false; @@ -18,4 +15,4 @@ function areStylesSet(el, styles, stopAt) { return areStylesSet(el.parentNode, styles, stopAt); } -axe.utils.areStylesSet = areStylesSet; +export default areStylesSet; diff --git a/lib/core/utils/assert.js b/lib/core/utils/assert.js index 4c4bccb171..27b5ddea09 100644 --- a/lib/core/utils/assert.js +++ b/lib/core/utils/assert.js @@ -1,12 +1,12 @@ -/* global axe*/ - /** - * If the first argument is falsey, throw an error using the second argument as a message. + * If the first argument is falsy, throw an error using the second argument as a message. * @param {boolean} bool * @param {string} message */ -axe.utils.assert = function assert(bool, message) { +function assert(bool, message) { if (!bool) { throw new Error(message); } -}; +} + +export default assert; diff --git a/lib/core/utils/check-helper.js b/lib/core/utils/check-helper.js index c492e523f2..5353ea0b17 100644 --- a/lib/core/utils/check-helper.js +++ b/lib/core/utils/check-helper.js @@ -1,17 +1,13 @@ +import toArray from './to-array'; +import DqElement from './dq-element'; + /** * Helper to denote which checks are asyncronous and provide callbacks and pass data back to the CheckResult * @param {CheckResult} checkResult The target object * @param {Function} callback The callback to expose when `this.async()` is called * @return {Object} Bound to `this` for a check's fn */ -axe.utils.checkHelper = function checkHelper( - checkResult, - options, - resolve, - reject -) { - 'use strict'; - +function checkHelper(checkResult, options, resolve, reject) { return { isAsync: false, async: function() { @@ -29,10 +25,12 @@ axe.utils.checkHelper = function checkHelper( checkResult.data = data; }, relatedNodes: function(nodes) { - nodes = nodes instanceof Node ? [nodes] : axe.utils.toArray(nodes); + nodes = nodes instanceof Node ? [nodes] : toArray(nodes); checkResult.relatedNodes = nodes.map(function(element) { - return new axe.utils.DqElement(element, options); + return new DqElement(element, options); }); } }; -}; +} + +export default checkHelper; diff --git a/lib/core/utils/clone.js b/lib/core/utils/clone.js index edcda7ea37..8e93180eb8 100644 --- a/lib/core/utils/clone.js +++ b/lib/core/utils/clone.js @@ -3,9 +3,8 @@ * @param {Mixed} obj The object/array to clone * @return {Mixed} A clone of the initial object or array */ -axe.utils.clone = function(obj) { +function clone(obj) { /* eslint guard-for-in: 0*/ - 'use strict'; var index, length, out = obj; @@ -14,14 +13,16 @@ axe.utils.clone = function(obj) { if (Array.isArray(obj)) { out = []; for (index = 0, length = obj.length; index < length; index++) { - out[index] = axe.utils.clone(obj[index]); + out[index] = clone(obj[index]); } } else { out = {}; for (index in obj) { - out[index] = axe.utils.clone(obj[index]); + out[index] = clone(obj[index]); } } } return out; -}; +} + +export default clone; diff --git a/lib/core/utils/closest.js b/lib/core/utils/closest.js index 355fc8cb40..5982b3938b 100644 --- a/lib/core/utils/closest.js +++ b/lib/core/utils/closest.js @@ -1,3 +1,5 @@ +import matches from './matches'; + /** * closest implementation that operates on a VirtualNode * @@ -7,9 +9,9 @@ * @param {String} selector CSS selector string * @return {Boolean} */ -axe.utils.closest = function closest(vNode, selector) { +function closest(vNode, selector) { while (vNode) { - if (axe.utils.matches(vNode, selector)) { + if (matches(vNode, selector)) { return vNode; } @@ -17,4 +19,6 @@ axe.utils.closest = function closest(vNode, selector) { } return null; -}; +} + +export default closest; diff --git a/lib/core/utils/collect-results-from-frames.js b/lib/core/utils/collect-results-from-frames.js index 2e911e9fa0..0c6161a6a7 100644 --- a/lib/core/utils/collect-results-from-frames.js +++ b/lib/core/utils/collect-results-from-frames.js @@ -1,66 +1,7 @@ -function err(message, node) { - 'use strict'; - var selector; - if (axe._tree) { - selector = axe.utils.getSelector(node); - } - return new Error(message + ': ' + (selector || node)); -} - -/** - * Sends a command to an instance of axe in the specified frame - * @param {Element} node The frame element to send the message to - * @param {Object} parameters Parameters to pass to the frame - * @param {Function} callback Function to call when results from the frame has returned - */ -axe.utils.sendCommandToFrame = function(node, parameters, resolve, reject) { - 'use strict'; - - var win = node.contentWindow; - if (!win) { - axe.log('Frame does not have a content window', node); - resolve(null); - return; - } - - // give the frame .5s to respond to 'axe.ping', else log failed response - var timeout = setTimeout(function() { - // This double timeout is important for allowing iframes to respond - // DO NOT REMOVE - timeout = setTimeout(function() { - if (!parameters.debug) { - resolve(null); - } else { - reject(err('No response from frame', node)); - } - }, 0); - }, 500); - - // send 'axe.ping' to the frame - axe.utils.respondable(win, 'axe.ping', null, undefined, function() { - clearTimeout(timeout); - - // Give axe 60s (or user-supplied value) to respond to 'axe.start' - var frameWaitTime = - (parameters.options && parameters.options.frameWaitTime) || 60000; - - timeout = setTimeout(function collectResultFramesTimeout() { - reject(err('Axe in frame timed out', node)); - }, frameWaitTime); - - // send 'axe.start' and send the callback if it responded - axe.utils.respondable(win, 'axe.start', parameters, undefined, function( - data - ) { - clearTimeout(timeout); - if (data instanceof Error === false) { - resolve(data); - } else { - reject(data); - } - }); - }); -}; +import queue from './queue'; +import sendCommandToFrame from './send-command-to-frame'; +import mergeResults from './merge-results'; +import getSelector from './get-selector'; /** * Sends a message to axe running in frames to start analysis and collate results (via `mergeResults`) @@ -79,9 +20,7 @@ function collectResultsFromFrames( resolve, reject ) { - 'use strict'; - - var q = axe.utils.queue(); + var q = queue(); var frames = context.frames; // Tell each axe running in each frame to collect results @@ -100,7 +39,7 @@ function collectResultsFromFrames( q.defer(function(res, rej) { var node = frame.node; - axe.utils.sendCommandToFrame( + sendCommandToFrame( node, params, function(data) { @@ -108,7 +47,7 @@ function collectResultsFromFrames( return res({ results: data, frameElement: node, - frame: axe.utils.getSelector(node) + frame: getSelector(node) }); } res(null); @@ -120,8 +59,8 @@ function collectResultsFromFrames( // Combine results from all frames and give it back q.then(function(data) { - resolve(axe.utils.mergeResults(data, options)); + resolve(mergeResults(data, options)); }).catch(reject); } -axe.utils.collectResultsFromFrames = collectResultsFromFrames; +export default collectResultsFromFrames; diff --git a/lib/core/utils/contains.js b/lib/core/utils/contains.js index 3ad7b2fb25..954dbaa72a 100644 --- a/lib/core/utils/contains.js +++ b/lib/core/utils/contains.js @@ -6,9 +6,9 @@ * @param {VirtualNode} otherVNode The vNode to test is contained by `vNode` * @return {Boolean} Whether `vNode` contains `otherVNode` */ -axe.utils.contains = function(vNode, otherVNode) { +function contains(vNode, otherVNode) { /*eslint no-bitwise: 0*/ - 'use strict'; + function containsShadowChild(vNode, otherVNode) { if (vNode.shadowId === otherVNode.shadowId) { return true; @@ -41,4 +41,6 @@ axe.utils.contains = function(vNode, otherVNode) { } return false; -}; +} + +export default contains; diff --git a/lib/core/utils/css-parser.js b/lib/core/utils/css-parser.js index 4a7ea1fc7b..3a04135a3d 100644 --- a/lib/core/utils/css-parser.js +++ b/lib/core/utils/css-parser.js @@ -1,7 +1,8 @@ -(function(axe) { - var parser = new axe.imports.CssSelectorParser(); - parser.registerSelectorPseudos('not'); - parser.registerNestingOperators('>'); - parser.registerAttrEqualityMods('^', '$', '*'); - axe.utils.cssParser = parser; -})(axe); +import { CssSelectorParser } from 'css-selector-parser'; + +const parser = new CssSelectorParser(); +parser.registerSelectorPseudos('not'); +parser.registerNestingOperators('>'); +parser.registerAttrEqualityMods('^', '$', '*'); + +export default parser; diff --git a/lib/core/utils/dq-element.js b/lib/core/utils/dq-element.js index 5270734eb3..7aa0154e96 100644 --- a/lib/core/utils/dq-element.js +++ b/lib/core/utils/dq-element.js @@ -1,4 +1,5 @@ -/*exported DqElement */ +import getSelector from './get-selector'; +import getXpath from './get-xpath'; function truncate(str, maxLength) { maxLength = maxLength || 300; @@ -54,9 +55,7 @@ DqElement.prototype = { * @return {String} */ get selector() { - return ( - this.spec.selector || [axe.utils.getSelector(this.element, this._options)] - ); + return this.spec.selector || [getSelector(this.element, this._options)]; }, /** @@ -64,7 +63,7 @@ DqElement.prototype = { * @return {String} */ get xpath() { - return this.spec.xpath || [axe.utils.getXpath(this.element)]; + return this.spec.xpath || [getXpath(this.element)]; }, /** @@ -91,7 +90,7 @@ DqElement.prototype = { DqElement.fromFrame = function(node, options, frame) { node.selector.unshift(frame.selector); node.xpath.unshift(frame.xpath); - return new axe.utils.DqElement(frame.element, options, node); + return new DqElement(frame.element, options, node); }; -axe.utils.DqElement = DqElement; +export default DqElement; diff --git a/lib/core/utils/element-matches.js b/lib/core/utils/element-matches.js index 711f1b7b9e..7854d7980f 100644 --- a/lib/core/utils/element-matches.js +++ b/lib/core/utils/element-matches.js @@ -4,9 +4,7 @@ * @param {String} selector The selector to test element against * @return {Boolean} */ -axe.utils.matchesSelector = (function() { - 'use strict'; - +const matchesSelector = (function() { var method; function getMethod(node) { @@ -41,3 +39,5 @@ axe.utils.matchesSelector = (function() { return false; }; })(); + +export default matchesSelector; diff --git a/lib/core/utils/escape-selector.js b/lib/core/utils/escape-selector.js index 4fe7da6679..ea3593fd04 100644 --- a/lib/core/utils/escape-selector.js +++ b/lib/core/utils/escape-selector.js @@ -5,8 +5,7 @@ * @param {String} value The piece of the selector to escape * @return {String} The escaped selector */ -axe.utils.escapeSelector = function(value) { - 'use strict'; +function escapeSelector(value) { /*eslint no-bitwise: 0, eqeqeq: 0, one-var: 0 */ var string = String(value); var length = string.length; @@ -75,4 +74,6 @@ axe.utils.escapeSelector = function(value) { result += '\\' + string.charAt(index); } return result; -}; +} + +export default escapeSelector; diff --git a/lib/core/utils/extend-meta-data.js b/lib/core/utils/extend-meta-data.js index 53420125b0..01fcccc81b 100644 --- a/lib/core/utils/extend-meta-data.js +++ b/lib/core/utils/extend-meta-data.js @@ -1,10 +1,9 @@ -/*eslint no-empty: 0*/ /** * Extends metadata onto result object and executes any functions * @param {Object} to The target of the extend * @param {Object} from Metadata to extend */ -axe.utils.extendMetaData = function(to, from) { +function extendMetaData(to, from) { Object.assign(to, from); Object.keys(from) .filter(prop => typeof from[prop] === 'function') @@ -12,6 +11,10 @@ axe.utils.extendMetaData = function(to, from) { to[prop] = null; try { to[prop] = from[prop](to); - } catch (e) {} + } catch (e) { + // Ignore + } }); -}; +} + +export default extendMetaData; diff --git a/lib/core/utils/finalize-result.js b/lib/core/utils/finalize-result.js index 6e0a77ca2a..d09bea915a 100644 --- a/lib/core/utils/finalize-result.js +++ b/lib/core/utils/finalize-result.js @@ -1,11 +1,15 @@ +import aggregateNodeResults from './aggregate-node-results'; + /** * Process rule results, grouping them by outcome * @param ruleResult {object} * @return {object} */ -axe.utils.finalizeRuleResult = function(ruleResult) { - Object.assign(ruleResult, axe.utils.aggregateNodeResults(ruleResult.nodes)); +function finalizeRuleResult(ruleResult) { + Object.assign(ruleResult, aggregateNodeResults(ruleResult.nodes)); delete ruleResult.nodes; return ruleResult; -}; +} + +export default finalizeRuleResult; diff --git a/lib/core/utils/find-by.js b/lib/core/utils/find-by.js index d5a91bb2fe..1d4e5569a8 100644 --- a/lib/core/utils/find-by.js +++ b/lib/core/utils/find-by.js @@ -7,8 +7,10 @@ * @param {Mixed} value The value to find * @return {Object} The first matching object or `undefined` if no match */ -axe.utils.findBy = function(array, key, value) { +function findBy(array, key, value) { if (Array.isArray(array)) { return array.find(obj => typeof obj === 'object' && obj[key] === value); } -}; +} + +export default findBy; diff --git a/lib/core/utils/get-all-checks.js b/lib/core/utils/get-all-checks.js index 1124255e01..f92bc2a5a3 100644 --- a/lib/core/utils/get-all-checks.js +++ b/lib/core/utils/get-all-checks.js @@ -2,11 +2,12 @@ * Gets all Checks (or CheckResults) for a given Rule or RuleResult * @param {RuleResult|Rule} rule */ -axe.utils.getAllChecks = function getAllChecks(object) { - 'use strict'; +function getAllChecks(object) { var result = []; return result .concat(object.any || []) .concat(object.all || []) .concat(object.none || []); -}; +} + +export default getAllChecks; diff --git a/lib/core/utils/get-base-lang.js b/lib/core/utils/get-base-lang.js index 5ee588d843..488347daf2 100644 --- a/lib/core/utils/get-base-lang.js +++ b/lib/core/utils/get-base-lang.js @@ -5,7 +5,7 @@ * @param {String} value value specified as lang or xml:lang attribute * @return {String} */ -axe.utils.getBaseLang = function getBaseLang(lang) { +function getBaseLang(lang) { if (!lang) { return ''; } @@ -13,4 +13,6 @@ axe.utils.getBaseLang = function getBaseLang(lang) { .trim() .split('-')[0] .toLowerCase(); -}; +} + +export default getBaseLang; diff --git a/lib/core/utils/get-check-message.js b/lib/core/utils/get-check-message.js index 461eed6035..20000be81a 100644 --- a/lib/core/utils/get-check-message.js +++ b/lib/core/utils/get-check-message.js @@ -1,4 +1,4 @@ -/* global axe*/ +import processMessage from './process-message'; /** * Get the pass, fail, or incomplete message for a check. @@ -7,7 +7,8 @@ * @param {Object} [data] The check data * @return {String} */ -axe.utils.getCheckMessage = function getCheckMessage(checkId, type, data) { +function getCheckMessage(checkId, type, data) { + // TODO: es-modules_audit const check = axe._audit.data.checks[checkId]; if (!check) { @@ -17,5 +18,7 @@ axe.utils.getCheckMessage = function getCheckMessage(checkId, type, data) { throw new Error(`Check "${checkId}"" does not have a "${type}" message.`); } - return axe.utils.processMessage(check.messages[type], data); -}; + return processMessage(check.messages[type], data); +} + +export default getCheckMessage; diff --git a/lib/core/utils/get-check-option.js b/lib/core/utils/get-check-option.js index ffb098afdc..f85f3cb282 100644 --- a/lib/core/utils/get-check-option.js +++ b/lib/core/utils/get-check-option.js @@ -5,7 +5,7 @@ * @param {Object} options Options object as passed to main API * @return {Object} The resolved object with `options` and `enabled` keys */ -axe.utils.getCheckOption = function(check, ruleID, options) { +function getCheckOption(check, ruleID, options) { var ruleCheckOption = (((options.rules && options.rules[ruleID]) || {}) .checks || {})[check.id]; var checkOption = (options.checks || {})[check.id]; @@ -36,4 +36,6 @@ axe.utils.getCheckOption = function(check, ruleID, options) { options: opts, absolutePaths: options.absolutePaths }; -}; +} + +export default getCheckOption; diff --git a/lib/core/utils/flattened-tree.js b/lib/core/utils/get-flattened-tree.js similarity index 90% rename from lib/core/utils/flattened-tree.js rename to lib/core/utils/get-flattened-tree.js index 0a2e8136f5..bdcc5ab64b 100644 --- a/lib/core/utils/flattened-tree.js +++ b/lib/core/utils/get-flattened-tree.js @@ -1,6 +1,5 @@ /* global VirtualNode */ -/*eslint no-use-before-define: 0*/ -var axe = axe || { utils: {} }; +import isShadowRoot from './is-shadow-root'; /** * This implemnts the flatten-tree algorithm specified: @@ -64,7 +63,7 @@ function flattenTree(node, shadowId, parent) { } nodeName = node.nodeName.toLowerCase(); - if (axe.utils.isShadowRoot(node)) { + if (isShadowRoot(node)) { // generate an ID for this shadow root and overwrite the current // closure shadowId with this value so that it cascades down the tree retVal = new VirtualNode(node, parent, shadowId); @@ -139,18 +138,10 @@ function flattenTree(node, shadowId, parent) { * @param {String} shadowId, optional ID of the shadow DOM that is the closest shadow * ancestor of the node */ -axe.utils.getFlattenedTree = function(node, shadowId) { +function getFlattenedTree(node, shadowId) { + // TODO: es-modules_cache axe._cache.set('nodeMap', new WeakMap()); return flattenTree(node, shadowId); -}; +} -/** - * Return a single node from the virtual dom tree - * - * @param {Object} vNode The flattened, virtual DOM tree - * @param {Node} node The HTML DOM node - */ -axe.utils.getNodeFromTree = function(vNode, node) { - const el = node || vNode; - return axe._cache.get('nodeMap') ? axe._cache.get('nodeMap').get(el) : null; -}; +export default getFlattenedTree; diff --git a/lib/core/utils/get-friendly-uri-end.js b/lib/core/utils/get-friendly-uri-end.js index eb5467fae7..ba9ba7c6f6 100644 --- a/lib/core/utils/get-friendly-uri-end.js +++ b/lib/core/utils/get-friendly-uri-end.js @@ -79,10 +79,7 @@ function uriParser(url) { * .maxLength Max length of the returned string (default: 25) * @return string A portion at the end of the uri, no longer than maxLength */ -axe.utils.getFriendlyUriEnd = function getFriendlyUriEnd( - uri = '', - options = {} -) { +function getFriendlyUriEnd(uri = '', options = {}) { if ( // Skip certain URIs: uri.length <= 1 || // very short @@ -141,4 +138,6 @@ axe.utils.getFriendlyUriEnd = function getFriendlyUriEnd( ) { return trimRight(pathEnd); } -}; +} + +export default getFriendlyUriEnd; diff --git a/lib/core/utils/get-node-attributes.js b/lib/core/utils/get-node-attributes.js index 675926d955..abae85d34b 100644 --- a/lib/core/utils/get-node-attributes.js +++ b/lib/core/utils/get-node-attributes.js @@ -1,5 +1,3 @@ -/* global axe */ - /** * Return the list of attributes of a node. * @method getNodeAttributes @@ -7,7 +5,7 @@ * @param {Element} node * @returns {NamedNodeMap} */ -axe.utils.getNodeAttributes = function getNodeAttributes(node) { +function getNodeAttributes(node) { // eslint-disable-next-line no-restricted-syntax if (node.attributes instanceof window.NamedNodeMap) { // eslint-disable-next-line no-restricted-syntax @@ -18,4 +16,6 @@ axe.utils.getNodeAttributes = function getNodeAttributes(node) { // has been clobbered. E.g.
. // We can clone the node to isolate it and then return the attributes return node.cloneNode(false).attributes; -}; +} + +export default getNodeAttributes; diff --git a/lib/core/utils/get-node-from-tree.js b/lib/core/utils/get-node-from-tree.js new file mode 100644 index 0000000000..1b3e657b8f --- /dev/null +++ b/lib/core/utils/get-node-from-tree.js @@ -0,0 +1,13 @@ +/** + * Return a single node from the virtual dom tree + * + * @param {Object} vNode The flattened, virtual DOM tree + * @param {Node} node The HTML DOM node + */ +function getNodeFromTree(vNode, node) { + const el = node || vNode; + // TODO: es-modules_cache + return axe._cache.get('nodeMap') ? axe._cache.get('nodeMap').get(el) : null; +} + +export default getNodeFromTree; diff --git a/lib/core/utils/get-root-node.js b/lib/core/utils/get-root-node.js index bd88f7d695..86fc320a64 100644 --- a/lib/core/utils/get-root-node.js +++ b/lib/core/utils/get-root-node.js @@ -1,5 +1,3 @@ -/* global axe */ - /** * Return the document or document fragment (shadow DOM) * @method getRootNode @@ -7,11 +5,13 @@ * @param {Element} node * @returns {DocumentFragment|Document} */ -axe.utils.getRootNode = function getRootNode(node) { +function getRootNode(node) { var doc = (node.getRootNode && node.getRootNode()) || document; // this is for backwards compatibility if (doc === node) { // disconnected node doc = document; } return doc; -}; +} + +export default getRootNode; diff --git a/lib/core/utils/scroll-state.js b/lib/core/utils/get-scroll-state.js similarity index 60% rename from lib/core/utils/scroll-state.js rename to lib/core/utils/get-scroll-state.js index 5e11cab6c7..9f05b04d45 100644 --- a/lib/core/utils/scroll-state.js +++ b/lib/core/utils/get-scroll-state.js @@ -1,14 +1,4 @@ -/** - * set the scroll position of an element - */ -function setScroll(elm, top, left) { - if (elm === window) { - return elm.scroll(left, top); - } else { - elm.scrollTop = top; - elm.scrollLeft = left; - } -} +import getScroll from './get-scroll'; /** * Create an array scroll positions from descending elements @@ -17,7 +7,7 @@ function getElmScrollRecursive(root) { // Need to also get .childNodes since SVGs in IE don't have .children. return Array.from(root.children || root.childNodes || []).reduce( (scrolls, elm) => { - const scroll = axe.utils.getScroll(elm); + const scroll = getScroll(elm); if (scroll) { scrolls.push(scroll); } @@ -30,7 +20,7 @@ function getElmScrollRecursive(root) { /** * Get the scroll position of all scrollable elements in a page */ -axe.utils.getScrollState = function getScrollState(win = window) { +function getScrollState(win = window) { const root = win.document.documentElement; const windowScroll = [ win.pageXOffset !== undefined @@ -47,11 +37,6 @@ axe.utils.getScrollState = function getScrollState(win = window) { ]; return windowScroll.concat(getElmScrollRecursive(document.body)); -}; +} -/** - * set the scroll position of all items in the scrollState array - */ -axe.utils.setScrollState = function setScrollState(scrollState) { - scrollState.forEach(({ elm, top, left }) => setScroll(elm, top, left)); -}; +export default getScrollState; diff --git a/lib/core/utils/get-scroll.js b/lib/core/utils/get-scroll.js index 8782aa9cf3..39b8ded823 100644 --- a/lib/core/utils/get-scroll.js +++ b/lib/core/utils/get-scroll.js @@ -6,7 +6,7 @@ * @param {buffer} (Optional) allowed negligence in overflow * @returns {Object | undefined} */ -axe.utils.getScroll = function getScroll(elm, buffer = 0) { +function getScroll(elm, buffer = 0) { const overflowX = elm.scrollWidth > elm.clientWidth + buffer; const overflowY = elm.scrollHeight > elm.clientHeight + buffer; @@ -36,4 +36,6 @@ axe.utils.getScroll = function getScroll(elm, buffer = 0) { left: elm.scrollLeft }; } -}; +} + +export default getScroll; diff --git a/lib/core/utils/get-selector.js b/lib/core/utils/get-selector.js index d4bbf20698..d93e13f917 100644 --- a/lib/core/utils/get-selector.js +++ b/lib/core/utils/get-selector.js @@ -1,5 +1,10 @@ -const escapeSelector = axe.utils.escapeSelector; -let isXHTML; +import escapeSelector from './escape-selector'; +import getFriendlyUriEnd from './get-friendly-uri-end'; +import getNodeAttributes from './get-node-attributes'; +import matchesSelector from './element-matches'; +import isXHTML from './is-xhtml'; + +let xhtml; const ignoredAttributes = [ 'class', 'style', @@ -32,7 +37,7 @@ function getAttributeNameValue(node, at) { let atnv; if (name.indexOf('href') !== -1 || name.indexOf('src') !== -1) { - let friendly = axe.utils.getFriendlyUriEnd(node.getAttribute(name)); + let friendly = getFriendlyUriEnd(node.getAttribute(name)); if (friendly) { let value = encodeURI(friendly); if (value) { @@ -78,7 +83,7 @@ function filterAttributes(at) { * one for tags and one for attributes. The map values are * the counts for how many elements with that feature exist */ -axe.utils.getSelectorData = function(domTree) { +export function getSelectorData(domTree) { /* eslint no-loop-func:0*/ // Initialize the return structure with the three maps @@ -120,7 +125,7 @@ axe.utils.getSelectorData = function(domTree) { // count all the filtered attributes if (node.hasAttributes()) { - Array.from(axe.utils.getNodeAttributes(node)) + Array.from(getNodeAttributes(node)) .filter(filterAttributes) .forEach(at => { let atnv = getAttributeNameValue(node, at); @@ -144,7 +149,7 @@ axe.utils.getSelectorData = function(domTree) { } } return data; -}; +} /** * Given a node and the statistics on class frequency on the page, @@ -185,7 +190,7 @@ function getNthChildString(elm, selector) { const siblings = (elm.parentNode && Array.from(elm.parentNode.children || '')) || []; const hasMatchingSiblings = siblings.find( - sibling => sibling !== elm && axe.utils.matchesSelector(sibling, selector) + sibling => sibling !== elm && matchesSelector(sibling, selector) ); if (hasMatchingSiblings) { const nthChild = 1 + siblings.indexOf(elm); @@ -220,10 +225,10 @@ function getElmId(elm) { * @return {String|Array