Skip to content

Commit 29ce4f2

Browse files
authored
chore: bump eslint config to latest (#308)
* chore: bump eslint config to latest * lint fix * lint pass * use roles directly
1 parent ab34712 commit 29ce4f2

16 files changed

+139
-66
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"import/no-unresolved": [
1010
2,
1111
{ "ignore": ["^@theme", "^@docusaurus", "^@generated"] }
12-
]
12+
],
13+
"react-native-a11y/has-valid-accessibility-ignores-invert-colors": 0
1314
}
1415
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"devDependencies": {
2222
"@babel/cli": "^7.8.4",
2323
"@babel/core": "^7.9.0",
24-
"@callstack/eslint-config": "^9.1.0",
24+
"@callstack/eslint-config": "^10.0.0",
2525
"@release-it/conventional-changelog": "^1.1.0",
2626
"@types/react": "^16.9.34",
2727
"@types/react-native": "^0.62.2",

src/__tests__/a11yAPI.test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import { render } from '..';
55

66
const BUTTON_LABEL = 'cool button';
77
const BUTTON_HINT = 'click this button';
8-
const BUTTON_ROLE = 'button';
98
const TEXT_LABEL = 'cool text';
109
const TEXT_HINT = 'static text';
11-
const TEXT_ROLE = 'link';
1210
// Little hack to make all the methods happy with type
1311
const NO_MATCHES_TEXT: any = 'not-existent-element';
1412
const NO_INSTANCES_FOUND = 'No instances found';
@@ -27,13 +25,13 @@ class Button extends React.Component<any> {
2725
<TouchableOpacity
2826
accessibilityHint={BUTTON_HINT}
2927
accessibilityLabel={BUTTON_LABEL}
30-
accessibilityRole={BUTTON_ROLE}
28+
accessibilityRole="button"
3129
accessibilityStates={['selected']}
3230
>
3331
<Typography
3432
accessibilityHint={TEXT_HINT}
3533
accessibilityLabel={TEXT_LABEL}
36-
accessibilityRole={TEXT_ROLE}
34+
accessibilityRole="link"
3735
accessibilityStates={['selected']}
3836
accessibilityState={{ expanded: false, selected: true }}
3937
accessibilityValue={{ min: 40, max: 60 }}
@@ -51,7 +49,7 @@ function Section() {
5149
<Typography
5250
accessibilityHint={TEXT_HINT}
5351
accessibilityLabel={TEXT_LABEL}
54-
accessibilityRole={TEXT_ROLE}
52+
accessibilityRole="link"
5553
// $FlowFixMe - removed in RN 0.62
5654
accessibilityStates={['selected', 'disabled']}
5755
accessibilityState={{ expanded: false }}

src/__tests__/debug.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Button extends React.Component<any, any> {
3232
}
3333

3434
test('debug', () => {
35-
jest.spyOn(console, 'log').mockImplementation(x => x);
35+
jest.spyOn(console, 'log').mockImplementation((x) => x);
3636
const component = <Button onPress={jest.fn} text="Press me" />;
3737
debug(component);
3838

src/__tests__/questionsBoard.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ function QuestionsBoard({ questions, onSubmit }) {
2020
<Text>{q}</Text>
2121
<TextInput
2222
accessibilityLabel="answer input"
23-
onChangeText={text => {
24-
setData(state => ({
23+
accessibilityHint="input"
24+
onChangeText={(text) => {
25+
setData((state) => ({
2526
...state,
2627
[index + 1]: { q, a: text },
2728
}));

src/__tests__/render.test.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Banana extends React.Component<any, any> {
4545
}
4646

4747
changeFresh = () => {
48-
this.setState(state => ({
48+
this.setState((state) => ({
4949
fresh: !state.fresh,
5050
}));
5151
};
@@ -320,7 +320,7 @@ test('toJSON', () => {
320320
});
321321

322322
test('debug', () => {
323-
jest.spyOn(console, 'log').mockImplementation(x => x);
323+
jest.spyOn(console, 'log').mockImplementation((x) => x);
324324

325325
const { debug } = render(<Banana />);
326326

@@ -343,7 +343,7 @@ test('debug', () => {
343343
});
344344

345345
test('debug changing component', () => {
346-
jest.spyOn(console, 'log').mockImplementation(x => x);
346+
jest.spyOn(console, 'log').mockImplementation((x) => x);
347347

348348
const { getByProps, debug } = render(<Banana />);
349349

@@ -390,7 +390,9 @@ test('renders options.wrapper around updated node', () => {
390390
wrapper: WrapperComponent,
391391
});
392392

393-
rerender(<View testID="inner" accessibilityLabel="test" />);
393+
rerender(
394+
<View testID="inner" accessibilityLabel="test" accessibilityHint="test" />
395+
);
394396

395397
expect(getByTestId('wrapper')).toBeTruthy();
396398
expect(toJSON()).toMatchInlineSnapshot(`
@@ -399,6 +401,7 @@ test('renders options.wrapper around updated node', () => {
399401
testID="wrapper"
400402
>
401403
<View
404+
accessibilityHint="test"
402405
accessibilityLabel="test"
403406
testID="inner"
404407
/>

src/__tests__/waitForElement.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class BananaContainer extends React.Component<{}, any> {
2424
state = { fresh: false };
2525

2626
onChangeFresh = async () => {
27-
await new Promise(resolve => setTimeout(resolve, 300));
27+
await new Promise((resolve) => setTimeout(resolve, 300));
2828
this.setState({ fresh: true });
2929
};
3030

src/cleanup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
let cleanupQueue = new Set();
33

44
export default function cleanup() {
5-
cleanupQueue.forEach(fn => fn());
5+
cleanupQueue.forEach((fn) => fn());
66
cleanupQueue.clear();
77
}
88

src/flushMicrotasksQueue.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
* Wait for microtasks queue to flush
44
*/
55
export default function flushMicrotasksQueue(): Promise<any> {
6-
return new Promise(resolve => setImmediate(resolve));
6+
return new Promise((resolve) => setImmediate(resolve));
77
}

src/helpers/a11yAPI.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
2-
import makeQuery from './makeQuery';
32
import type { A11yRole, A11yStates, A11yState, A11yValue } from '../types.flow';
43
import type { WaitForOptions } from './findByAPI';
4+
import makeQuery from './makeQuery';
55

66
type GetReturn = ReactTestInstance;
77
type GetAllReturn = Array<ReactTestInstance>;
@@ -44,18 +44,18 @@ type A11yAPI = {|
4444
findAllByA11yStates: (A11yStates, ?WaitForOptions) => FindAllReturn,
4545

4646
// State
47-
getByA11yState: A11yState => GetReturn,
48-
getAllByA11yState: A11yState => GetAllReturn,
49-
queryByA11yState: A11yState => QueryReturn,
50-
queryAllByA11yState: A11yState => QueryAllReturn,
47+
getByA11yState: (A11yState) => GetReturn,
48+
getAllByA11yState: (A11yState) => GetAllReturn,
49+
queryByA11yState: (A11yState) => QueryReturn,
50+
queryAllByA11yState: (A11yState) => QueryAllReturn,
5151
findByA11yState: (A11yState, ?WaitForOptions) => FindReturn,
5252
findAllByA11yState: (A11yState, ?WaitForOptions) => FindAllReturn,
5353

5454
// Value
55-
getByA11yValue: A11yValue => GetReturn,
56-
getAllByA11yValue: A11yValue => GetAllReturn,
57-
queryByA11yValue: A11yValue => QueryReturn,
58-
queryAllByA11yValue: A11yValue => QueryAllReturn,
55+
getByA11yValue: (A11yValue) => GetReturn,
56+
getAllByA11yValue: (A11yValue) => GetAllReturn,
57+
queryByA11yValue: (A11yValue) => QueryReturn,
58+
queryAllByA11yValue: (A11yValue) => QueryAllReturn,
5959
findByA11yValue: (A11yValue, ?WaitForOptions) => FindReturn,
6060
findAllByA11yValue: (A11yValue, ?WaitForOptions) => FindAllReturn,
6161
|};
@@ -87,14 +87,14 @@ export function matchArrayValue(
8787
return prop.includes(matcher);
8888
}
8989

90-
return !matcher.some(e => !prop.includes(e));
90+
return !matcher.some((e) => !prop.includes(e));
9191
}
9292

9393
export function matchObject<T: {}>(prop?: T, matcher: T): boolean {
9494
return prop
9595
? Object.keys(matcher).length !== 0 &&
9696
Object.keys(prop).length !== 0 &&
97-
!Object.keys(matcher).some(key => prop[key] !== matcher[key])
97+
!Object.keys(matcher).some((key) => prop[key] !== matcher[key])
9898
: false;
9999
}
100100

0 commit comments

Comments
 (0)