Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add support for custom image module with image alias #93

7 changes: 3 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"presets": [
[
"@babel/preset-env", {
"@babel/preset-env",
{
"targets": {
"node": "4"
}
}
]
],
"plugins": [
"@babel/transform-flow-strip-types",
]
"plugins": ["@babel/transform-flow-strip-types"]
}
5 changes: 5 additions & 0 deletions .changeset/funny-socks-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eslint-plugin-react-native-a11y': minor
---

Allow aliasing Images
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Eslint-plugin-react-native-a11y is a collection of React Native specific ESLint
## Setup

### Pre-Requisites

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](https://eslint.org/docs/user-guide/getting-started#installation-and-usage).
Expand All @@ -30,12 +31,12 @@ yarn add eslint-plugin-react-native-a11y --dev

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
| 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.

Expand All @@ -48,10 +49,7 @@ Add the config you want to use to the `extends` section of your ESLint config us

module.exports = {
root: true,
extends: [
'@react-native-community',
'plugin:react-native-a11y/ios'
]
extends: ['@react-native-community', 'plugin:react-native-a11y/ios'],
};
```

Expand All @@ -62,12 +60,10 @@ Alternatively if you do not want to use one of the pre-defined configs — or wa

module.exports = {
root: true,
extends: [
'@react-native-community',
],
extends: ['@react-native-community'],
rules: {
'react-native-a11y/rule-name': 2
}
'react-native-a11y/rule-name': 2,
},
};
```

Expand All @@ -76,6 +72,7 @@ For more information on configuring behaviour of an individual rule, please refe
## Supported Rules

### Basic

- [has-accessibility-hint](docs/rules/has-accessibility-hint.md): Enforce `accessibilityHint` is used in conjunction with `accessibilityLabel`
- [has-accessibility-props](docs/rules/has-accessibility-props.md): Enforce that `<Touchable\*>` components only have either the `accessibilityRole` prop or both `accessibilityTraits` and `accessibilityComponentType` props set
- [has-valid-accessibility-actions](docs/rules/has-valid-accessibility-actions.md): Enforce both `accessibilityActions` and `onAccessibilityAction` props are valid
Expand All @@ -89,9 +86,11 @@ For more information on configuring behaviour of an individual rule, please refe
- [has-valid-accessibility-descriptors](docs/rules/has-valid-accessibility-descriptors.md): Ensures that Touchable* components have appropriate props to communicate with assistive technologies

### iOS

- [has-valid-accessibility-ignores-invert-colors](docs/rules/has-valid-accessibility-ignores-invert-colors.md): Enforce that certain elements use `accessibilityIgnoresInvertColors` to avoid being inverted by device color settings.

### Android

- [has-valid-accessibility-live-region](docs/rules/has-valid-accessibility-live-region.md): Enforce `accessibilityLiveRegion` prop values must be valid
- [has-valid-important-for-accessibility](docs/rules/has-valid-important-for-accessibility.md): Enforce `importantForAccessibility` property value is valid

Expand Down
8 changes: 6 additions & 2 deletions __tests__/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ describe('all rule files should be exported by the plugin', () => {
});

describe('configurations', () => {
it("should export a 'recommended' configuration", () => {
assert(plugin.configs.recommended);
const configs = ['basic', 'ios', 'android', 'all'];

configs.forEach((name) => {
it(`should export a '${name}' configuration`, () => {
assert(plugin.configs[name]);
});
});
});

Expand Down
Loading