Skip to content

Commit 3de4675

Browse files
committed
Add "check-all" script
1 parent e8a4e9f commit 3de4675

File tree

8 files changed

+62
-43
lines changed

8 files changed

+62
-43
lines changed

CONTRIBUTING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,25 @@
2828
2. Select your device in the devices drop-down
2929
3. Hit run
3030

31+
## Committing
32+
33+
We love to keep our codebases clean. To achieve that, we use linters and formatters which output errors when something isn't formatted the way we like it to be.
34+
35+
Before pushing your changes, you can verify that everything is still correctly formatted by running all linters:
36+
37+
```
38+
yarn check-all
39+
```
40+
41+
This validates Swift, Kotlin, C++ and JS/TS code:
42+
43+
```bash
44+
$ yarn check-all
45+
yarn run v1.22.10
46+
Formatting Swift code..
47+
Linting Swift code..
48+
Linting Kotlin code..
49+
Linting JS/TS code..
50+
All done!
51+
✨ Done in 8.05s.
52+
```

android/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,13 @@ This folder contains the Android-platform-specific code for react-native-vision-
1414
It is recommended that you work on the code using the Example project (`example/android/`), since that always includes the React Native header files, plus you can easily test changes that way.
1515

1616
You can however still edit the library project here by opening this folder with Android Studio.
17+
18+
## Committing
19+
20+
Before committing, make sure that you're not violating the Kotlin codestyles. To do that, run the following command:
21+
22+
```bash
23+
yarn check-android
24+
```
25+
26+
This will also try to automatically fix any errors by re-formatting the Kotlin code.

ios/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,13 @@ This folder contains the iOS-platform-specific code for react-native-vision-came
1818
It is recommended that you work on the code using the Example project (`example/ios/VisionCameraExample.xcworkspace`), since that always includes the React Native header files, plus you can easily test changes that way.
1919

2020
You can however still edit the library project here by opening `VisionCamera.xcodeproj`, this has the advantage of **automatically formatting your Code** (swiftformat) and **showing you Linter errors** (swiftlint) when trying to build (<kbd></kbd>+<kbd>B</kbd>).
21+
22+
## Committing
23+
24+
Before committing, make sure that you're not violating the Swift or C++ codestyles. To do that, run the following command:
25+
26+
```bash
27+
yarn check-ios
28+
```
29+
30+
This will also try to automatically fix any errors by re-formatting the Swift code.

package.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,11 @@
3535
"example": "yarn --cwd example",
3636
"pods": "cd example && pod-install --quiet",
3737
"bootstrap": "yarn example && yarn && yarn pods",
38-
"ktlint": "scripts/ktlint.sh",
39-
"swiftlint": "scripts/swiftlint.sh",
40-
"swiftformat": "scripts/swiftformat.sh",
38+
"check-android": "scripts/ktlint.sh",
39+
"check-ios": "scripts/swiftformat.sh && scripts/swiftlint.sh",
40+
"check-all": "scripts/checkall.sh",
4141
"docs": "cd docs && yarn build"
4242
},
43-
"pre-commit": [
44-
"swiftformat"
45-
],
4643
"keywords": [
4744
"react-native",
4845
"ios",
@@ -85,7 +82,6 @@
8582
"eslint-plugin-react-native": "^3.10.0",
8683
"jest": "^26.0.1",
8784
"pod-install": "^0.1.0",
88-
"pre-commit": "^1.2.2",
8985
"prettier": "^2.2.1",
9086
"react": "17.0.1",
9187
"react-native": "0.63.4",

scripts/check-all.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
echo "Formatting Swift code.."
4+
./scripts/swiftformat.sh
5+
6+
echo "Linting Swift code.."
7+
./scripts/swiftlint.sh
8+
9+
echo "Linting Kotlin code.."
10+
./scripts/ktlint.sh
11+
12+
echo "Linting JS/TS code.."
13+
yarn lint --fix
14+
15+
echo "All done!"

scripts/swiftformat.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
if which swiftformat >/dev/null; then
4-
cd ios && swiftformat .
4+
cd ios && swiftformat --quiet .
55
else
66
echo "warning: SwiftFormat not installed, download from https://github.com/nicklockwood/SwiftFormat"
77
fi

scripts/swiftlint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
if which swiftlint >/dev/null; then
4-
cd ios && swiftlint --fix && swiftlint
4+
cd ios && swiftlint --quiet --fix && swiftlint --quiet
55
else
66
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
77
fi

yarn.lock

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,14 +1896,6 @@
18961896
"@typescript-eslint/typescript-estree" "4.17.0"
18971897
debug "^4.1.1"
18981898

1899-
"@typescript-eslint/[email protected]":
1900-
version "4.16.1"
1901-
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.16.1.tgz#244e2006bc60cfe46987e9987f4ff49c9e3f00d5"
1902-
integrity sha512-6IlZv9JaurqV0jkEg923cV49aAn8V6+1H1DRfhRcvZUrptQ+UtSKHb5kwTayzOYTJJ/RsYZdcvhOEKiBLyc0Cw==
1903-
dependencies:
1904-
"@typescript-eslint/types" "4.16.1"
1905-
"@typescript-eslint/visitor-keys" "4.16.1"
1906-
19071899
"@typescript-eslint/[email protected]":
19081900
version "4.17.0"
19091901
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.17.0.tgz#f4edf94eff3b52a863180f7f89581bf963e3d37d"
@@ -1917,11 +1909,6 @@
19171909
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-3.10.1.tgz#1d7463fa7c32d8a23ab508a803ca2fe26e758727"
19181910
integrity sha512-+3+FCUJIahE9q0lDi1WleYzjCwJs5hIsbugIgnbB+dSCYUxl8L6PwmsyOPFZde2hc1DlTo/xnkOgiTLSyAbHiQ==
19191911

1920-
"@typescript-eslint/[email protected]":
1921-
version "4.16.1"
1922-
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.16.1.tgz#5ba2d3e38b1a67420d2487519e193163054d9c15"
1923-
integrity sha512-nnKqBwMgRlhzmJQF8tnFDZWfunXmJyuXj55xc8Kbfup4PbkzdoDXZvzN8//EiKR27J6vUSU8j4t37yUuYPiLqA==
1924-
19251912
"@typescript-eslint/[email protected]":
19261913
version "4.17.0"
19271914
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.17.0.tgz#f57d8fc7f31b348db946498a43050083d25f40ad"
@@ -1941,19 +1928,6 @@
19411928
semver "^7.3.2"
19421929
tsutils "^3.17.1"
19431930

1944-
"@typescript-eslint/[email protected]":
1945-
version "4.16.1"
1946-
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.16.1.tgz#c2fc46b05a48fbf8bbe8b66a63f0a9ba04b356f1"
1947-
integrity sha512-m8I/DKHa8YbeHt31T+UGd/l8Kwr0XCTCZL3H4HMvvLCT7HU9V7yYdinTOv1gf/zfqNeDcCgaFH2BMsS8x6NvJg==
1948-
dependencies:
1949-
"@typescript-eslint/types" "4.16.1"
1950-
"@typescript-eslint/visitor-keys" "4.16.1"
1951-
debug "^4.1.1"
1952-
globby "^11.0.1"
1953-
is-glob "^4.0.1"
1954-
semver "^7.3.2"
1955-
tsutils "^3.17.1"
1956-
19571931
"@typescript-eslint/[email protected]":
19581932
version "4.17.0"
19591933
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.17.0.tgz#b835d152804f0972b80dbda92477f9070a72ded1"
@@ -1974,14 +1948,6 @@
19741948
dependencies:
19751949
eslint-visitor-keys "^1.1.0"
19761950

1977-
"@typescript-eslint/[email protected]":
1978-
version "4.16.1"
1979-
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.16.1.tgz#d7571fb580749fae621520deeb134370bbfc7293"
1980-
integrity sha512-s/aIP1XcMkEqCNcPQtl60ogUYjSM8FU2mq1O7y5cFf3Xcob1z1iXWNB6cC43Op+NGRTFgGolri6s8z/efA9i1w==
1981-
dependencies:
1982-
"@typescript-eslint/types" "4.16.1"
1983-
eslint-visitor-keys "^2.0.0"
1984-
19851951
"@typescript-eslint/[email protected]":
19861952
version "4.17.0"
19871953
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.17.0.tgz#9c304cfd20287c14a31d573195a709111849b14d"

0 commit comments

Comments
 (0)