Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Typescript attempt #1
// Type definitions for axe-core 2.0.5
// Project: https://github.com/dequelabs/axe-core
// Definitions by: Marcy Sutton <https://github.com/marcysutton>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare const enum Tags {"wcag2a", "wcag2aa", "section508", "best-practice"}
declare const enum Reporter {"v1", "v2"}
interface ElementContext {
node?: any,
selector?: string,
include?: Array<any>,
exclude?: Array<any>,
}
interface RunOnly {
type?: string,
values?: Array<Tags>,
rules?: Object,
}
interface Spec {
branding?: {
brand: string,
application: string
},
reporter?: Reporter,
checks?: Checks,
rules?: Rules
}
interface Checks {
id: string,
evaluate: Function,
after?: Function,
options?: any,
matches?: string,
enabled?: boolean
}
interface Rules {
id: string,
selector? :string,
excludeHidden?: boolean,
enabled?: boolean,
pageLevel?: boolean,
any?: Array<string>,
all?: Array<string>,
none?: Array<string>,
tags?: Array<string>,
matches?: string
}
interface Plugin {
id: string,
run: () => any,
commands: [{
id: string,
callback: () => void
}]
}
declare var axe {
/**
* Starts analysis on the current document and its subframes
*
* @param {Object} context The `Context` specification object @see Context
* @param {Array} options Options passed into rules or checks, temporarily modifyint them.
* @param {Function} callback The function to invoke when analysis is complete.
*/
//export function a11yCheck(context:ElementContext, options:{runOnly?:RunOnly, rules?: Object}, callback:Function): Object
export function a11yCheck(context:any, options:Object, callback:() => void): Object
/**
* Method for configuring the data format used by aXe. Helpful for adding new
* rules, which must be registered with the library to execute.
* @param {Object} spec Object with valid `branding`, `reporter`, `checks` and `rules` data
*/
export function configure(spec:Spec): void
/**
* Searches and returns rules that contain a tag in the list of tags.
* @param {Array} tags Optional array of tags
* @return {Array} Array of rules
*/
export function getRules(tags:Array<Tags>): Array<Object>
/**
* Restores the default axe configuration
*/
export function reset(): void
/**
* Function to register a plugin configuration in document and its subframes
* @param {Object} plugin A plugin configuration object
*/
export function registerPlugin(plugin:{Plugin}): void
/**
* Function to clean up plugin configuration in document and its subframes
*/
export function cleanup(): void
}
export = axe;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.