Skip to content

Commit a688a55

Browse files
Feature/add support for custom image module with image alias (#93)
Co-authored-by: Eli Zibin <elizibin@gmail.com>
1 parent 2e6e045 commit a688a55

File tree

8 files changed

+450
-150
lines changed

8 files changed

+450
-150
lines changed

.babelrc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
{
22
"presets": [
33
[
4-
"@babel/preset-env", {
4+
"@babel/preset-env",
5+
{
56
"targets": {
67
"node": "4"
78
}
89
}
910
]
1011
],
11-
"plugins": [
12-
"@babel/transform-flow-strip-types",
13-
]
12+
"plugins": ["@babel/transform-flow-strip-types"]
1413
}

.changeset/funny-socks-collect.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'eslint-plugin-react-native-a11y': minor
3+
---
4+
5+
Allow aliasing Images

README.md

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Eslint-plugin-react-native-a11y is a collection of React Native specific ESLint
88
## Setup
99

1010
### Pre-Requisites
11+
1112
Before starting, check you already have ESLint as a `devDependency` of your project.
1213

1314
> 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).
@@ -30,12 +31,12 @@ yarn add eslint-plugin-react-native-a11y --dev
3031

3132
This plugin exposes four recommended configs.
3233

33-
Name|Description
34-
-|-
35-
basic|Only use basic validation rules common to both iOS & Android
36-
ios|Use all rules from "basic", plus iOS-specific extras
37-
android|Use all rules from "basic", plus Android-specific extras
38-
all|Use all rules from "basic", plus iOS-specific extras, plus Android-specific extras
34+
| Name | Description |
35+
| ------- | ---------------------------------------------------------------------------------- |
36+
| basic | Only use basic validation rules common to both iOS & Android |
37+
| ios | Use all rules from "basic", plus iOS-specific extras |
38+
| android | Use all rules from "basic", plus Android-specific extras |
39+
| all | Use all rules from "basic", plus iOS-specific extras, plus Android-specific extras |
3940

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

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

4950
module.exports = {
5051
root: true,
51-
extends: [
52-
'@react-native-community',
53-
'plugin:react-native-a11y/ios'
54-
]
52+
extends: ['@react-native-community', 'plugin:react-native-a11y/ios'],
5553
};
5654
```
5755

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

6361
module.exports = {
6462
root: true,
65-
extends: [
66-
'@react-native-community',
67-
],
63+
extends: ['@react-native-community'],
6864
rules: {
69-
'react-native-a11y/rule-name': 2
70-
}
65+
'react-native-a11y/rule-name': 2,
66+
},
7167
};
7268
```
7369

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

7874
### Basic
75+
7976
- [has-accessibility-hint](docs/rules/has-accessibility-hint.md): Enforce `accessibilityHint` is used in conjunction with `accessibilityLabel`
8077
- [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
8178
- [has-valid-accessibility-actions](docs/rules/has-valid-accessibility-actions.md): Enforce both `accessibilityActions` and `onAccessibilityAction` props are valid
@@ -89,9 +86,11 @@ For more information on configuring behaviour of an individual rule, please refe
8986
- [has-valid-accessibility-descriptors](docs/rules/has-valid-accessibility-descriptors.md): Ensures that Touchable* components have appropriate props to communicate with assistive technologies
9087

9188
### iOS
89+
9290
- [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.
9391

9492
### Android
93+
9594
- [has-valid-accessibility-live-region](docs/rules/has-valid-accessibility-live-region.md): Enforce `accessibilityLiveRegion` prop values must be valid
9695
- [has-valid-important-for-accessibility](docs/rules/has-valid-important-for-accessibility.md): Enforce `importantForAccessibility` property value is valid
9796

__tests__/index-test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,12 @@ describe('all rule files should be exported by the plugin', () => {
2222
});
2323

2424
describe('configurations', () => {
25-
it("should export a 'recommended' configuration", () => {
26-
assert(plugin.configs.recommended);
25+
const configs = ['basic', 'ios', 'android', 'all'];
26+
27+
configs.forEach((name) => {
28+
it(`should export a '${name}' configuration`, () => {
29+
assert(plugin.configs[name]);
30+
});
2731
});
2832
});
2933

0 commit comments

Comments
 (0)