Skip to content

Commit f097f3a

Browse files
committed
fix(types): More detailed typescript support
1 parent e81c653 commit f097f3a

File tree

2 files changed

+154
-24
lines changed

2 files changed

+154
-24
lines changed

Diff for: index.d.ts

+149-20
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,161 @@
11
import { PluginFunction } from 'vue';
22

3-
interface RunOptions {
4-
clearConsole: boolean;
5-
element: Document | HTMLElement;
3+
export interface RunOptions {
4+
clearConsole: boolean;
5+
element: Document | HTMLElement;
66
}
77

8-
export interface VueAxe
9-
{
10-
run({ clearConsole, element }: RunOptions): void;
8+
export interface AxeConfig {
9+
/**
10+
* mixed(optional) Used to set the branding of the helpUrls
11+
*/
12+
branding?: {
13+
/**
14+
* string(optional) sets the brand string - default "axe"
15+
*/
16+
brand?: string,
17+
/**
18+
* string(optional) sets the application string - default "axeAPI"
19+
*/
20+
application?: string
21+
},
22+
/**
23+
* Used to set the output format that the axe.run function will pass to the callback function
24+
*/
25+
reporter?: string,
26+
/**
27+
* Used to add checks to the list of checks used by rules, or to override the properties of existing checks
28+
*/
29+
checks?: any,
30+
/**
31+
* Used to add rules to the existing set of rules, or to override the properties of existing rules
32+
*/
33+
rules?: any,
34+
/**
35+
* A locale object to apply (at runtime) to all rules and checks, in the same shape as /locales/*.json.
36+
*/
37+
locale?: any,
38+
/**
39+
* 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
40+
*/
41+
axeVersion?: string
42+
}
43+
44+
export interface AxeRunOptions {
45+
/**
46+
* Limit which rules are executed, based on names or tags
47+
*/
48+
runOnly?: any,
49+
/**
50+
* Allow customizing a rule's properties (including { enable: false })
51+
*/
52+
rules?: any,
53+
/**
54+
* Which reporter to use
55+
*/
56+
reporter?: string,
57+
/**
58+
* Limit which result types are processed and aggregated
59+
*/
60+
resultTypes?: any,
61+
/**
62+
* Return xpath selectors for elements
63+
*/
64+
xpath?: boolean,
65+
/**
66+
* Use absolute paths when creating element selectors
67+
*/
68+
absolutePaths?: boolean,
69+
/**
70+
* Tell axe to run inside iframes
71+
*/
72+
iframes?: boolean,
73+
/**
74+
* Return element references in addition to the target
75+
*/
76+
elementRef?: boolean,
77+
/**
78+
* Scrolls elements back to before axe started
79+
*/
80+
restoreScroll?: boolean,
81+
/**
82+
* How long (in milliseconds) axe waits for a response from embedded frames before timing out
83+
*/
84+
frameWaitTime?: number,
85+
/**
86+
* Any additional assets (eg: cssom) to preload before running rules
87+
*/
88+
preload?: boolean,
89+
/**
90+
* Log rule performance metrics to the console
91+
*/
92+
performanceTimer?: boolean,
93+
}
94+
95+
export interface VueAxeStyle {
96+
head?: string,
97+
boldCourier?: string,
98+
moderate?: string,
99+
critical?: string,
100+
serious?: string,
101+
minor?: string,
102+
title?: string,
103+
url?: string
104+
}
105+
106+
export interface VueAxeOptions {
107+
/**
108+
* Disables automatic verification. Only checks with $axe.run
109+
*/
110+
auto?: boolean,
111+
/**
112+
* Clears the console each time vue-axe runs
113+
*/
114+
clearConsoleOnUpdate?: boolean,
115+
/**
116+
* Provide your Axe-core configuration
117+
*/
118+
config?: AxeConfig,
119+
/**
120+
* Provide your Axe-core runtime options
121+
*/
122+
runOptions?: AxeRunOptions,
123+
/**
124+
* Used to delay the first check. - `Millisecond`
125+
*/
126+
delay?: number
127+
/**
128+
*
129+
*/
130+
style?: VueAxeStyle,
131+
/**
132+
* Register Axe plugins
133+
*/
134+
plugins?: any[],
135+
/**
136+
* Handle the results. (This may be needed for automated tests)
137+
*/
138+
customResultHandler?: (error: any, results: any),
139+
}
140+
141+
export interface VueAxe {
142+
run({ clearConsole, element }: RunOptions): void;
11143

12-
plugins: Record<string, any>;
144+
plugins: Record<string, any>;
13145

14-
clearConsole(forceClear: boolean): void;
15-
16-
debounce(): void;
146+
clearConsole(forceClear: boolean): void;
147+
148+
debounce(): void;
17149
}
18150

19-
declare module 'vue/types/vue'
20-
{
21-
interface Vue
22-
{
23-
$axe: VueAxe;
24-
}
151+
declare module 'vue/types/vue' {
152+
interface Vue {
153+
$axe: VueAxe;
154+
}
25155
}
26156

27-
export declare class VueAxe
28-
{
29-
static install: PluginFunction<never>;
157+
declare class VueAxePlugin {
158+
static install: PluginFunction<VueAxeOptions>;
30159
}
31160

32-
export default VueAxe;
161+
export default VueAxePlugin;

Diff for: package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
"name": "vue-axe",
33
"version": "2.1.1",
44
"description": "Dynamic accessibility analysis for Vue.js using axe-core",
5-
"main": "dist/vue-axe.umd.js",
6-
"module": "dist/vue-axe.esm.js",
7-
"unpkg": "dist/vue-axe.min.js",
5+
"main": "./dist/vue-axe.umd.js",
6+
"module": "./dist/vue-axe.esm.js",
7+
"unpkg": "./dist/vue-axe.min.js",
8+
"types": "./index.d.ts",
89
"scripts": {
910
"dev": "rollup --config rollup.config.dev.js --watch",
1011
"build": "npm run build:umd & npm run build:es & npm run build:unpkg",
@@ -15,7 +16,7 @@
1516
"test:e2e": "node_modules/.bin/cypress run --headless",
1617
"test:e2e:open": "node_modules/.bin/cypress open",
1718
"project:publish": "git push --follow-tags origin master && npm publish",
18-
"deploy": "surge ./demo https://vue-axe.surge.sh/"
19+
"deploy": "surge ./demo/dist https://vue-axe.surge.sh/"
1920
},
2021
"repository": {
2122
"type": "git",

0 commit comments

Comments
 (0)