Skip to content

Commit 94ff425

Browse files
thymikeeEsemesek
authored andcommitted
chore: bump Flow and ESLint preset (#241)
* chore: bump Flow and ESLint preset * fix name of waitForElement
1 parent 4c77f4a commit 94ff425

File tree

12 files changed

+405
-202
lines changed

12 files changed

+405
-202
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"rules": {
44
"flowtype/no-weak-types": 0,
55
"react-native/no-raw-text": 0,
6-
"no-console": 1
6+
"no-console": 1,
7+
"react/no-multi-comp": 0
78
}
89
}

docs/API.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,14 @@ expect(onEndReached).toHaveBeenCalled();
318318
Defined as:
319319

320320
```jsx
321-
function waitForExpect<T: *>(
321+
function waitForElement<T>(
322322
expectation: () => T,
323323
timeout: number = 4500,
324324
interval: number = 50
325325
): Promise<T> {}
326326
```
327327

328-
Waits for non-deterministic periods of time until your element appears or times out. `waitForExpect` periodically calls `expectation` every `interval` milliseconds to determine whether the element appeared or not.
328+
Waits for non-deterministic periods of time until your element appears or times out. `waitForElement` periodically calls `expectation` every `interval` milliseconds to determine whether the element appeared or not.
329329

330330
```jsx
331331
import { render, waitForElement } from 'react-testing-library';

package.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,15 @@
1717
"devDependencies": {
1818
"@babel/cli": "^7.1.2",
1919
"@babel/core": "^7.1.2",
20-
"@callstack/eslint-config": "^7.0.0",
20+
"@callstack/eslint-config": "^8.0.0",
2121
"@release-it/conventional-changelog": "^1.1.0",
2222
"@types/react": "^16.7.11",
2323
"@types/react-test-renderer": "^16.0.3",
24-
"@typescript-eslint/eslint-plugin": "^1.10.2",
2524
"babel-jest": "^24.7.1",
26-
"chalk": "^2.4.1",
2725
"conventional-changelog-cli": "^2.0.11",
2826
"dedent": "^0.7.0",
29-
"eslint": "^6.0.1",
30-
"flow-bin": "^0.104.0",
27+
"eslint": "^6.7.2",
28+
"flow-bin": "^0.107.0",
3129
"flow-copy-source": "^2.0.6",
3230
"jest": "^24.7.1",
3331
"metro-react-native-babel-preset": "^0.52.0",
@@ -36,14 +34,14 @@
3634
"react-test-renderer": "16.8.6",
3735
"release-it": "^12.3.3",
3836
"strip-ansi": "^5.2.0",
39-
"typescript": "^3.5.3"
37+
"typescript": "^3.7.3"
4038
},
4139
"dependencies": {
4240
"pretty-format": "^24.0.0"
4341
},
4442
"peerDependencies": {
4543
"react": ">=16.0.0",
46-
"react-test-renderer": ">= 16.0.0"
44+
"react-test-renderer": ">=16.0.0"
4745
},
4846
"scripts": {
4947
"test": "jest",
@@ -71,8 +69,5 @@
7169
},
7270
"publishConfig": {
7371
"registry": "https://registry.npmjs.org/"
74-
},
75-
"resolutions": {
76-
"eslint-plugin-import": "2.18.0"
7772
}
7873
}

src/__tests__/a11yAPI.test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ const TEXT_LABEL = 'cool text';
1010
const TEXT_HINT = 'static text';
1111
const TEXT_ROLE = 'link';
1212
const NO_MATCHES_TEXT = 'not-existent-element';
13-
1413
const NO_INSTANCES_FOUND = 'No instances found';
1514
const FOUND_TWO_INSTANCES = 'Expected 1 but found 2 instances';
1615

1716
const Typography = ({ children, ...rest }) => {
1817
return <Text {...rest}>{children}</Text>;
1918
};
2019

21-
class Button extends React.Component<*> {
20+
class Button extends React.Component<any> {
2221
render() {
2322
return (
2423
<TouchableOpacity

src/__tests__/debug.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function TextComponent({ text }) {
1212
return <Text>{text}</Text>;
1313
}
1414

15-
class Button extends React.Component<*, *> {
15+
class Button extends React.Component<any, any> {
1616
state = { counter: 0 };
1717

1818
onPress = async () => {

src/__tests__/render.test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// @flow
2-
/* eslint-disable react/no-multi-comp */
32
import React from 'react';
43
import {
54
View,
@@ -18,7 +17,7 @@ const PLACEHOLDER_CHEF = 'Who inspected freshness?';
1817
const INPUT_FRESHNESS = 'Custom Freshie';
1918
const INPUT_CHEF = 'I inspected freshie';
2019

21-
class Button extends React.Component<*> {
20+
class Button extends React.Component<any> {
2221
render() {
2322
return (
2423
<TouchableOpacity onPress={this.props.onPress}>
@@ -28,7 +27,7 @@ class Button extends React.Component<*> {
2827
}
2928
}
3029

31-
class Banana extends React.Component<*, *> {
30+
class Banana extends React.Component<any, any> {
3231
state = {
3332
fresh: false,
3433
};

src/__tests__/waitForElement.test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
// @flow
2-
/* eslint-disable react/no-multi-comp */
32
import React from 'react';
43
import { View, Text, TouchableOpacity } from 'react-native';
54
import { render, fireEvent, waitForElement } from '..';
65

7-
class Banana extends React.Component<*, *> {
6+
class Banana extends React.Component<any> {
87
changeFresh = () => {
98
this.props.onChangeFresh();
109
};
@@ -21,7 +20,7 @@ class Banana extends React.Component<*, *> {
2120
}
2221
}
2322

24-
class BananaContainer extends React.Component<*, *> {
23+
class BananaContainer extends React.Component<{}, any> {
2524
state = { fresh: false };
2625

2726
onChangeFresh = async () => {

src/helpers/a11yAPI.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type ArrayQueryAllFn = (
1212
type ArrayGetFn = (string | Array<string>) => ReactTestInstance;
1313
type ArrayGetAllFn = (string | Array<string>) => Array<ReactTestInstance>;
1414

15-
type A11yAPI = {
15+
type A11yAPI = {|
1616
getByA11yLabel: GetFn,
1717
getAllByA11yLabel: GetAllFn,
1818
queryByA11yLabel: QueryFn,
@@ -29,7 +29,7 @@ type A11yAPI = {
2929
getAllByA11yStates: ArrayGetAllFn,
3030
queryByA11yStates: ArrayQueryFn,
3131
queryAllByA11yStates: ArrayQueryAllFn,
32-
};
32+
|};
3333

3434
export function matchStringValue(prop?: string, matcher: string | RegExp) {
3535
if (!prop) {
@@ -55,7 +55,6 @@ export function matchArrayValue(
5555
return prop.includes(matcher);
5656
}
5757

58-
// $FlowFixMe - callback is sync hence prop exists
5958
return !matcher.some(e => !prop.includes(e));
6059
}
6160

src/helpers/getByAPI.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const getTextInputNodeByDisplayValue = (node, value) => {
6969
};
7070

7171
export const getByName = (instance: ReactTestInstance) =>
72-
function getByNameFn(name: string | React.ComponentType<*>) {
72+
function getByNameFn(name: string | React.ComponentType<any>) {
7373
logDeprecationWarning('getByName', 'getByType');
7474
try {
7575
return typeof name === 'string'
@@ -81,7 +81,7 @@ export const getByName = (instance: ReactTestInstance) =>
8181
};
8282

8383
export const getByType = (instance: ReactTestInstance) =>
84-
function getByTypeFn(type: React.ComponentType<*>) {
84+
function getByTypeFn(type: React.ComponentType<any>) {
8585
try {
8686
return instance.findByType(type);
8787
} catch (error) {
@@ -139,7 +139,7 @@ export const getByTestId = (instance: ReactTestInstance) =>
139139
};
140140

141141
export const getAllByName = (instance: ReactTestInstance) =>
142-
function getAllByNameFn(name: string | React.ComponentType<*>) {
142+
function getAllByNameFn(name: string | React.ComponentType<any>) {
143143
logDeprecationWarning('getAllByName', 'getAllByType');
144144
const results =
145145
typeof name === 'string'
@@ -152,7 +152,7 @@ export const getAllByName = (instance: ReactTestInstance) =>
152152
};
153153

154154
export const getAllByType = (instance: ReactTestInstance) =>
155-
function getAllByTypeFn(type: React.ComponentType<*>) {
155+
function getAllByTypeFn(type: React.ComponentType<any>) {
156156
const results = instance.findAllByType(type);
157157
if (results.length === 0) {
158158
throw new ErrorWithStack('No instances found', getAllByTypeFn);

src/helpers/queryByAPI.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
import { logDeprecationWarning, createQueryByError } from './errors';
2020

2121
export const queryByName = (instance: ReactTestInstance) =>
22-
function queryByNameFn(name: string | React.ComponentType<*>) {
22+
function queryByNameFn(name: string | React.ComponentType<any>) {
2323
logDeprecationWarning('queryByName', 'getByName');
2424
try {
2525
return getByName(instance)(name);
@@ -29,7 +29,7 @@ export const queryByName = (instance: ReactTestInstance) =>
2929
};
3030

3131
export const queryByType = (instance: ReactTestInstance) =>
32-
function queryByTypeFn(type: React.ComponentType<*>) {
32+
function queryByTypeFn(type: React.ComponentType<any>) {
3333
try {
3434
return getByType(instance)(type);
3535
} catch (error) {
@@ -83,7 +83,7 @@ export const queryByTestId = (instance: ReactTestInstance) =>
8383
};
8484

8585
export const queryAllByName = (instance: ReactTestInstance) => (
86-
name: string | React.ComponentType<*>
86+
name: string | React.ComponentType<any>
8787
) => {
8888
logDeprecationWarning('queryAllByName', 'getAllByName');
8989
try {
@@ -94,7 +94,7 @@ export const queryAllByName = (instance: ReactTestInstance) => (
9494
};
9595

9696
export const queryAllByType = (instance: ReactTestInstance) => (
97-
type: React.ComponentType<*>
97+
type: React.ComponentType<any>
9898
) => {
9999
try {
100100
return getAllByType(instance)(type);

0 commit comments

Comments
 (0)