-
Notifications
You must be signed in to change notification settings - Fork 2
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
0 parents
commit 00cc1a5
Showing
13 changed files
with
6,717 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
root: true, | ||
parser: "@typescript-eslint/parser", | ||
plugins: ["@typescript-eslint", "prettier"], | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier", | ||
], | ||
rules: { | ||
"prettier/prettier": "error", | ||
}, | ||
}; |
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,3 @@ | ||
node_modules | ||
dist | ||
.DS_Store |
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,8 @@ | ||
{ | ||
"tabWidth": 4, | ||
"semi": true, | ||
"singleQuote": false, | ||
"quoteProps": "consistent", | ||
"printWidth": 80, | ||
"endOfLine": "auto" | ||
} |
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,9 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright 2023 Stack Exchange Inc. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,85 @@ | ||
# axe-apca | ||
|
||
This package contains custom axe rules and checks for [APCA](https://readtech.org/) Bronze and Silver+ [conformance levels](https://readtech.org/ARC/tests/visual-readability-contrast/?tn=criterion). | ||
|
||
## Usage | ||
|
||
### Installation | ||
|
||
```bash | ||
npm install --save-dev axe-core axe-apca | ||
``` | ||
|
||
### Setup | ||
|
||
```js | ||
import axe from "axe-core"; | ||
import { registerAxeAPCA } from 'axe-apca'; | ||
|
||
registerAxeAPCA('bronze'); // or registerAxeAPCA('silver'); | ||
|
||
// consider turning off default WCAG 2.2 AA color contrast rules when using APCA | ||
axe.configure({ | ||
rules: [{ id: "color-contrast", enabled: false }] | ||
}) | ||
|
||
axe.run(document, (err, results) => { | ||
if (err) throw err; | ||
console.log(results); | ||
}); | ||
``` | ||
|
||
### Using custom APCA thresholds | ||
|
||
To set custom thresholds for APCA checks, follow these steps: | ||
|
||
1. Use `custom` as the first argument when calling `registerAxeAPCA`. | ||
1. Provide a function as the second argument, optionally accepting `fontSize` and `fontWeight` arguments. | ||
|
||
|
||
```js | ||
const customConformanceThresholdFn = (fontSize, fontWeight) => { | ||
const size = parseFloat(fontSize); | ||
const weight = parseFloat(fontWeight); | ||
|
||
return size >= 32 || weight > 700 ? 45 : 60; | ||
}; | ||
|
||
registerAxeAPCA('custom', customConformanceThresholdFn); | ||
``` | ||
|
||
## Development | ||
|
||
### Prerequisites | ||
|
||
- Node.js v18+ | ||
|
||
### Linting | ||
To run eslint (including prettier as a formatter) you can run | ||
``` | ||
npm run lint | ||
``` | ||
To have eslint fix any autofixable issue run | ||
``` | ||
npm run lint:fix | ||
``` | ||
|
||
### Testing | ||
|
||
Tests are run by web-test-runner in combination with playwright against chromium, firefox and webkit | ||
|
||
``` | ||
npm run test | ||
``` | ||
|
||
For watch mode | ||
``` | ||
npm run test:watch | ||
``` | ||
|
||
### Publishing | ||
|
||
TBC | ||
|
||
## License | ||
Copyright 2023 Stack Exchange, Inc and released under the [MIT License](/LICENSE.MD). |
Oops, something went wrong.