@accesslint/core 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -18
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -34,16 +34,6 @@ npm install @accesslint/core
|
|
|
34
34
|
|
|
35
35
|
## Quick start
|
|
36
36
|
|
|
37
|
-
```js
|
|
38
|
-
import { runAudit } from "@accesslint/core";
|
|
39
|
-
|
|
40
|
-
const result = runAudit(document);
|
|
41
|
-
|
|
42
|
-
for (const violation of result.violations) {
|
|
43
|
-
console.log(violation.ruleId, violation.message, violation.selector);
|
|
44
|
-
}
|
|
45
|
-
```
|
|
46
|
-
|
|
47
37
|
### Playwright
|
|
48
38
|
|
|
49
39
|
Inject the library into the page and audit the live DOM:
|
|
@@ -51,21 +41,18 @@ Inject the library into the page and audit the live DOM:
|
|
|
51
41
|
```ts
|
|
52
42
|
// a11y.spec.ts
|
|
53
43
|
import { test, expect } from "@playwright/test";
|
|
54
|
-
import { createRequire } from "module";
|
|
55
44
|
|
|
56
|
-
const
|
|
45
|
+
const iife = require.resolve("@accesslint/core/iife");
|
|
57
46
|
|
|
58
47
|
test("page has no accessibility violations", async ({ page }) => {
|
|
59
48
|
await page.goto("https://example.com");
|
|
60
49
|
|
|
61
|
-
await page.addScriptTag({
|
|
62
|
-
path: require.resolve("@accesslint/core/dist/index.iife.js"),
|
|
63
|
-
});
|
|
50
|
+
await page.addScriptTag({ path: iife });
|
|
64
51
|
|
|
65
52
|
const violations = await page.evaluate(() => {
|
|
66
53
|
const { runAudit } = (window as any).AccessLintCore;
|
|
67
54
|
return runAudit(document).violations.map(
|
|
68
|
-
(
|
|
55
|
+
(v: any) => ({ ruleId: v.ruleId, message: v.message, selector: v.selector, impact: v.impact })
|
|
69
56
|
);
|
|
70
57
|
});
|
|
71
58
|
|
|
@@ -80,8 +67,7 @@ Inject the library into the page and audit the live DOM:
|
|
|
80
67
|
```js
|
|
81
68
|
// cypress/support/commands.js
|
|
82
69
|
Cypress.Commands.add("audit", () => {
|
|
83
|
-
|
|
84
|
-
cy.readFile(script).then((src) => {
|
|
70
|
+
cy.readFile("node_modules/@accesslint/core/dist/index.iife.js").then((src) => {
|
|
85
71
|
cy.window().then((win) => {
|
|
86
72
|
win.eval(src);
|
|
87
73
|
const { runAudit } = win.AccessLintCore;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@accesslint/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Pure accessibility rule engine — WCAG audit with zero browser dependencies",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"import": "./dist/index.js",
|
|
13
13
|
"require": "./dist/index.cjs"
|
|
14
|
-
}
|
|
14
|
+
},
|
|
15
|
+
"./iife": "./dist/index.iife.js"
|
|
15
16
|
},
|
|
16
17
|
"files": [
|
|
17
18
|
"dist"
|