Skip to content

Commit 21254b0

Browse files
chore: reformat source using prettier (#1550)
* chore: reformat source using prettier * chore: fix lint
1 parent 7899412 commit 21254b0

File tree

174 files changed

+847
-2215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

174 files changed

+847
-2215
lines changed

.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
root = true
6+
7+
[*]
8+
9+
indent_style = space
10+
indent_size = 2
11+
12+
end_of_line = lf
13+
charset = utf-8
14+
trim_trailing_whitespace = true
15+
insert_final_newline = true
16+
17+
max_line_length = 100

.eslintrc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
"no-console": 1,
77
"react/no-multi-comp": 0,
88
// Ignore certain webpack alias because it can't be resolved
9-
"import/no-unresolved": [
10-
2,
11-
{ "ignore": ["^@theme", "^@docusaurus", "^@generated"] }
12-
],
9+
"import/no-unresolved": [2, { "ignore": ["^@theme", "^@docusaurus", "^@generated"] }],
1310
"react-native/no-color-literals": "off",
1411
"react-native/no-inline-styles": "off",
1512
"react-native-a11y/has-valid-accessibility-descriptors": "off",

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ labels: 'feature request'
55
---
66

77
## Describe the Feature
8+
89
<!-- Describe the requested Feature -->
910

1011
## Possible Implementations
12+
1113
<!-- Describe how to implement the feature -->
1214

1315
## Related Issues
16+
1417
<!-- Link related issues here -->

.github/dependabot.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
version: 2
22
updates:
3-
- package-ecosystem: npm
4-
directory: "/"
5-
schedule:
6-
interval: "weekly"
7-
open-pull-requests-limit: 3
8-
ignore:
9-
- dependency-name: "*"
10-
update-types: ["version-update:semver-minor", "version-update:semver-patch"]
3+
- package-ecosystem: npm
4+
directory: '/'
5+
schedule:
6+
interval: 'weekly'
7+
open-pull-requests-limit: 3
8+
ignore:
9+
- dependency-name: '*'
10+
update-types: ['version-update:semver-minor', 'version-update:semver-patch']

.prettierrc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// added for Jest inline snapshots to not use default Prettier config
22
module.exports = {
33
singleQuote: true,
4-
trailingComma: "es5"
5-
}
4+
trailingComma: 'es5',
5+
};

CODE_OF_CONDUCT.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@ orientation.
1414
Examples of behavior that contributes to creating a positive environment
1515
include:
1616

17-
* Using welcoming and inclusive language
18-
* Being respectful of differing viewpoints and experiences
19-
* Gracefully accepting constructive criticism
20-
* Focusing on what is best for the community
21-
* Showing empathy towards other community members
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
2222

2323
Examples of unacceptable behavior by participants include:
2424

25-
* The use of sexualized language or imagery and unwelcome sexual attention or
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
2626
advances
27-
* Trolling, insulting/derogatory comments, and personal or political attacks
28-
* Public or private harassment
29-
* Publishing others' private information, such as a physical or electronic
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
3030
address, without explicit permission
31-
* Other conduct which could reasonably be considered inappropriate in a
31+
- Other conduct which could reasonably be considered inappropriate in a
3232
professional setting
3333

3434
## Our Responsibilities

examples/basic/App.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ const App = () => {
88

99
return (
1010
<SafeAreaView>
11-
{user == null ? (
12-
<LoginForm onLoginSuccess={setUser} />
13-
) : (
14-
<Home user={user} />
15-
)}
11+
{user == null ? <LoginForm onLoginSuccess={setUser} /> : <Home user={user} />}
1612
</SafeAreaView>
1713
);
1814
};

examples/basic/__tests__/App.test.tsx

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ test('renders correctly', () => {
1313

1414
// Idiom: `getBy*` queries are predicates by themselves, but we will use it with `expect().toBeOnTheScreen()`
1515
// to clarify our intent.
16-
expect(
17-
screen.getByRole('header', { name: 'Sign in to Example App' })
18-
).toBeOnTheScreen();
16+
expect(screen.getByRole('header', { name: 'Sign in to Example App' })).toBeOnTheScreen();
1917
});
2018

2119
/**
@@ -32,9 +30,7 @@ test('User can sign in successully with correct credentials', async () => {
3230

3331
// Idiom: `getBy*` queries are predicates by themselves, but we will use it with `expect().toBeOnTheScreen()`
3432
// to clarify our intent.
35-
expect(
36-
screen.getByRole('header', { name: 'Sign in to Example App' })
37-
).toBeOnTheScreen();
33+
expect(screen.getByRole('header', { name: 'Sign in to Example App' })).toBeOnTheScreen();
3834

3935
// Hint: we can use `getByLabelText` to find our text inputs using their labels.
4036
await user.type(screen.getByLabelText('Username'), 'admin');
@@ -47,14 +43,10 @@ test('User can sign in successully with correct credentials', async () => {
4743
// for the action to complete.
4844
// Hint: subsequent queries do not need to use `findBy*`, because they are used after the async action
4945
// already finished
50-
expect(
51-
await screen.findByRole('header', { name: 'Welcome admin!' })
52-
).toBeOnTheScreen();
46+
expect(await screen.findByRole('header', { name: 'Welcome admin!' })).toBeOnTheScreen();
5347

5448
// Idiom: use `queryBy*` with `expect().not.toBeOnTheScreen()` to assess that element is not present.
55-
expect(
56-
screen.queryByRole('header', { name: 'Sign in to Example App' })
57-
).not.toBeOnTheScreen();
49+
expect(screen.queryByRole('header', { name: 'Sign in to Example App' })).not.toBeOnTheScreen();
5850
expect(screen.queryByLabelText('Username')).not.toBeOnTheScreen();
5951
expect(screen.queryByLabelText('Password')).not.toBeOnTheScreen();
6052
});
@@ -75,22 +67,16 @@ test('User will see errors for incorrect credentials', async () => {
7567
const user = userEvent.setup();
7668
render(<App />);
7769

78-
expect(
79-
screen.getByRole('header', { name: 'Sign in to Example App' })
80-
).toBeOnTheScreen();
70+
expect(screen.getByRole('header', { name: 'Sign in to Example App' })).toBeOnTheScreen();
8171

8272
await user.type(screen.getByLabelText('Username'), 'admin');
8373
await user.type(screen.getByLabelText('Password'), 'qwerty123');
8474
await user.press(screen.getByRole('button', { name: 'Sign In' }));
8575

8676
// Hint: you can use custom Jest Native matcher to check text content.
87-
expect(await screen.findByRole('alert')).toHaveTextContent(
88-
'Incorrect username or password'
89-
);
77+
expect(await screen.findByRole('alert')).toHaveTextContent('Incorrect username or password');
9078

91-
expect(
92-
screen.getByRole('header', { name: 'Sign in to Example App' })
93-
).toBeOnTheScreen();
79+
expect(screen.getByRole('header', { name: 'Sign in to Example App' })).toBeOnTheScreen();
9480
expect(screen.getByLabelText('Username')).toBeOnTheScreen();
9581
expect(screen.getByLabelText('Password')).toBeOnTheScreen();
9682
});
@@ -102,9 +88,7 @@ test('User can sign in after incorrect attempt', async () => {
10288
const user = userEvent.setup();
10389
render(<App />);
10490

105-
expect(
106-
screen.getByRole('header', { name: 'Sign in to Example App' })
107-
).toBeOnTheScreen();
91+
expect(screen.getByRole('header', { name: 'Sign in to Example App' })).toBeOnTheScreen();
10892

10993
const usernameInput = screen.getByLabelText('Username');
11094
const passwordInput = screen.getByLabelText('Password');
@@ -113,9 +97,7 @@ test('User can sign in after incorrect attempt', async () => {
11397
await user.type(passwordInput, 'qwerty123');
11498
await user.press(screen.getByRole('button', { name: 'Sign In' }));
11599

116-
expect(await screen.findByRole('alert')).toHaveTextContent(
117-
'Incorrect username or password'
118-
);
100+
expect(await screen.findByRole('alert')).toHaveTextContent('Incorrect username or password');
119101

120102
// Clear password field
121103
await user.clear(passwordInput);
@@ -124,9 +106,7 @@ test('User can sign in after incorrect attempt', async () => {
124106
await user.press(screen.getByRole('button', { name: 'Sign In' }));
125107

126108
expect(await screen.findByText('Welcome admin!')).toBeOnTheScreen();
127-
expect(
128-
screen.queryByRole('header', { name: 'Sign in to Example App' })
129-
).not.toBeOnTheScreen();
109+
expect(screen.queryByRole('header', { name: 'Sign in to Example App' })).not.toBeOnTheScreen();
130110
expect(screen.queryByLabelText('Username')).not.toBeOnTheScreen();
131111
expect(screen.queryByLabelText('Password')).not.toBeOnTheScreen();
132112
});

examples/basic/components/LoginForm.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
import * as React from 'react';
2-
import {
3-
StyleSheet,
4-
View,
5-
Text,
6-
TextInput,
7-
Pressable,
8-
ActivityIndicator,
9-
} from 'react-native';
2+
import { StyleSheet, View, Text, TextInput, Pressable, ActivityIndicator } from 'react-native';
103

114
type Props = {
125
onLoginSuccess: (user: string) => void;
@@ -84,10 +77,7 @@ export function LoginForm({ onLoginSuccess }: Props) {
8477
* @param password The password to authenticate.
8578
* @returns username if the username and password are correct, null otherwise.
8679
*/
87-
async function authUser(
88-
username: string,
89-
password: string
90-
): Promise<string | null> {
80+
async function authUser(username: string, password: string): Promise<string | null> {
9181
return new Promise((resolve) =>
9282
setTimeout(() => {
9383
const hasValidCredentials = username === 'admin' && password === 'admin1';

examples/react-navigation/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ This example shows how to write integration tests using React Navigation without
77
## Recommended tests
88

99
There are two types of recommeded tests:
10+
1011
1. Tests operating on navigator level - these use `renderNavigator` helper to render a navigator component used in the app. It is useful when you want to test a scenario that includes multiple screens.
1112
2. Tests operating on single screen level - these use regular `render` helper but require refactoring screen components into `Screen` and `ScreenContent` components. Where `Screen` receives React Navigation props and/or uses hooks like `useNavigation` while `ScreenContent` does not have a direct relation to React Navigation API but gets props from `Screen` and calls relevant callbacks to trigger navigation.
1213

1314
## Non-recommended tests
1415

15-
There also exists another popular type of screen level tests, where users mock React Navigation objects like `navigation`, `route` and/or hooks like `useNavigation`, etc. We don't recommend this way of testing. **Mocking internal parts of the libraries is effectively testing implementation details, which goes against the Testing Library's [Guiding Principles](https://testing-library.com/docs/guiding-principles/)**.
16-
16+
There also exists another popular type of screen level tests, where users mock React Navigation objects like `navigation`, `route` and/or hooks like `useNavigation`, etc. We don't recommend this way of testing. **Mocking internal parts of the libraries is effectively testing implementation details, which goes against the Testing Library's [Guiding Principles](https://testing-library.com/docs/guiding-principles/)**.

examples/react-navigation/src/DrawerNavigator.test.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ test('Changing screens', () => {
2525
expect(screen.getByRole('button', { name: 'Settings' })).toBeSelected();
2626

2727
// Assert visible screen
28-
expect(
29-
screen.getByRole('header', { name: 'Settings screen' })
30-
).toBeOnTheScreen();
31-
expect(
32-
screen.queryByRole('header', { name: 'Home screen' })
33-
).not.toBeOnTheScreen();
28+
expect(screen.getByRole('header', { name: 'Settings screen' })).toBeOnTheScreen();
29+
expect(screen.queryByRole('header', { name: 'Home screen' })).not.toBeOnTheScreen();
3430
});

examples/react-navigation/src/NativeStackNavigator.test.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ test('Home screen contains the header and list of items', () => {
99
expect(screen.getByRole('header', { name: 'Home screen' })).toBeOnTheScreen();
1010
expect(screen.getAllByRole('button', { name: /Item/ })).toHaveLength(10);
1111

12-
expect(
13-
screen.queryByRole('header', { name: /Details for item/i })
14-
).not.toBeOnTheScreen();
12+
expect(screen.queryByRole('header', { name: /Details for item/i })).not.toBeOnTheScreen();
1513
});
1614

1715
test('Pressing an item takes user to the details screen', () => {
@@ -20,15 +18,9 @@ test('Pressing an item takes user to the details screen', () => {
2018
const item5 = screen.getByRole('button', { name: 'Item 5' });
2119
fireEvent.press(item5);
2220

23-
expect(
24-
screen.getByRole('header', { name: 'Details for Item 5' })
25-
).toBeOnTheScreen();
26-
expect(
27-
screen.getByText('The number you have chosen is 5.')
28-
).toBeOnTheScreen();
21+
expect(screen.getByRole('header', { name: 'Details for Item 5' })).toBeOnTheScreen();
22+
expect(screen.getByText('The number you have chosen is 5.')).toBeOnTheScreen();
2923

3024
// Home screen is still in the element tree but it is hidden from accessibility
31-
expect(
32-
screen.queryByRole('header', { name: 'Home screen' })
33-
).not.toBeOnTheScreen();
25+
expect(screen.queryByRole('header', { name: 'Home screen' })).not.toBeOnTheScreen();
3426
});

examples/react-navigation/src/StackNavigator.test.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ test('Home screen contains the header and list of items', () => {
99
expect(screen.getByRole('header', { name: 'Home screen' })).toBeOnTheScreen();
1010
expect(screen.getAllByRole('button', { name: /Item/ })).toHaveLength(10);
1111

12-
expect(
13-
screen.queryByRole('header', { name: /Details for item/i })
14-
).not.toBeOnTheScreen();
12+
expect(screen.queryByRole('header', { name: /Details for item/i })).not.toBeOnTheScreen();
1513
});
1614

1715
test('Pressing an item takes user to the details screen', () => {
@@ -20,15 +18,9 @@ test('Pressing an item takes user to the details screen', () => {
2018
const item5 = screen.getByRole('button', { name: 'Item 5' });
2119
fireEvent.press(item5);
2220

23-
expect(
24-
screen.getByRole('header', { name: 'Details for Item 5' })
25-
).toBeOnTheScreen();
26-
expect(
27-
screen.getByText('The number you have chosen is 5.')
28-
).toBeOnTheScreen();
21+
expect(screen.getByRole('header', { name: 'Details for Item 5' })).toBeOnTheScreen();
22+
expect(screen.getByText('The number you have chosen is 5.')).toBeOnTheScreen();
2923

3024
// Home screen is still in the element tree but it is hidden from accessibility
31-
expect(
32-
screen.queryByRole('header', { name: 'Home screen' })
33-
).not.toBeOnTheScreen();
25+
expect(screen.queryByRole('header', { name: 'Home screen' })).not.toBeOnTheScreen();
3426
});

examples/react-navigation/src/TabNavigator.test.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ test('Changing tabs', () => {
1212
const settingsTab = screen.getByRole('button', { name: 'Settings' });
1313
fireEvent.press(settingsTab);
1414

15-
expect(
16-
screen.getByRole('header', { name: 'Settings screen' })
17-
).toBeOnTheScreen();
18-
expect(
19-
screen.queryByRole('header', { name: 'Home screen' })
20-
).not.toBeOnTheScreen();
15+
expect(screen.getByRole('header', { name: 'Settings screen' })).toBeOnTheScreen();
16+
expect(screen.queryByRole('header', { name: 'Home screen' })).not.toBeOnTheScreen();
2117
});

examples/react-navigation/src/screens/DetailsScreen.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import { StyleSheet, View, Text, Pressable } from 'react-native';
33

44
export default function DetailsScreen({ navigation, route }) {
55
const item = route.params;
6-
return (
7-
<DetailsScreenContent item={item} onGoBack={() => navigation.goBack()} />
8-
);
6+
return <DetailsScreenContent item={item} onGoBack={() => navigation.goBack()} />;
97
}
108

119
export function DetailsScreenContent({ item, onGoBack }) {
@@ -14,9 +12,7 @@ export function DetailsScreenContent({ item, onGoBack }) {
1412
<Text accessibilityRole="header" style={styles.header}>
1513
Details for {item.title}
1614
</Text>
17-
<Text style={styles.body}>
18-
The number you have chosen is {item.value}.
19-
</Text>
15+
<Text style={styles.body}>The number you have chosen is {item.value}.</Text>
2016

2117
<BackButton onPress={onGoBack} />
2218
</View>

examples/react-navigation/src/screens/DetailsScreen.test.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ test('Details screen contains the header and content', () => {
1414
// Passing both navigation and route to the screen as props
1515
render(<DetailsScreenContent item={item} onGoBack={onGoBack} />);
1616

17-
expect(
18-
screen.getByRole('header', { name: 'Details for Item 100' })
19-
).toBeOnTheScreen();
20-
expect(
21-
screen.getByText('The number you have chosen is 100.')
22-
).toBeOnTheScreen();
17+
expect(screen.getByRole('header', { name: 'Details for Item 100' })).toBeOnTheScreen();
18+
expect(screen.getByText('The number you have chosen is 100.')).toBeOnTheScreen();
2319

2420
// Note: Go Back button get navigation from `useNavigation` hook
2521
fireEvent.press(screen.getByRole('button', { name: 'Go Back' }));

examples/redux/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
**Note: this example is stale and might not function correctly.**
44

5-
This example shows how to write integration tests using Redux without mocking it.
5+
This example shows how to write integration tests using Redux without mocking it.

examples/redux/components/AddTodo.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ const mapStateToProps = ({ todos }) => ({
6767
todoLength: todos.length,
6868
});
6969

70-
const mapDispatchToProps = (dispatch) =>
71-
bindActionCreators({ addTodo }, dispatch);
70+
const mapDispatchToProps = (dispatch) => bindActionCreators({ addTodo }, dispatch);
7271

7372
export default connect(mapStateToProps, mapDispatchToProps)(AddTodo);

0 commit comments

Comments
 (0)