-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
1,267 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,7 @@ chrome-extension | |
|
||
# build custom extension | ||
build-extension.js | ||
build-rules.js | ||
|
||
# data dir | ||
_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,4 @@ build | |
_tests | ||
./test-results | ||
_data | ||
|
||
./screenshot.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,7 @@ async function launchBench() { | |
unit: "OPS/S", | ||
value: 1000 / avg, | ||
}, | ||
]) | ||
]), | ||
); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,7 @@ async function launchBench() { | |
unit: "OPS/S", | ||
value: 1000 / avg, | ||
}, | ||
]) | ||
]), | ||
); | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { chromium } from "playwright"; | ||
import { Standard, kayle } from "kayle"; | ||
import { writeFile } from "fs/promises"; | ||
import { format } from "prettier"; | ||
|
||
type Rule = { | ||
ruleId: string; | ||
description?: string; | ||
help?: string; | ||
helpUrl?: string; | ||
tags?: string[]; | ||
actIds?: string[]; | ||
}; | ||
|
||
(async () => { | ||
const browser = await chromium.launch({ headless: true }); | ||
const page = await browser.newPage(); | ||
|
||
const fast_htmlcs_rules: Rule[] = []; | ||
const fast_axe_rules: Rule[] = []; | ||
|
||
// inject the scripts | ||
await kayle( | ||
{ | ||
page, | ||
browser, | ||
runners: ["htmlcs", "axe"], | ||
html: "<html><body>><h1>Build Rules list</h1></body></html>", | ||
standard: Standard.WCAG2AA, | ||
origin: "https://www.example.com", | ||
}, | ||
true, | ||
); | ||
|
||
await page.exposeFunction("pushHtmlcsRule", (t: Rule) => { | ||
fast_htmlcs_rules.push(t); | ||
}); | ||
|
||
await page.exposeFunction("pushAxeRule", (t: Rule) => { | ||
fast_axe_rules.push(t); | ||
}); | ||
|
||
await page.evaluate(() => { | ||
// @ts-ignore | ||
for (const r of window.axe.getRules()) { | ||
// @ts-ignore we need to get the rules description and urls. | ||
window.pushAxeRule(r); | ||
} | ||
for (const k of Object.keys(window)) { | ||
if (k.startsWith("HTMLCS_WCAG2AAA_Sniffs_Principle")) { | ||
// @ts-ignore | ||
window.pushHtmlcsRule({ | ||
ruleId: k, | ||
}); | ||
} | ||
} | ||
}); | ||
|
||
const pConfig = { | ||
singleQuote: true, | ||
semi: false, | ||
parser: "babel", | ||
}; | ||
|
||
const DNE = "THIS FILE WAS CREATED DYNAMICALLY - DO NOT EDIT"; | ||
|
||
await writeFile( | ||
"./lib/rules/htmlcs-rules.ts", | ||
Buffer.from( | ||
await format( | ||
`/* ${DNE} */\nexport const htmlcsRules = ${JSON.stringify( | ||
fast_htmlcs_rules, | ||
)};`, | ||
pConfig, | ||
), | ||
), | ||
"utf8", | ||
); | ||
|
||
await writeFile( | ||
"./lib/rules/axe-rules.ts", | ||
Buffer.from( | ||
await format( | ||
`/* ${DNE} */\nexport const axeRules = ${JSON.stringify( | ||
fast_axe_rules, | ||
)};`, | ||
pConfig, | ||
), | ||
), | ||
"utf8", | ||
); | ||
|
||
await browser.close(); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.