@@ -42,32 +42,40 @@ 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- - [ ] Run ` npx expo lint ` to create a ` .eslintrc.js ` file at the root of your project.
52+ You can lint your code manually by rerunning ` npx expo lint ` in your terminal.
53+
54+ - [ ] Setup ESLint in your project.
55+ - [ ] Run ` npx expo lint ` in your terminal.
5556
57+ ### Prettier
58+
59+ For other packages managers
5660``` console
57- npx expo lint
61+ npx expo install -- --save-dev prettier eslint-config-prettier eslint-plugin-prettier
5862```
5963
60- - [ ] Update your ` .eslintrc.js ` file to add the following rules:
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:
6172
6273``` javascript
63- // .eslintrc.js
6474module .exports = {
65- extends: [" expo" , " react-native-wcandillon" ],
66- plugins: [" @tanstack/query" ],
67- requireConfigFile: false ,
75+ extends: [" expo" , " prettier" ],
76+ plugins: [" prettier" ],
6877 rules: {
69- camelcase: " off" ,
70- " import/no-anonymous-default-export" : [1 , { allowArray: true }],
78+ " prettier/prettier" : " warn" ,
7179 },
7280};
7381```
@@ -118,6 +126,9 @@ We are making progress, but we are not done yet. We need to add rules for React
118126``` console
119127npm install --dev prettier eslint-config-prettier eslint-plugin-prettier eslint-plugin-react eslint-plugin-react-native eslint-plugin-simple-import-sort
120128```
129+ ``` console
130+ yarn add -D prettier eslint-config-prettier eslint-plugin-prettier eslint-plugin-react eslint-plugin-react-native eslint-plugin-simple-import-sort
131+ ```
121132
122133- [ ] Update your ` .eslintrc.js ` file to add the following rules:
123134
@@ -167,7 +178,9 @@ module.exports = {
167178 [" ^\\ ./(?=.*/)(?!/?$)" , " ^\\ .(?!/?$)" , " ^\\ ./?$" ],
168179 ]
169180 }
170- ]
181+ ],
182+ quotes: [" error" , " double" ], // enforce double quotes
183+ " react/no-unescaped-entities" : " off" , // Disable the rule
171184 }
172185};
173186```
@@ -188,7 +201,6 @@ module.exports = {
188201}
189202```
190203
191- - [ ] Run ` --fix ` to automatically fix your errors.
192204- [ ] if you encounter a difference between errors on your terminal and VSCode, reload VSCode with ` ⌘ + ⇧ + P ` "Developer: Reload Window".
193205
194206### Updating ESLint rules
@@ -205,7 +217,7 @@ In our case `cargo_capacity`, `cost_in_credits` are not using `camelCase` and we
205217{
206218 "rules" : {
207219 ...
208- " camelcase" : " off" , // disable camelcase rule
220+ camelcase: "off", // disable camelcase rule
209221 "@typescript-eslint/no-explicit-any" : " warn" // detect usage of `any` type
210222 },
211223}
0 commit comments