Add "check-all" script

This commit is contained in:
Marc Rousavy 2021-03-09 12:19:18 +01:00
parent e8a4e9f6b5
commit 3de4675592
8 changed files with 62 additions and 43 deletions

View File

@ -28,3 +28,25 @@
2. Select your device in the devices drop-down
3. Hit run
## Committing
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.
Before pushing your changes, you can verify that everything is still correctly formatted by running all linters:
```
yarn check-all
```
This validates Swift, Kotlin, C++ and JS/TS code:
```bash
$ yarn check-all
yarn run v1.22.10
Formatting Swift code..
Linting Swift code..
Linting Kotlin code..
Linting JS/TS code..
All done!
✨ Done in 8.05s.
```

View File

@ -14,3 +14,13 @@ This folder contains the Android-platform-specific code for react-native-vision-
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.
You can however still edit the library project here by opening this folder with Android Studio.
## Committing
Before committing, make sure that you're not violating the Kotlin codestyles. To do that, run the following command:
```bash
yarn check-android
```
This will also try to automatically fix any errors by re-formatting the Kotlin code.

View File

@ -18,3 +18,13 @@ This folder contains the iOS-platform-specific code for react-native-vision-came
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.
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>).
## Committing
Before committing, make sure that you're not violating the Swift or C++ codestyles. To do that, run the following command:
```bash
yarn check-ios
```
This will also try to automatically fix any errors by re-formatting the Swift code.

View File

@ -35,14 +35,11 @@
"example": "yarn --cwd example",
"pods": "cd example && pod-install --quiet",
"bootstrap": "yarn example && yarn && yarn pods",
"ktlint": "scripts/ktlint.sh",
"swiftlint": "scripts/swiftlint.sh",
"swiftformat": "scripts/swiftformat.sh",
"check-android": "scripts/ktlint.sh",
"check-ios": "scripts/swiftformat.sh && scripts/swiftlint.sh",
"check-all": "scripts/checkall.sh",
"docs": "cd docs && yarn build"
},
"pre-commit": [
"swiftformat"
],
"keywords": [
"react-native",
"ios",
@ -85,7 +82,6 @@
"eslint-plugin-react-native": "^3.10.0",
"jest": "^26.0.1",
"pod-install": "^0.1.0",
"pre-commit": "^1.2.2",
"prettier": "^2.2.1",
"react": "17.0.1",
"react-native": "0.63.4",

15
scripts/check-all.sh Executable file
View File

@ -0,0 +1,15 @@
#!/bin/bash
echo "Formatting Swift code.."
./scripts/swiftformat.sh
echo "Linting Swift code.."
./scripts/swiftlint.sh
echo "Linting Kotlin code.."
./scripts/ktlint.sh
echo "Linting JS/TS code.."
yarn lint --fix
echo "All done!"

View File

@ -1,7 +1,7 @@
#!/bin/bash
if which swiftformat >/dev/null; then
cd ios && swiftformat .
cd ios && swiftformat --quiet .
else
echo "warning: SwiftFormat not installed, download from https://github.com/nicklockwood/SwiftFormat"
fi

View File

@ -1,7 +1,7 @@
#!/bin/bash
if which swiftlint >/dev/null; then
cd ios && swiftlint --fix && swiftlint
cd ios && swiftlint --quiet --fix && swiftlint --quiet
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi

View File

@ -1896,14 +1896,6 @@
"@typescript-eslint/typescript-estree" "4.17.0"
debug "^4.1.1"
"@typescript-eslint/scope-manager@4.16.1":
version "4.16.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.16.1.tgz#244e2006bc60cfe46987e9987f4ff49c9e3f00d5"
integrity sha512-6IlZv9JaurqV0jkEg923cV49aAn8V6+1H1DRfhRcvZUrptQ+UtSKHb5kwTayzOYTJJ/RsYZdcvhOEKiBLyc0Cw==
dependencies:
"@typescript-eslint/types" "4.16.1"
"@typescript-eslint/visitor-keys" "4.16.1"
"@typescript-eslint/scope-manager@4.17.0":
version "4.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-4.17.0.tgz#f4edf94eff3b52a863180f7f89581bf963e3d37d"
@ -1917,11 +1909,6 @@
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-3.10.1.tgz#1d7463fa7c32d8a23ab508a803ca2fe26e758727"
integrity sha512-+3+FCUJIahE9q0lDi1WleYzjCwJs5hIsbugIgnbB+dSCYUxl8L6PwmsyOPFZde2hc1DlTo/xnkOgiTLSyAbHiQ==
"@typescript-eslint/types@4.16.1":
version "4.16.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.16.1.tgz#5ba2d3e38b1a67420d2487519e193163054d9c15"
integrity sha512-nnKqBwMgRlhzmJQF8tnFDZWfunXmJyuXj55xc8Kbfup4PbkzdoDXZvzN8//EiKR27J6vUSU8j4t37yUuYPiLqA==
"@typescript-eslint/types@4.17.0":
version "4.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.17.0.tgz#f57d8fc7f31b348db946498a43050083d25f40ad"
@ -1941,19 +1928,6 @@
semver "^7.3.2"
tsutils "^3.17.1"
"@typescript-eslint/typescript-estree@4.16.1":
version "4.16.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.16.1.tgz#c2fc46b05a48fbf8bbe8b66a63f0a9ba04b356f1"
integrity sha512-m8I/DKHa8YbeHt31T+UGd/l8Kwr0XCTCZL3H4HMvvLCT7HU9V7yYdinTOv1gf/zfqNeDcCgaFH2BMsS8x6NvJg==
dependencies:
"@typescript-eslint/types" "4.16.1"
"@typescript-eslint/visitor-keys" "4.16.1"
debug "^4.1.1"
globby "^11.0.1"
is-glob "^4.0.1"
semver "^7.3.2"
tsutils "^3.17.1"
"@typescript-eslint/typescript-estree@4.17.0":
version "4.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.17.0.tgz#b835d152804f0972b80dbda92477f9070a72ded1"
@ -1974,14 +1948,6 @@
dependencies:
eslint-visitor-keys "^1.1.0"
"@typescript-eslint/visitor-keys@4.16.1":
version "4.16.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.16.1.tgz#d7571fb580749fae621520deeb134370bbfc7293"
integrity sha512-s/aIP1XcMkEqCNcPQtl60ogUYjSM8FU2mq1O7y5cFf3Xcob1z1iXWNB6cC43Op+NGRTFgGolri6s8z/efA9i1w==
dependencies:
"@typescript-eslint/types" "4.16.1"
eslint-visitor-keys "^2.0.0"
"@typescript-eslint/visitor-keys@4.17.0":
version "4.17.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-4.17.0.tgz#9c304cfd20287c14a31d573195a709111849b14d"