Skip to content

Commit 04f2838

Browse files
authored
[MOB-9138] Add ESLint + Prettier (#802)
* Add ESLint + Prettier * Fix Format * Remove ESLint from Example * Fix Automatic Lint Issues * Fix Equality Issues * Fix Undefined Variables * Fix Duplicate Tests Description * Remove Unused Vars * Fix New Function Error * Fix Shadowing * Remove Inline Styles * Fix Nested Components * Enforce `const` * Add Lint CI Job * Scope `env` to test files * Extract `TabBarIcon` to its own Component * Separate Jest and Detox Overrides * Enforce Sorted Imports * Update Scripts * Format All Files * Fix More Formatting Issues
1 parent 5f0e223 commit 04f2838

Some content is hidden

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

63 files changed

+1841
-1534
lines changed

.circleci/config.yml

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@ jobs:
99
steps:
1010
- checkout
1111
- run: danger
12+
13+
lint:
14+
working_directory: ~/project
15+
docker:
16+
- image: cimg/node:16.17.1
17+
steps:
18+
- checkout
19+
- run:
20+
name: Install Node Packages
21+
command: yarn
22+
- run:
23+
name: Check Format
24+
command: yarn format
25+
- run:
26+
name: Check Lint
27+
command: yarn lint:ci
28+
1229
test_module:
1330
working_directory: ~/project
1431
docker:
@@ -28,7 +45,7 @@ jobs:
2845
yarn run test
2946
environment:
3047
JEST_JUNIT_OUTPUT: test-results/jest/junit.xml
31-
48+
3249
- codecov/upload:
3350
flags: javascript
3451

@@ -46,7 +63,7 @@ jobs:
4663
test_android:
4764
executor:
4865
name: android/android-machine
49-
tag: "2022.03.1"
66+
tag: '2022.03.1'
5067
working_directory: ~/project
5168
steps:
5269
- checkout:
@@ -80,7 +97,7 @@ jobs:
8097
command: bash -n ios/upload_sourcemap.sh
8198

8299
# Make sure that files like yarn.lock and project.pbxproj
83-
# are in sync with the latest changes in package.json and
100+
# are in sync with the latest changes in package.json and
84101
# ios/upload_sourcemap.sh files respectively.
85102
sync_generated_files:
86103
macos:
@@ -120,7 +137,7 @@ jobs:
120137
e2e_ios:
121138
macos:
122139
xcode: 13.4.1
123-
resource_class: large
140+
resource_class: large
124141
working_directory: ~/project
125142
environment:
126143
FL_OUTPUT_DIR: output
@@ -164,12 +181,12 @@ jobs:
164181
e2e_android:
165182
executor:
166183
name: android/android-machine
167-
tag: "2022.03.1"
184+
tag: 2022.03.1
168185
resource-class: large
169186
working_directory: ~/project
170187
steps:
171188
- checkout
172-
- run:
189+
- run:
173190
name: Install Yarn
174191
command: npm install --global yarn
175192
- run:
@@ -194,18 +211,18 @@ jobs:
194211
no-window: true
195212
memory: 2048
196213
post-emulator-launch-assemble-command: |
197-
rm -rf ~/.gradle/caches
198-
cd ~/project/example/android && ./gradlew androidDependencies
199-
cd .. && detox build -c android.emu.release
214+
rm -rf ~/.gradle/caches
215+
cd ~/project/example/android && ./gradlew androidDependencies
216+
cd .. && detox build -c android.emu.release
200217
- run:
201218
name: Detox - Run E2E Tests
202219
working_directory: example
203220
command: detox test -c android.emu.release
204221

205222
publish:
206223
macos:
207-
xcode: "13.4.1"
208-
working_directory: "~"
224+
xcode: 13.4.1
225+
working_directory: ~
209226
steps:
210227
- checkout:
211228
path: ~/project
@@ -219,6 +236,7 @@ workflows:
219236
publish:
220237
jobs:
221238
- danger
239+
- lint
222240
- test_module
223241
- test_android
224242
- validate_shell_files
@@ -228,6 +246,8 @@ workflows:
228246
- e2e_android
229247
- hold:
230248
requires:
249+
- danger
250+
- lint
231251
- test_module
232252
- test_android
233253
- validate_shell_files

.eslintrc.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/** @type {import('eslint').ESLint.ConfigData} */
2+
module.exports = {
3+
extends: '@react-native-community',
4+
plugins: ['prettier', 'jest'],
5+
overrides: [
6+
{
7+
// Jest Overrides
8+
files: ['tests/**'],
9+
env: {
10+
node: true,
11+
browser: true,
12+
'jest/globals': true,
13+
},
14+
},
15+
{
16+
// Detox Overrides
17+
files: ['example/e2e/**.js'],
18+
env: {
19+
'jest/globals': true,
20+
},
21+
globals: {
22+
device: false,
23+
waitFor: false,
24+
element: false,
25+
by: false,
26+
},
27+
},
28+
],
29+
rules: {
30+
'prettier/prettier': 'error',
31+
'prefer-const': 'error',
32+
},
33+
};

.github/dependabot.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
version: 2
22

33
updates:
4-
- package-ecosystem: "npm"
5-
directory: "/"
4+
- package-ecosystem: npm
5+
directory: /
66
schedule:
7-
interval: "weekly"
7+
interval: weekly
88
ignore:
9-
- dependency-name: "*"
10-
update-types: ["version-update:semver-major"]
9+
- dependency-name: '*'
10+
update-types: [version-update:semver-major]

.github/issue_template.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<!--
2-
Please fill in the template below when creating an issue
2+
Please fill in the template below when creating an issue
33
to help us reproduce it and fix it faster.
44
5-
While not required, including a sample project that reproduces
5+
While not required, including a sample project that reproduces
66
your issue will help us a lot.
77
-->
88

@@ -13,15 +13,19 @@ your issue will help us a lot.
1313
### Actual Behavior
1414

1515
### Instabug integration code
16+
1617
<!--Make sure to remove your app token.-->
1718

1819
### SDK Version
20+
1921
<!--Which version of Instabug React Native are you on?.-->
2022

2123
### React Native, iOS and Android Versions
2224

2325
### Device Model
26+
2427
<!--If this issue is happening on specific devices, please mention them.-->
2528

2629
### [Optional] Project That Reproduces the Issue
30+
2731
<!--While not required, providing a sample project that reproduces the issue you're having will help us solve it much faster.-->

.github/pull_request_template.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
## Description of the change
2+
23
> Description goes here
4+
35
## Type of change
6+
47
- [ ] Bug fix (non-breaking change that fixes an issue)
58
- [ ] New feature (non-breaking change that adds functionality)
69
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
10+
711
## Related issues
12+
813
> Issue links go here
14+
915
## Checklists
16+
1017
### Development
18+
1119
- [ ] Lint rules pass locally
1220
- [ ] The code changed/added as part of this pull request has been covered with tests
13-
### Code review
21+
22+
### Code review
23+
1424
- [ ] This pull request has a descriptive title and information useful to a reviewer
15-
- [ ] Issue from task tracker has a link to this pull request
25+
- [ ] Issue from task tracker has a link to this pull request

.prettierrc.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1+
/** @type {import('prettier').Config} */
12
module.exports = {
2-
arrowParens : 'avoid',
3-
bracketSameLine : true,
4-
printWidth : 100,
5-
singleQuote : true,
6-
trailingComma : 'all',
3+
semi: true,
4+
singleQuote: true,
5+
bracketSameLine: true,
6+
useTabs: false,
7+
tabWidth: 2,
8+
trailingComma: 'all',
9+
endOfLine: 'auto',
10+
printWidth: 100,
11+
importOrder: ['mocks', '^react(-native)?(/.*)?$', '<THIRD_PARTY_MODULES>', '^[./]'],
12+
importOrderSeparation: true,
13+
importOrderSortSpecifiers: true,
714
};
8-

0 commit comments

Comments
 (0)