Skip to content

chore: bump eslint config to latest #308

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

Merged
merged 4 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"import/no-unresolved": [
2,
{ "ignore": ["^@theme", "^@docusaurus", "^@generated"] }
]
],
"react-native-a11y/has-valid-accessibility-ignores-invert-colors": 0
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"devDependencies": {
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.0",
"@callstack/eslint-config": "^9.1.0",
"@callstack/eslint-config": "^10.0.0",
"@release-it/conventional-changelog": "^1.1.0",
"@types/react": "^16.9.34",
"@types/react-native": "^0.62.2",
Expand Down
8 changes: 3 additions & 5 deletions src/__tests__/a11yAPI.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ import { render } from '..';

const BUTTON_LABEL = 'cool button';
const BUTTON_HINT = 'click this button';
const BUTTON_ROLE = 'button';
const TEXT_LABEL = 'cool text';
const TEXT_HINT = 'static text';
const TEXT_ROLE = 'link';
// Little hack to make all the methods happy with type
const NO_MATCHES_TEXT: any = 'not-existent-element';
const NO_INSTANCES_FOUND = 'No instances found';
Expand All @@ -27,13 +25,13 @@ class Button extends React.Component<any> {
<TouchableOpacity
accessibilityHint={BUTTON_HINT}
accessibilityLabel={BUTTON_LABEL}
accessibilityRole={BUTTON_ROLE}
accessibilityRole="button"
accessibilityStates={['selected']}
>
<Typography
accessibilityHint={TEXT_HINT}
accessibilityLabel={TEXT_LABEL}
accessibilityRole={TEXT_ROLE}
accessibilityRole="link"
accessibilityStates={['selected']}
accessibilityState={{ expanded: false, selected: true }}
accessibilityValue={{ min: 40, max: 60 }}
Expand All @@ -51,7 +49,7 @@ function Section() {
<Typography
accessibilityHint={TEXT_HINT}
accessibilityLabel={TEXT_LABEL}
accessibilityRole={TEXT_ROLE}
accessibilityRole="link"
// $FlowFixMe - removed in RN 0.62
accessibilityStates={['selected', 'disabled']}
accessibilityState={{ expanded: false }}
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/debug.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Button extends React.Component<any, any> {
}

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

Expand Down
5 changes: 3 additions & 2 deletions src/__tests__/questionsBoard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ function QuestionsBoard({ questions, onSubmit }) {
<Text>{q}</Text>
<TextInput
accessibilityLabel="answer input"
onChangeText={text => {
setData(state => ({
accessibilityHint="input"
onChangeText={(text) => {
setData((state) => ({
...state,
[index + 1]: { q, a: text },
}));
Expand Down
11 changes: 7 additions & 4 deletions src/__tests__/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Banana extends React.Component<any, any> {
}

changeFresh = () => {
this.setState(state => ({
this.setState((state) => ({
fresh: !state.fresh,
}));
};
Expand Down Expand Up @@ -320,7 +320,7 @@ test('toJSON', () => {
});

test('debug', () => {
jest.spyOn(console, 'log').mockImplementation(x => x);
jest.spyOn(console, 'log').mockImplementation((x) => x);

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

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

test('debug changing component', () => {
jest.spyOn(console, 'log').mockImplementation(x => x);
jest.spyOn(console, 'log').mockImplementation((x) => x);

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

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

rerender(<View testID="inner" accessibilityLabel="test" />);
rerender(
<View testID="inner" accessibilityLabel="test" accessibilityHint="test" />
);

expect(getByTestId('wrapper')).toBeTruthy();
expect(toJSON()).toMatchInlineSnapshot(`
Expand All @@ -399,6 +401,7 @@ test('renders options.wrapper around updated node', () => {
testID="wrapper"
>
<View
accessibilityHint="test"
accessibilityLabel="test"
testID="inner"
/>
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/waitForElement.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class BananaContainer extends React.Component<{}, any> {
state = { fresh: false };

onChangeFresh = async () => {
await new Promise(resolve => setTimeout(resolve, 300));
await new Promise((resolve) => setTimeout(resolve, 300));
this.setState({ fresh: true });
};

Expand Down
2 changes: 1 addition & 1 deletion src/cleanup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
let cleanupQueue = new Set();

export default function cleanup() {
cleanupQueue.forEach(fn => fn());
cleanupQueue.forEach((fn) => fn());
cleanupQueue.clear();
}

Expand Down
2 changes: 1 addition & 1 deletion src/flushMicrotasksQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
* Wait for microtasks queue to flush
*/
export default function flushMicrotasksQueue(): Promise<any> {
return new Promise(resolve => setImmediate(resolve));
return new Promise((resolve) => setImmediate(resolve));
}
22 changes: 11 additions & 11 deletions src/helpers/a11yAPI.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import makeQuery from './makeQuery';
import type { A11yRole, A11yStates, A11yState, A11yValue } from '../types.flow';
import type { WaitForOptions } from './findByAPI';
import makeQuery from './makeQuery';

type GetReturn = ReactTestInstance;
type GetAllReturn = Array<ReactTestInstance>;
Expand Down Expand Up @@ -44,18 +44,18 @@ type A11yAPI = {|
findAllByA11yStates: (A11yStates, ?WaitForOptions) => FindAllReturn,

// State
getByA11yState: A11yState => GetReturn,
getAllByA11yState: A11yState => GetAllReturn,
queryByA11yState: A11yState => QueryReturn,
queryAllByA11yState: A11yState => QueryAllReturn,
getByA11yState: (A11yState) => GetReturn,
getAllByA11yState: (A11yState) => GetAllReturn,
queryByA11yState: (A11yState) => QueryReturn,
queryAllByA11yState: (A11yState) => QueryAllReturn,
findByA11yState: (A11yState, ?WaitForOptions) => FindReturn,
findAllByA11yState: (A11yState, ?WaitForOptions) => FindAllReturn,

// Value
getByA11yValue: A11yValue => GetReturn,
getAllByA11yValue: A11yValue => GetAllReturn,
queryByA11yValue: A11yValue => QueryReturn,
queryAllByA11yValue: A11yValue => QueryAllReturn,
getByA11yValue: (A11yValue) => GetReturn,
getAllByA11yValue: (A11yValue) => GetAllReturn,
queryByA11yValue: (A11yValue) => QueryReturn,
queryAllByA11yValue: (A11yValue) => QueryAllReturn,
findByA11yValue: (A11yValue, ?WaitForOptions) => FindReturn,
findAllByA11yValue: (A11yValue, ?WaitForOptions) => FindAllReturn,
|};
Expand Down Expand Up @@ -87,14 +87,14 @@ export function matchArrayValue(
return prop.includes(matcher);
}

return !matcher.some(e => !prop.includes(e));
return !matcher.some((e) => !prop.includes(e));
}

export function matchObject<T: {}>(prop?: T, matcher: T): boolean {
return prop
? Object.keys(matcher).length !== 0 &&
Object.keys(prop).length !== 0 &&
!Object.keys(matcher).some(key => prop[key] !== matcher[key])
!Object.keys(matcher).some((key) => prop[key] !== matcher[key])
: false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/helpers/findByAPI.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow
import waitForElement from '../waitForElement';
import {
fixedGetByTestId,
getAllByTestId,
Expand All @@ -9,7 +10,6 @@ import {
getByDisplayValue,
getAllByDisplayValue,
} from './getByAPI';
import waitForElement from '../waitForElement';

export type WaitForOptions = {
timeout?: number,
Expand Down
20 changes: 10 additions & 10 deletions src/helpers/getByAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const getNodeByText = (node, text) => {
};

const getChildrenAsText = (children, TextComponent, textContent = []) => {
React.Children.forEach(children, child => {
React.Children.forEach(children, (child) => {
if (typeof child === 'string') {
textContent.push(child);
return;
Expand Down Expand Up @@ -90,7 +90,7 @@ export const getByName = (instance: ReactTestInstance, warnFn?: Function) =>
warnFn && warnFn('getByName');
try {
return typeof name === 'string'
? instance.find(node => filterNodeByName(node, name))
? instance.find((node) => filterNodeByName(node, name))
: instance.findByType(name);
} catch (error) {
throw new ErrorWithStack(prepareErrorMessage(error), getByNameFn);
Expand All @@ -110,7 +110,7 @@ export const getByType = (instance: ReactTestInstance, warnFn?: Function) =>
export const getByText = (instance: ReactTestInstance) =>
function getByTextFn(text: string | RegExp) {
try {
return instance.find(node => getNodeByText(node, text));
return instance.find((node) => getNodeByText(node, text));
} catch (error) {
throw new ErrorWithStack(prepareErrorMessage(error), getByTextFn);
}
Expand All @@ -119,7 +119,7 @@ export const getByText = (instance: ReactTestInstance) =>
export const getByPlaceholder = (instance: ReactTestInstance) =>
function getByPlaceholderFn(placeholder: string | RegExp) {
try {
return instance.find(node =>
return instance.find((node) =>
getTextInputNodeByPlaceholder(node, placeholder)
);
} catch (error) {
Expand All @@ -130,7 +130,7 @@ export const getByPlaceholder = (instance: ReactTestInstance) =>
export const getByDisplayValue = (instance: ReactTestInstance) =>
function getByDisplayValueFn(placeholder: string | RegExp) {
try {
return instance.find(node =>
return instance.find((node) =>
getTextInputNodeByDisplayValue(node, placeholder)
);
} catch (error) {
Expand Down Expand Up @@ -181,7 +181,7 @@ export const getAllByName = (instance: ReactTestInstance, warnFn?: Function) =>
warnFn && warnFn('getAllByName');
const results =
typeof name === 'string'
? instance.findAll(node => filterNodeByName(node, name))
? instance.findAll((node) => filterNodeByName(node, name))
: instance.findAllByType(name);
if (results.length === 0) {
throw new ErrorWithStack('No instances found', getAllByNameFn);
Expand All @@ -201,7 +201,7 @@ export const getAllByType = (instance: ReactTestInstance, warnFn?: Function) =>

export const getAllByText = (instance: ReactTestInstance) =>
function getAllByTextFn(text: string | RegExp) {
const results = instance.findAll(node => getNodeByText(node, text));
const results = instance.findAll((node) => getNodeByText(node, text));
if (results.length === 0) {
throw new ErrorWithStack(
`No instances found with text: ${String(text)}`,
Expand All @@ -213,7 +213,7 @@ export const getAllByText = (instance: ReactTestInstance) =>

export const getAllByPlaceholder = (instance: ReactTestInstance) =>
function getAllByPlaceholderFn(placeholder: string | RegExp) {
const results = instance.findAll(node =>
const results = instance.findAll((node) =>
getTextInputNodeByPlaceholder(node, placeholder)
);
if (results.length === 0) {
Expand All @@ -227,7 +227,7 @@ export const getAllByPlaceholder = (instance: ReactTestInstance) =>

export const getAllByDisplayValue = (instance: ReactTestInstance) =>
function getAllByDisplayValueFn(value: string | RegExp) {
const results = instance.findAll(node =>
const results = instance.findAll((node) =>
getTextInputNodeByDisplayValue(node, value)
);
if (results.length === 0) {
Expand Down Expand Up @@ -256,7 +256,7 @@ export const getAllByTestId = (instance: ReactTestInstance) =>
function getAllByTestIdFn(testID: string): ReactTestInstance[] {
const results = instance
.findAllByProps({ testID })
.filter(element => typeof element.type === 'string');
.filter((element) => typeof element.type === 'string');

if (results.length === 0) {
throw new ErrorWithStack(
Expand Down
8 changes: 4 additions & 4 deletions src/helpers/makeQuery.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// @flow
import waitForElement from '../waitForElement';
import {
ErrorWithStack,
prepareErrorMessage,
createQueryByError,
} from './errors';
import waitForElement from '../waitForElement';
import type { WaitForOptions } from './findByAPI';

function isNodeValid(node: ReactTestInstance) {
Expand All @@ -13,7 +13,7 @@ function isNodeValid(node: ReactTestInstance) {

function makeAliases(aliases: Array<string>, query: Function) {
return aliases
.map(alias => ({ [alias]: query }))
.map((alias) => ({ [alias]: query }))
.reduce((acc, query) => ({ ...acc, ...query }), {});
}

Expand All @@ -34,7 +34,7 @@ const makeQuery = <P: mixed, M: mixed>(
const getBy = (matcher: M) => {
try {
return instance.find(
node => isNodeValid(node) && matcherFn(node.props[name], matcher)
(node) => isNodeValid(node) && matcherFn(node.props[name], matcher)
);
} catch (error) {
throw new ErrorWithStack(prepareErrorMessage(error), getBy);
Expand All @@ -43,7 +43,7 @@ const makeQuery = <P: mixed, M: mixed>(

const getAllBy = (matcher: M) => {
const results = instance.findAll(
node => isNodeValid(node) && matcherFn(node.props[name], matcher)
(node) => isNodeValid(node) && matcherFn(node.props[name], matcher)
);

if (results.length === 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function updateWithAct(
renderer: ReactTestRenderer,
wrap: (innerElement: React.Element<any>) => React.Element<any>
) {
return function(component: React.Element<any>) {
return function (component: React.Element<any>) {
act(() => {
renderer.update(wrap(component));
});
Expand All @@ -79,6 +79,6 @@ function debug(instance: ReactTestInstance, renderer) {
function debugImpl(message?: string) {
return debugDeep(renderer.toJSON(), message);
}
debugImpl.shallow = message => debugShallow(instance, message);
debugImpl.shallow = (message) => debugShallow(instance, message);
return debugImpl;
}
2 changes: 1 addition & 1 deletion src/waitForElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default function waitForElement<T>(
): Promise<T> {
const startTime = Date.now();
return new Promise((resolve, reject) => {
const rejectOrRerun = error => {
const rejectOrRerun = (error) => {
if (Date.now() - startTime >= timeout) {
reject(error);
return;
Expand Down
Loading