UNPKG

website-auditfy

Version:

> Tool for validate your project on SEO, HTML, CSS, JS, TS, Performance, Security and A11Y

138 lines 5.64 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.A11yAudit = void 0; const puppeteer_1 = __importDefault(require("puppeteer")); const puppeteer_2 = require("@axe-core/puppeteer"); const message_model_1 = require("../../models/message.model"); const message_enum_1 = require("../../enum/message.enum"); const audit_model_1 = require("../../models/audit.model"); class A11yAudit extends audit_model_1.Audit { constructor(source, dom, lightHouse, htmlValidator) { super(); this.dom = dom; this.source = source; this.lighthouse = lightHouse; this.htmlValidator = htmlValidator; this.name = 'A11Y'; } check() { return __awaiter(this, void 0, void 0, function* () { const browser = yield puppeteer_1.default.launch({ headless: true, args: ['--no-sandbox', '--disable-setuid-sandbox'] }); const page = yield browser.newPage(); const path = this.source.isURL ? this.source.url : this.source.file.pathWithExtension; yield page.goto(path); const results = yield new puppeteer_2.AxePuppeteer(page).withRules([ 'td-has-header', 'table-fake-caption', 'p-as-heading', 'label-content-name-mismatch', 'hidden-content', 'focus-order-semantics', 'meta-refresh-no-exceptions', 'identical-links-same-purpose', 'table-duplicate-name', 'skip-link', 'tabindex', 'scope-attr-valid', 'region', 'presentation-role-conflict', 'meta-viewport-large', 'landmark-unique', 'landmark-one-main', 'landmark-no-duplicate-main', 'landmark-no-duplicate-contentinfo', 'landmark-no-duplicate-banner', 'landmark-main-is-top-level', 'landmark-contentinfo-is-top-level', 'landmark-complementary-is-top-level', 'landmark-banner-is-top-level', 'target-size', 'link-in-text-block', 'duplicate-id-aria', 'aria-allowed-attr', 'aria-braille-equivalent', 'aria-command-name', 'aria-conditional-attr', 'aria-deprecated-role', 'aria-hidden-focus', 'aria-input-field-name', 'aria-meter-name', 'aria-progressbar-name', 'aria-prohibited-attr', 'aria-required-attr', 'aria-required-children', 'aria-required-parent', 'aria-roles', 'aria-toggle-field-name', 'aria-tooltip-name', 'aria-valid-attr-value', 'aria-valid-attr', 'button-name', 'bypass', 'color-contrast', 'color-contrast-enhanced', 'definition-list', 'dlitem', 'frame-focusable-content', 'frame-title-unique', 'frame-title', 'html-has-lang', 'html-xml-lang-mismatch', 'input-button-name', 'input-image-alt', 'list', 'listitem', 'marquee', 'meta-viewport', 'nested-interactive', 'object-alt', 'role-img-alt', 'scrollable-region-focusable', 'select-name', 'server-side-image-map', 'summary-name', 'svg-img-alt', 'td-headers-attr', 'th-has-data-cells', 'valid-lang', 'video-caption', 'avoid-inline-spacing', // Best Practices Rules 'accesskeys', 'aria-allowed-role', 'aria-dialog-name', 'aria-text', 'aria-treeitem-name', 'empty-table-header', 'frame-tested', 'image-redundant-alt', 'label-title-only', 'css-orientation-lock' ]).analyze(); yield page.close(); yield browser.close(); const messages = []; messages.push(...results.violations.map(v => { return message_model_1.Message.create(v.help, message_enum_1.MessageType.warning); })); return messages; }); } } exports.A11yAudit = A11yAudit; //# sourceMappingURL=a11y.js.map