Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre-commit hook and linters for Android and iOS code #2114

Merged
merged 29 commits into from
Oct 11, 2022

Conversation

j-piasecki
Copy link
Member

@j-piasecki j-piasecki commented Jun 27, 2022

Description

This PR:

  • Removes unnecessary .gitignore, build.gradle and proguard-rules.pro files from the lib/ directory. I believe those were leftovers from when Gesture Handler could be used as a native Android library
  • Adds Gradle wrapper in the android/ directory
  • Adds Spotless for linting the Android code, similarly to how it's done in Screens
  • Adds .clang-format for linting the iOS code, the config is the same as in Screens and Reanimated
  • Adds a pre-commit hook similarly to how it's implemented in Screens
  • Adds workflow that lints Android code
  • Formats Android code so that it passes spotlessCheck

While this PR formats Android code, it doesn't modify the iOS one. On Android there weren't that many changes and the number of affected files was low. On iOS there are more changes needed in more files. The idea behind that is that the changed files from now on will have to be reformatted, so the style changes will be more gradual without one huge commit changing the whole codebase. After some time we could make one commit that updates the remaining files, which should result in a clearer history.

Also, at some point in the future we should think about updating the prettier version the root project is using to match the one in example apps, although it would require reformatting the code. This would allow for handling core, Example and FabricExample code using the same lint-staged rule, instead of each one of those having their own.

@kacperkapusciak kacperkapusciak self-requested a review August 12, 2022 10:15
Copy link
Member

@kacperkapusciak kacperkapusciak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of comments. Overall LGTM 👍

.github/workflows/kotlin-lint.yml Outdated Show resolved Hide resolved
.github/workflows/kotlin-lint.yml Show resolved Hide resolved
@kacperkapusciak kacperkapusciak self-requested a review October 5, 2022 13:57
Copy link
Member

@kacperkapusciak kacperkapusciak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :shipit:

There's a tiny side-effect that anyone who will commit anything iOS related after this PR is merged will be greeted with reformating of all the obj-c code

image

@j-piasecki j-piasecki merged commit 6dcc759 into main Oct 11, 2022
@j-piasecki j-piasecki deleted the @jpiasecki/spotless-kotlin branch October 11, 2022 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants