Skip to content

Commit 08159f9

Browse files
committed
pr comments
1 parent 80fac72 commit 08159f9

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

__tests__/src/rules/has-valid-accessibility-state-test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ ruleTester.run('has-valid-accessibility-state', rule, {
4242
valid: [
4343
{ code: '<TouchableOpacity accessibilityState={{ disabled: true }} />;' },
4444
{ code: '<TouchableOpacity accessibilityState={{ checked: true }} />;' },
45-
{ code: '<TouchableOpacity accessibilityState={{ checked: "mixed" }} />;' }
45+
{ code: '<TouchableOpacity accessibilityState={{ checked: "mixed" }} />;' },
46+
{
47+
code:
48+
'<TouchableOpacity accessibilityState={{ disabled: true, checked: true }} />;'
49+
}
4650
].map(parserOptionsMapper),
4751
invalid: [
4852
{

docs/rules/has-valid-accessibility-state.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This rule takes no arguments.
2626
<TouchableOpacity accessibilityState={{ disabled: true }} />
2727
<TouchableOpacity accessibilityState={{ checked: true }} />
2828
<TouchableOpacity accessibilityState={{ checked: "mixed" }} />
29+
<TouchableOpacity accessibilityState={{ disabled: true, checked: true }} />
2930
```
3031

3132
### Fail

src/rules/has-valid-accessibility-state.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,17 @@ module.exports = {
4040
Object.entries(attrValue).map(([key, value]) => {
4141
if (validKeys.indexOf(key) < 0) {
4242
error(`accessibilityState object: "${key}" is not a valid key`);
43-
} else if (key !== 'checked' && typeof value !== 'boolean') {
44-
error(
45-
`accessibilityState object: "${key}" value is not a boolean`
46-
);
4743
} else if (
4844
key === 'checked' &&
4945
!(typeof value === 'boolean' || value === 'mixed')
5046
) {
5147
error(
5248
`accessibilityState object: "checked" value is not either a boolean or 'mixed'`
5349
);
50+
} else if (key !== 'checked' && typeof value !== 'boolean') {
51+
error(
52+
`accessibilityState object: "${key}" value is not a boolean`
53+
);
5454
}
5555
});
5656
}

0 commit comments

Comments
 (0)