Config file
In dev mode, AMA components try to enforce some accessibility requirements by showing an error banner and printing the reason when a rule is broken. For example, missing accessibility label, poor color contrast, minimum size not met, etc.
Conscious that there might be edge cases where a rule or two might need to be broken, AMA provides a way to change the logging level of each guideline tested.
info
The library does not perform any accessibility check on the production build!
The log levels
AMA guidelines are categorised as:
- MUST and MUST_NOT: Those best practices are enforced and AMA overlays an error when fail
- SHOULD and SHOULD_NOT: Those best practices are preferred and AMA prints only prints a warning message when fail
Default Rules
Log key | Guideline |
---|---|
BOTTOM_SHEET_CLOSE_ACTION | MUST |
CONTRAST_FAILED | MUST |
CONTRAST_FAILED_AAA | SHOULD |
FLATLIST_NO_COUNT_IN_SINGULAR_MESSAGE | SHOULD |
FLATLIST_NO_COUNT_IN_PLURAL_MESSAGE | MUST |
MINIMUM_SIZE | MUST |
NO_ACCESSIBILITY_LABEL1 | MUST |
NO_ACCESSIBILITY_ROLE 1 | MUST |
NO_FORM_LABEL | MUST |
NO_FORM_ERROR | MUST |
NO_KEYBOARD_TRAP 1 | MUST_NOT |
UPPERCASE_TEXT_NO_ACCESSIBILITY_LABEL | MUST_NOT |
NO_UPPERCASE_TEXT | MUST_NOT |
Constants
Elements that perform a contrast check do it on all the children up to the level specified by CONTRAST_CHECKER_MAX_DEPTH
.
Constant key | Default value |
---|---|
CONTRAST_CHECKER_MAX_DEPTH | 5 |
This can be turned off by specifying a level of 0
accessibilityLabelExceptions
This field is empty by default and can be overridden by specifying a list of accessibilityLabel to be excluded from the all caps check.
Customising the log levels
Create a JSON file called ama.json
in the project's root folder to customise the log rules, then specify the custom log level for the wanted key.
Example
{
"rules": {
"CONTRAST_FAILED": "warn",
"CONTRAST_CHECKER_MAX_DEPTH": 0
},
"accessibilityLabelExceptions": ["A A"]
}
tip
The JSON file does not need to contain all the log keys, as AMA defaults to the default rule if not present in the JSON one.
warning
Every time the ama.rules.json
file is updated, you need to update the copy inside the node_modules
folder and restart the development server:
cp ama.rules.json node_modules/react-native-ama/
yarn start
- The rule cannot be overridden↩