
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
eslint-plugin-react-native-accessibility
Advanced tools
React Native specific accessibility linting rules.
THis is a Fork from eslint-plugin-react-native-a11y
eslint-plugin-react-native-accessibility is a collection of React Native specific ESLint rules for identifying accessibility issues. Building upon the foundation set down by eslint-plugin-jsx-a11y, eslint-plugin-react-native-accessibility detects a few of the most commonly made accessibility issues found in react native apps. These rules make it easier for your apps to be navigable by users with screen readers.
Before starting, check you already have ESLint as a devDependency
of your project.
Projects created using
react-native init
will already have this, but for Expo depending on your template you may need to follow ESLint's installation instructions.
Next, install eslint-plugin-react-native-accessibility
:
npm install eslint-plugin-react-native-accessibility --save-dev
# or
yarn add eslint-plugin-react-native-accessibility --dev
Note: If you installed ESLint globally (using the -g
flag in npm, or the global
prefix in yarn) then you must also install eslint-plugin-react-native-accessibility
globally.
This plugin exposes four recommended configs.
Name | Description |
---|---|
basic | Only use basic validation rules common to both iOS & Android |
ios | Use all rules from "basic", plus iOS-specific extras |
android | Use all rules from "basic", plus Android-specific extras |
all | Use all rules from "basic", plus iOS-specific extras, plus Android-specific extras |
If your project only supports a single platform, you may get the best experience using a platform-specific config. This will both avoid reporting issues which do not affect your platform and also results in slightly faster linting for larger projects.
If you are unsure which one to use, in most cases
all
can be safely used.
Add the config you want to use to the extends
section of your ESLint config using the pattern plugin:react-native-a11y/
followed by your config name, as shown below:
// .eslintrc.js
module.exports = {
root: true,
extends: ['@react-native-community', 'plugin:react-native-a11y/ios'],
};
Alternatively if you do not want to use one of the pre-defined configs — or want to override the behaviour of a specific rule — you can always include a list rules and configurations in the rules
section of your ESLint config.
// .eslintrc.js
module.exports = {
root: true,
extends: ['@react-native-community'],
rules: {
'react-native-a11y/rule-name': 2,
},
};
For more information on configuring behaviour of an individual rule, please refer to the ESLint docs
accessibilityHint
is used in conjunction with accessibilityLabel
<Touchable\*>
components only have either the accessibilityRole
prop or both accessibilityTraits
and accessibilityComponentType
props setaccessibilityActions
and onAccessibilityAction
props are validaccessibilityRole
property value is validaccessibilityState
property value is validaccessibilityStates
property value is validaccessibilityComponentType
property value is validaccessibilityTraits
and accessibilityComponentType
prop values must be validaccessibilityValue
property value is validaccessible={true}
, that there are no touchable elements insideaccessibilityIgnoresInvertColors
to avoid being inverted by device color settings.accessibilityLiveRegion
prop values must be validimportantForAccessibility
property value is validThe following options are available to customize the recommended rule set.
react-native-a11y/has-accessibility-props
and react-native-a11y/no-nested-touchables
allow you to define an array of names for custom components that you may have that conform to the same accessibility interfaces as Touchables.
"react-native-a11y/has-accessibility-props": [
"error",
{
"touchables": ["TouchableCustom"]
}
]
react-native-a11y/has-valid-accessibility-ignores-invert-colors
allows you to optionally define an Array of component names to check in addition to <Image />
.
For more information, see the rule docs.
"react-native-a11y/has-valid-accessibility-ignores-invert-colors": [
"error",
{
"invertableComponents": [
"FastImage",
]
}
]
If you are developing new rules for this project, you can use the create-rule
script to scaffold the new files.
$ ./scripts/create-rule.js my-new-rule
This project started as a fork of eslint-plugin-jsx-a11y and a lot of the work was carried out by its contributors, to whom we owe a lot!
eslint-plugin-react-native-accessibility is licensed under the MIT License.
Active: Nearform is actively working on this project, and we expect to continue for work for the foreseeable future. Bug reports, feature requests and pull requests are welcome.
FAQs
React Native specific accessibility linting rules.
The npm package eslint-plugin-react-native-accessibility receives a total of 6 weekly downloads. As such, eslint-plugin-react-native-accessibility popularity was classified as not popular.
We found that eslint-plugin-react-native-accessibility demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.