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

feat: adding swiftlint #1085

Merged
merged 14 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Setup & Lint Package

on:
pull_request:
branches:
- master

# Only run on the latest workflow run
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
setup-and-lint-package:
runs-on: macos-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Enable corepack
run: corepack enable

- name: Install CocoaPods
run: sudo gem install cocoapods

- name: Install Dependencies
run: yarn install --immutable

- name: Build project
run: yarn setup

- name: SwiftLint
run: yarn lint:swift
15 changes: 13 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Contributions are welcome and are greatly appreciated! Every little bit helps, and credit will
always be given.


## Setting up your environment

After forking to your own github org, do the following steps to get started:
Expand Down Expand Up @@ -56,6 +55,19 @@ codebase, however you can always check to see if the source code is compliant by
npm run lint
```

For linting the native iOS package, we are using [Swift lint](https://github.com/realm/SwiftLint). You need to install it on your machine using the following command:

```bash
brew install swiftlint
```

And then you can run it by calling it from JS using:

```bash
yarn lint:swift
```

Or let it work on its own, as it is part of the build phases for the iOS project

### Building Docs

Expand All @@ -69,7 +81,6 @@ After this, you can open up your browser to the specified port (usually http://l

The browser will automatically refresh when there are changes to any of the source files.


## Pull Request Guidelines

Before you submit a pull request from your forked repo, check that it meets these guidelines:
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"fabric:ios": "yarn workspace fabric-example ios",
"paper:android": "yarn workspace paper-example android",
"paper:ios": "yarn workspace paper-example ios",
"lint:swift": "yarn workspace lottie-react-native lint:swift",
"docs:clean": "rimraf _book",
"docs:prepare": "gitbook install",
"docs:build": "yarn docs:prepare && gitbook build",
Expand Down
6 changes: 6 additions & 0 deletions packages/core/ios/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
disabled_rules:
- line_length
- identifier_name
type_body_length:
- 300
- 400
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ class AnimationViewManagerModule: RCTViewManager {
return ContainerView()
}

@objc override func constantsToExport() -> [AnyHashable : Any]! {
@objc override func constantsToExport() -> [AnyHashable: Any]! {
return ["VERSION": 1]
}

@objc(play:fromFrame:toFrame:)
public func play(_ reactTag: NSNumber, startFrame: NSNumber, endFrame: NSNumber) {
self.bridge.uiManager.addUIBlock { (uiManager, viewRegistry) in
self.bridge.uiManager.addUIBlock { (_, viewRegistry) in
guard let view = viewRegistry?[reactTag] as? ContainerView else {
if (RCT_DEBUG == 1) {
if RCT_DEBUG == 1 {
print("Invalid view returned from registry, expecting ContainerView")
}
return
}

if (startFrame.intValue != -1 && endFrame.intValue != -1) {
if startFrame.intValue != -1 && endFrame.intValue != -1 {
view.play(fromFrame: AnimationFrameTime(truncating: startFrame), toFrame: AnimationFrameTime(truncating: endFrame))
} else {
view.play()
Expand All @@ -42,9 +42,9 @@ class AnimationViewManagerModule: RCTViewManager {

@objc(reset:)
public func reset(_ reactTag: NSNumber) {
self.bridge.uiManager.addUIBlock { uiManager, viewRegistry in
self.bridge.uiManager.addUIBlock { _, viewRegistry in
guard let view = viewRegistry?[reactTag] as? ContainerView else {
if (RCT_DEBUG == 1) {
if RCT_DEBUG == 1 {
print("Invalid view returned from registry, expecting ContainerView")
}
return
Expand All @@ -56,9 +56,9 @@ class AnimationViewManagerModule: RCTViewManager {

@objc(pause:)
public func pause(_ reactTag: NSNumber) {
self.bridge.uiManager.addUIBlock { uiManager, viewRegistry in
self.bridge.uiManager.addUIBlock { _, viewRegistry in
guard let view = viewRegistry?[reactTag] as? ContainerView else {
if (RCT_DEBUG == 1) {
if RCT_DEBUG == 1 {
print("Invalid view returned from registry, expecting ContainerView")
}
return
Expand All @@ -70,9 +70,9 @@ class AnimationViewManagerModule: RCTViewManager {

@objc(resume:)
public func resume(_ reactTag: NSNumber) {
self.bridge.uiManager.addUIBlock { uiManager, viewRegistry in
self.bridge.uiManager.addUIBlock { _, viewRegistry in
guard let view = viewRegistry?[reactTag] as? ContainerView else {
if (RCT_DEBUG == 1) {
if RCT_DEBUG == 1 {
print("Invalid view returned from registry, expecting ContainerView")
}
return
Expand Down