-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add axe-config-generator package (#6395)
#### Details Add a `axe-config-generator` package, which generates an `axe-config.json` file containing the current [ScanOptions](https://www.deque.com/axe/core-documentation/api-documentation/#options-parameter) we provide to axe.run for fastpass scans. ##### Motivation Keep tool in centralized location ##### Context We have been noticing confusion from users about how/ why the set of rules that the web extension uses differs from the set of rules that axe-core provides. This tool is the first step in increasing clarity about which rules the extension is running. #### Pull request checklist <!-- If a checklist item is not applicable to this change, write "n/a" in the checkbox --> - [n/a] Addresses an existing issue: #0000 - [x] Ran `yarn fastpass` - [n/a] Added/updated relevant unit test(s) (and ran `yarn test`) - [n/a] Verified code coverage for the changes made. Check coverage report at: `<rootDir>/test-results/unit/coverage` - [x] PR title *AND* final merge commit title both start with a semantic tag (`fix:`, `chore:`, `feat(feature-name):`, `refactor:`). See `CONTRIBUTING.md`. - [n/a] (UI changes only) Added screenshots/GIFs to description above - [n/a] (UI changes only) Verified usability with NVDA/JAWS
- Loading branch information
Showing
8 changed files
with
129 additions
and
0 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<!-- | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the MIT License. | ||
--> | ||
|
||
# @accessibility-insights/axe-config | ||
|
||
This library provides the [axe core run options](https://www.deque.com/axe/core-documentation/api-documentation/#options-parameter) currently used by default in Accessibility Insights for Web extension FastPass scans. | ||
|
||
## Contributing | ||
|
||
To contribute, please visit [accessibility-insights-web](https://github.com/microsoft/accessibility-insights-web/blob/main/README.md) for more information. | ||
|
||
### Code of Conduct | ||
|
||
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). | ||
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or | ||
contact [[email protected]](mailto:[email protected]) with any additional questions or comments. |
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,5 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
const axeScanOptions = require('./axe-config.json'); | ||
exports.axeScanOptions = axeScanOptions; |
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,20 @@ | ||
{ | ||
"name": "@accessibility-insights/axe-config", | ||
"version": "1.0.0", | ||
"description": "Provides the current axe-core run options used by Accessibility Insights for Web for FastPass scans.", | ||
"license": "MIT", | ||
"files": [ | ||
"../../LICENSE", | ||
"drop", | ||
"README.md" | ||
], | ||
"main": "drop/index.js", | ||
"scripts": { | ||
"build": "grunt build-axe-config" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Microsoft/accessibility-insights-web" | ||
}, | ||
"dependencies": {} | ||
} |
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,7 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
const baseConfig = require('../../prettier.config'); | ||
|
||
module.exports = { | ||
...baseConfig, | ||
}; |
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,30 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import * as axe from 'axe-core'; | ||
import * as fs from 'fs'; | ||
import * as path from 'path'; | ||
import { explicitRuleOverrides, getRuleInclusions } from 'scanner/get-rule-inclusions'; | ||
import { ScanParameterGenerator } from 'scanner/scan-parameter-generator'; | ||
|
||
const defaultConfigFilePath = path.join(__dirname, '../../../drop/axe-config.json'); | ||
const configFilePath = process.argv[2] || defaultConfigFilePath; | ||
|
||
const generateAxeConfig = () => { | ||
console.log('Generating axe config file...'); | ||
|
||
const ruleIncludedStatus = getRuleInclusions(axe._audit.rules, explicitRuleOverrides); | ||
const scanParameterGenerator = new ScanParameterGenerator(ruleIncludedStatus); | ||
const scanOptions = scanParameterGenerator.getAxeEngineOptions({}); | ||
const config = JSON.stringify(scanOptions, null, '\t'); | ||
|
||
console.log(`Writing config to ${configFilePath}...`); | ||
if (!fs.existsSync(path.dirname(configFilePath))) { | ||
fs.mkdirSync(path.dirname(configFilePath)); | ||
} | ||
fs.writeFileSync(configFilePath, config); | ||
|
||
console.log('Finished generating axe config file.'); | ||
}; | ||
|
||
generateAxeConfig(); |