Skip to content

Instantly share code, notes, and snippets.

@DanielRosenwasser
Forked from marcysutton/axe-core.d.ts
Last active July 19, 2016 00:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanielRosenwasser/1ff72a78965b9790af0cc3426fdc53b7 to your computer and use it in GitHub Desktop.
Save DanielRosenwasser/1ff72a78965b9790af0cc3426fdc53b7 to your computer and use it in GitHub Desktop.
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?: any[],
exclude?: any[],
}
interface RunOnly {
type?: string,
values?: Tags[],
rules?: any,
}
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?: string[],
all?: string[],
none?: string[],
tags?: string[],
matches?: string
}
interface Plugin {
id: string,
run: () => any,
commands: {
id: string,
callback: () => void
}[]
}
declare namespace 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?: any}, callback: Function): any
export function a11yCheck(context: any, options: any, callback:() => void): any
/**
* 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: any[]): any[]
/**
* 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