UNPKG

accessibility-checker

Version:

An automated testing tools for accessibility testing using Puppeteer, Selenium, or Zombie

130 lines (126 loc) 4.17 kB
/****************************************************************************** Copyright:: 2020- IBM, Inc Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *****************************************************************************/ import { IMapResult } from "./IMapper"; export declare enum eRuleLevel { violation = "violation", potentialviolation = "potentialviolation", recommendation = "recommendation", potentialrecommendation = "potentialrecommendation", manual = "manual", pass = "pass", ignored = "ignored" } export declare enum eRuleConfidence { PASS = "PASS", FAIL = "FAIL", POTENTIAL = "POTENTIAL", MANUAL = "MANUAL" } export declare enum eRulePolicy { VIOLATION = "VIOLATION", RECOMMENDATION = "RECOMMENDATION", INFORMATION = "INFORMATION" } export declare enum eToolkitLevel { LEVEL_ONE = "1", LEVEL_TWO = "2", LEVEL_THREE = "3", LEVEL_FOUR = "4" } export declare enum eRuleCategory { ACCESSIBILITY = "Accessibility", DESIGN = "Design", OTHER = "Other" } export declare function RulePass(reasonId: number | string, messageArgs?: string[], apiArgs?: any[]): RuleResult; export declare function RuleRender(reasonId: number | string, messageArgs?: string[], apiArgs?: any[]): RuleResult; export declare function RuleFail(reasonId: number | string, messageArgs?: string[], apiArgs?: any[]): RuleResult; export declare function RulePotential(reasonId: number | string, messageArgs?: string[], apiArgs?: any[]): RuleResult; export declare function RuleManual(reasonId: number | string, messageArgs?: string[], apiArgs?: any[]): RuleResult; export type RuleResult = { value: [eRulePolicy, eRuleConfidence]; reasonId?: number | string; messageArgs?: string[]; apiArgs?: any[]; }; export type RuleDetails = RuleResult & { ruleId: string; node: Node; category?: eRuleCategory; path: { [ns: string]: string; }; ruleTime: number; message: string; bounds?: { top: number; left: number; width: number; height: number; }; snippet: string; ignored?: boolean; level?: eRuleLevel; }; export type RuleContextHierarchy = { [namespace: string]: IMapResult[]; }; export type RuleContext = { [namespace: string]: IMapResult; }; export type Rule = { id: string; context: string; refactor?: { [oldRuleId: string]: { [oldReasonCode: string]: string; }; }; dependencies?: string[]; run: (context: RuleContext, options?: {}, contextHierarchies?: RuleContextHierarchy) => RuleResult | RuleResult[]; enabled?: boolean; }; export type Report = { results: RuleDetails[]; numExecuted: number; ruleTime: number; totalTime?: number; nls?: { [ruleId: string]: { [reasonId: string]: string; }; }; }; export type NlsMap = { [key: string]: string[]; }; export type HelpMap = { [key: string]: string[]; }; export interface IEngine { /** * Perform a scan on a document or subtree * @param rulesetIds Array of ruleset ids of rulesets to use for this scan * @param root Document or subtree to scan */ run(root: Document | Node, options?: {}): Promise<Report>; enableRules(ruleIds: string[]): any; getRule(ruleId: string): Rule; getRulesIds(): string[]; getMessage(ruleId: string, ruleIdx: number | string, msgArgs?: string[]): string; getHelp(ruleId: string, ruleIdx: number | string): string; addRules(rule: Rule[]): any; addRule(rule: Rule): any; addNlsMap(map: NlsMap): any; addHelpMap(map: NlsMap): any; }