Skip to content

Commit 9319be0

Browse files
authored
Merge branch 'main' into feature/netinfo
2 parents 7cc3f72 + 742955d commit 9319be0

Some content is hidden

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

72 files changed

+9109
-5471
lines changed

challenges/ecosystem/02.md

Lines changed: 104 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -42,30 +42,41 @@ Prettier is an opinionated code formatter. It enforces a consistent style by par
4242

4343
![Prettier format on save preview on VS Code](https://raw.githubusercontent.com/flexbox/react-native-workshop/main/challenges/ecosystem/format-on-save.png)
4444

45-
### Setup ESLint rules for React Native project
4645

47-
- [ ] Install ESLint as a dev dependency.
46+
### Setup ESLint in your expo project
4847

4948
```console
50-
npm install --dev eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser
51-
# same as `yarn add --dev eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser`
49+
npx expo lint
5250
```
5351

54-
- [ ] Create a `.eslintrc.js` file at the root of your project with the following content: (you can use `touch .eslintrc.js` from the terminal).
52+
You can lint your code manually by rerunning `npx expo lint` in your terminal.
5553

56-
```javascript
57-
// .eslintrc.js
54+
- [ ] Setup ESLint in your project.
55+
- [ ] Run `npx expo lint` in your terminal.
5856

57+
### Prettier
58+
59+
For other packages managers
60+
```console
61+
npx expo install -- --save-dev prettier eslint-config-prettier eslint-plugin-prettier
62+
```
63+
64+
For yarn
65+
```console
66+
yarn add -D prettier eslint-config-prettier eslint-plugin-prettier
67+
```
68+
69+
- [ ] add the dependencies to your project.
70+
71+
- [ ] Update your `eslintrc.js` file to add the following rules:
72+
73+
```javascript
5974
module.exports = {
60-
env: {
61-
node: true
75+
extends: ["expo", "prettier"],
76+
plugins: ["prettier"],
77+
rules: {
78+
"prettier/prettier": "warn",
6279
},
63-
parser: "@typescript-eslint/parser",
64-
root: true,
65-
extends: [
66-
"eslint:recommended",
67-
"plugin:@typescript-eslint/recommended",
68-
],
6980
};
7081
```
7182

@@ -113,7 +124,10 @@ We are making progress, but we are not done yet. We need to add rules for React
113124
- [ ] Install the following plugins
114125

115126
```console
116-
npm install --dev prettier eslint-config-prettier eslint-plugin-prettier eslint-plugin-react eslint-plugin-react-native eslint-plugin-simple-import-sort
127+
npm install --dev prettier eslint-config-prettier eslint-plugin-prettier eslint-plugin-react
128+
```
129+
```console
130+
yarn add -D prettier eslint-config-prettier eslint-plugin-prettier eslint-plugin-react
117131
```
118132

119133
- [ ] Update your `.eslintrc.js` file to add the following rules:
@@ -134,37 +148,15 @@ module.exports = {
134148
"plugin:react/jsx-runtime", // support for React 17 JSX
135149
"plugin:prettier/recommended" // Prettier recommended rules
136150
],
137-
plugins: ["react", "react-native", "simple-import-sort"], // add React and React Native plugins
151+
plugins: ["react"], // add React and React Native plugins
138152
rules: {
139153
"prettier/prettier": [ // Prettier rules
140154
"warn",
141155
{
142156
usePrettierrc: true
143157
}
144158
],
145-
"react-native/no-color-literals": 2, // enforce color literals are not used
146-
"react-native/no-unused-styles": 2, // detect unused StyleSheet rules
147-
"react-native/no-raw-text": 0, // detect raw text outside of Text component
148-
"react-native/sort-styles": 2, // enforce style definitions are sorted
149159
"@typescript-eslint/no-unused-vars": "warn", // detect unused variables
150-
"simple-import-sort/exports": "warn", // enforce sorting exports within module
151-
"simple-import-sort/imports": [
152-
"warn",
153-
{
154-
groups: [
155-
// Side effect imports.
156-
["^\\u0000"],
157-
// Packages `react` related packages come first.
158-
["^react", "^@?\\w"],
159-
// Environment variables
160-
["^(@env)(/.*|$)"],
161-
// Parent imports. Put `..` last.
162-
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
163-
// Other relative imports. Put same-folder imports and `.` last.
164-
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
165-
]
166-
}
167-
]
168160
}
169161
};
170162
```
@@ -185,11 +177,80 @@ module.exports = {
185177
}
186178
```
187179

188-
- [ ] Run `--fix` to automatically fix your errors.
189180
- [ ] if you encounter a difference between errors on your terminal and VSCode, reload VSCode with `⌘ + ⇧ + P` "Developer: Reload Window".
190181

191182
### Updating ESLint rules
192183

184+
We want to add some rules to our ESLint configuration.
185+
186+
```console
187+
npm install --dev eslint-plugin-react-native
188+
```
189+
```console
190+
yarn add -D eslint-plugin-react-native
191+
```
192+
193+
- [ ] Update your `.eslintrc.js` file to add the following react-native rules:
194+
195+
```json
196+
// .eslintrc.js
197+
198+
{
199+
plugins: ["react", "react-native"],
200+
"rules": {
201+
...
202+
"react-native/no-color-literals": 2, // enforce color literals are not used
203+
"react-native/no-unused-styles": 2, // detect unused StyleSheet rules
204+
"react-native/no-raw-text": 0, // detect raw text outside of Text component
205+
"react-native/sort-styles": 2, // enforce style definitions are sorted
206+
},
207+
}
208+
```
209+
210+
- [ ] Lint your code and push your changes to GitHub.
211+
212+
We now want to sort our imports automatically. We can use the `simple-import-sort` plugin.
213+
214+
```console
215+
npm install --dev eslint-plugin-simple-import-sort
216+
```
217+
```console
218+
yarn add -D eslint-plugin-simple-import-sort
219+
```
220+
221+
- [ ] Update your `.eslintrc.js` file to add the following import rules:
222+
223+
```json
224+
// .eslintrc.js
225+
226+
{
227+
"rules": {
228+
plugins: ["react", "react-native", "eslint-plugin-simple-import-sort"],
229+
...
230+
"simple-import-sort/exports": "warn", // enforce sorting exports within module
231+
"simple-import-sort/imports": [
232+
"warn",
233+
{
234+
groups: [
235+
// Side effect imports.
236+
["^\\u0000"],
237+
// Packages `react` related packages come first.
238+
["^react", "^@?\\w"],
239+
// Environment variables
240+
["^(@env)(/.*|$)"],
241+
// Parent imports. Put `..` last.
242+
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
243+
// Other relative imports. Put same-folder imports and `.` last.
244+
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
245+
]
246+
}
247+
],
248+
},
249+
}
250+
```
251+
252+
- [ ] Lint your code and push your changes to GitHub.
253+
193254
We have no control on the api data we are pulling from SWAPI. Sometimes we want to update our rules to reflect differences.
194255

195256
In our case `cargo_capacity`, `cost_in_credits` are not using `camelCase` and we want to disable this rule.
@@ -202,12 +263,14 @@ In our case `cargo_capacity`, `cost_in_credits` are not using `camelCase` and we
202263
{
203264
"rules": {
204265
...
205-
"camelcase": "off", // disable camelcase rule
266+
camelcase: "off", // disable camelcase rule
206267
"@typescript-eslint/no-explicit-any": "warn" // detect usage of `any` type
207268
},
208269
}
209270
```
210271

272+
- [ ] Lint your code and push your changes to GitHub.
273+
211274
## 👽 Bonus
212275

213276
You can share your VSCode settings with your team by adding a `.vscode` folder at the root of your project with the following content:

challenges/foundation/02.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,5 @@ Create a better UX to show/hide the password:
135135
- [ ] Add a function to toggle the password visibility.
136136

137137
![password](https://raw.githubusercontent.com/flexbox/react-native-workshop/main/challenges/foundation/password.gif)
138+
139+
- [ ] Check [`Expo.new`](https://expo.dev/onboarding/hello) and try to create a new project. It will setup and deploy everything for you.

challenges/foundation/05.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -162,25 +162,4 @@ import { ScreenContainer } from "~/components/ScreenContainer";
162162
}
163163
```
164164

165-
- [ ] install `babel-plugin-root-import` with
166165

167-
```console
168-
npm install babel-plugin-root-import
169-
```
170-
171-
- [ ] Open your `babel.config.js` file and add plugins array section:
172-
173-
```diff
174-
return {
175-
presets: ['babel-preset-expo'],
176-
plugins: [
177-
[
178-
"babel-plugin-root-import",
179-
{
180-
rootPathPrefix: "~/",
181-
rootPathSuffix: "./src/",
182-
},
183-
],
184-
],
185-
};
186-
```

challenges/react-navigation/02.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,10 @@ You can use these component to make it pretty:
3939

4040
- [ ] Change the `screenOptions` to display your screen as a `modal`.
4141
- [ ] Add a "close modal" Button with an icon.
42+
- [ ] Add [`expo-dev-tools`](https://docs.expo.dev/debugging/devtools-plugins/#expo-dev-tools-plugins) to your project
43+
44+
- [ ] Look with the `expo-dev-tools` the `route` and `params` of the screen.
45+
46+
Start the project with and open the `expo-dev-tools` with `?` and `shift + m` in your terminal to open the menu and select `@dev-plugins/react-navigation`.
47+
48+
Now you can navigate in your app and see the `route` and `params` of the screen.

challenges/release/04.md

Lines changed: 0 additions & 88 deletions
This file was deleted.

hackathon/spacecraft/.eslintrc

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)