Skip to content

Commit

Permalink
fix(types): More detailed typescript support
Browse files Browse the repository at this point in the history
  • Loading branch information
ktquez committed May 31, 2020
1 parent e81c653 commit f097f3a
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 24 deletions.
169 changes: 149 additions & 20 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,161 @@
import { PluginFunction } from 'vue';

interface RunOptions {
clearConsole: boolean;
element: Document | HTMLElement;
export interface RunOptions {
clearConsole: boolean;
element: Document | HTMLElement;
}

export interface VueAxe
{
run({ clearConsole, element }: RunOptions): void;
export interface AxeConfig {
/**
* mixed(optional) Used to set the branding of the helpUrls
*/
branding?: {
/**
* string(optional) sets the brand string - default "axe"
*/
brand?: string,
/**
* string(optional) sets the application string - default "axeAPI"
*/
application?: string
},
/**
* Used to set the output format that the axe.run function will pass to the callback function
*/
reporter?: string,
/**
* Used to add checks to the list of checks used by rules, or to override the properties of existing checks
*/
checks?: any,
/**
* Used to add rules to the existing set of rules, or to override the properties of existing rules
*/
rules?: any,
/**
* A locale object to apply (at runtime) to all rules and checks, in the same shape as /locales/*.json.
*/
locale?: any,
/**
* Set the compatible version of a custom rule with the current axe version. Compatible versions are all patch and minor updates that are the same as, or newer than those of the `axeVersion` property
*/
axeVersion?: string
}

export interface AxeRunOptions {
/**
* Limit which rules are executed, based on names or tags
*/
runOnly?: any,
/**
* Allow customizing a rule's properties (including { enable: false })
*/
rules?: any,
/**
* Which reporter to use
*/
reporter?: string,
/**
* Limit which result types are processed and aggregated
*/
resultTypes?: any,
/**
* Return xpath selectors for elements
*/
xpath?: boolean,
/**
* Use absolute paths when creating element selectors
*/
absolutePaths?: boolean,
/**
* Tell axe to run inside iframes
*/
iframes?: boolean,
/**
* Return element references in addition to the target
*/
elementRef?: boolean,
/**
* Scrolls elements back to before axe started
*/
restoreScroll?: boolean,
/**
* How long (in milliseconds) axe waits for a response from embedded frames before timing out
*/
frameWaitTime?: number,
/**
* Any additional assets (eg: cssom) to preload before running rules
*/
preload?: boolean,
/**
* Log rule performance metrics to the console
*/
performanceTimer?: boolean,
}

export interface VueAxeStyle {
head?: string,
boldCourier?: string,
moderate?: string,
critical?: string,
serious?: string,
minor?: string,
title?: string,
url?: string
}

export interface VueAxeOptions {
/**
* Disables automatic verification. Only checks with $axe.run
*/
auto?: boolean,
/**
* Clears the console each time vue-axe runs
*/
clearConsoleOnUpdate?: boolean,
/**
* Provide your Axe-core configuration
*/
config?: AxeConfig,
/**
* Provide your Axe-core runtime options
*/
runOptions?: AxeRunOptions,
/**
* Used to delay the first check. - `Millisecond`
*/
delay?: number
/**
*
*/
style?: VueAxeStyle,
/**
* Register Axe plugins
*/
plugins?: any[],
/**
* Handle the results. (This may be needed for automated tests)
*/
customResultHandler?: (error: any, results: any),
}

export interface VueAxe {
run({ clearConsole, element }: RunOptions): void;

plugins: Record<string, any>;
plugins: Record<string, any>;

clearConsole(forceClear: boolean): void;
debounce(): void;
clearConsole(forceClear: boolean): void;

debounce(): void;
}

declare module 'vue/types/vue'
{
interface Vue
{
$axe: VueAxe;
}
declare module 'vue/types/vue' {
interface Vue {
$axe: VueAxe;
}
}

export declare class VueAxe
{
static install: PluginFunction<never>;
declare class VueAxePlugin {
static install: PluginFunction<VueAxeOptions>;
}

export default VueAxe;
export default VueAxePlugin;
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"name": "vue-axe",
"version": "2.1.1",
"description": "Dynamic accessibility analysis for Vue.js using axe-core",
"main": "dist/vue-axe.umd.js",
"module": "dist/vue-axe.esm.js",
"unpkg": "dist/vue-axe.min.js",
"main": "./dist/vue-axe.umd.js",
"module": "./dist/vue-axe.esm.js",
"unpkg": "./dist/vue-axe.min.js",
"types": "./index.d.ts",
"scripts": {
"dev": "rollup --config rollup.config.dev.js --watch",
"build": "npm run build:umd & npm run build:es & npm run build:unpkg",
Expand All @@ -15,7 +16,7 @@
"test:e2e": "node_modules/.bin/cypress run --headless",
"test:e2e:open": "node_modules/.bin/cypress open",
"project:publish": "git push --follow-tags origin master && npm publish",
"deploy": "surge ./demo https://vue-axe.surge.sh/"
"deploy": "surge ./demo/dist https://vue-axe.surge.sh/"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit f097f3a

Please sign in to comment.