Skip to content

Commit

Permalink
Merge branch 'development' into pip-enter-leave-programmatically
Browse files Browse the repository at this point in the history
# Conflicts:
#	ios/RNPlayerViewManager.swift
  • Loading branch information
rolandkakonyi committed Oct 17, 2023
2 parents d343bf3 + 7b8c7bc commit 31ba779
Show file tree
Hide file tree
Showing 28 changed files with 780 additions and 359 deletions.
8 changes: 8 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

if [[ "$(uname -m)" == arm64 ]]; then
export PATH="/opt/homebrew/bin:$PATH"
fi

yarn lint-staged

if [ "$(uname)" == "Darwin" ]; then
swiftlint lint --strict
fi
165 changes: 165 additions & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
excluded:
# folders that are excluded from linting, external dependencies or generated files
- ${PWD}/example/ios/Pods

disabled_rules:
- todo
- trailing_comma
- inclusive_language

opt_in_rules:
# performance
- contains_over_filter_count
- contains_over_filter_is_empty
- contains_over_first_not_nil
- contains_over_range_nil_comparison
- empty_collection_literal
- empty_count
- empty_string
- first_where
- flatmap_over_map_reduce
- last_where
- reduce_into
- sorted_first_last

# idiomatic
- explicit_init
- fallthrough
- force_unwrapping
- function_default_parameter_at_end
- implicitly_unwrapped_optional
- redundant_nil_coalescing
- convenience_type
- extension_access_modifier
- fatal_error_message
- file_name
- file_name_no_space
- legacy_multiple
- legacy_random
- pattern_matching_keywords
- redundant_type_annotation
- toggle_bool
- unavailable_function
- xct_specific_matcher
- return_value_from_void_function
- shorthand_optional_binding
- explicit_top_level_acl

#lint
- overridden_super_call
- empty_xctest_method
- identical_operands
- lower_acl_than_parent
- override_in_extension
- quick_discouraged_call
- quick_discouraged_focused_test
- yoda_condition
- private_subject
- weak_delegate

#style
- attributes
- closure_end_indentation
- closure_spacing
- collection_alignment
- implicit_return
# - indentation_width # causing a lot of false positives, see: https://github.com/realm/SwiftLint/issues/3046
- literal_expression_end_indentation
- modifier_order
- multiline_arguments
- multiline_arguments_brackets
- multiline_literal_brackets
- multiline_function_chains
- multiline_parameters
- multiline_parameters_brackets
- number_separator
- operator_usage_whitespace
- optional_enum_case_matching
- single_test_class
- sorted_imports
- switch_case_on_newline
- trailing_closure
- unneeded_parentheses_in_closure_argument
- vertical_parameter_alignment_on_call
- vertical_whitespace_closing_braces
- vertical_whitespace_opening_braces
- prefer_self_in_static_references
- comma_inheritance
- self_binding

deployment_target:
iOS_deployment_target: 13.99
tvOS_deployment_target: 13.99
type_name:
allowed_symbols: '_'
min_length:
warning: 4
max_length:
warning: 40
error: 50
excluded:
- Ads
- Xml
- Url
identifier_name:
allowed_symbols: '_'
min_length:
error: 3
excluded:
- Ads
- Ad
- ad
- id
- to
- on
compiler_protocol_init:
severity: error
line_length:
ignores_urls: true
file_length:
warning: 500
custom_rules:
nimble_discourage_be:
included: ".*Tests/.*\\.swift"
name: 'Discouraged be()'
regex: '\W(be)\('
capture_group: 1
message: 'Prefer beIdentical() or equal() over be() when using Nimble to make expectations explicit'
severity: error
nimble_discourage_count_0:
included: ".*Tests/.*\\.swift"
name: 'Discouraged .count with equal(0)'
regex: '\.count\)(\\n|\s)*\.(to|toNot|toEventually|toEventuallyNot|toNotEventually)\((\\n|\s)*equal\(0\)(\\n|\s)*\)'
message: 'Prefer beEmpty() over direct access to .count with equal(0)'
severity: error
nimble_discourage_havecount_0:
included: ".*Tests/.*\\.swift"
name: 'Discouraged haveCount(0)'
regex: '\.(to|toNot|toEventually|toEventuallyNot|toNotEventually)\((\\n|\s)*haveCount\(0\)(\\n|\s)*\)'
message: 'Prefer beEmpty() over using haveCount(0)'
severity: error
nimble_discourage_count_equal:
included: ".*Tests/.*\\.swift"
name: 'Discouraged .count with equal()'
regex: '\.count\)(\\n|\s)*\.(to|toNot|toEventually|toEventuallyNot|toNotEventually)\((\\n|\s)*equal\([^0]'
message: 'Prefer haveCount() over direct access to .count with equal()'
severity: error
nimble_discourage_truthy_falsy:
included: ".*Tests/.*\\.swift"
name: 'Discouraged beTruthy()/beFalsy()'
regex: '(beTruthy|beFalsy)\(\)'
capture_group: 1
message: 'Prefer beTrue()/beFalse() usage over beTruthy()/beFalsy()'
severity: error
non_breaking_whitespaces:
included: '.*'
name: 'Non-breaking whitespaces'
regex: '\x{00A0}'
message: 'Non-breaking space (U+00A0) used instead of regular space'
severity: error
final_tests:
included: ".*Tests/.*\\.swift"
name: 'Final test cases'
regex: '^class .*: (QuickSpec|XCTestCase|QuickPlayerTest) \{'
message: 'Make test classes final to make them run faster'
severity: error
1 change: 1 addition & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
brew "swiftlint"
62 changes: 62 additions & 0 deletions Brewfile.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"entries": {
"brew": {
"swiftlint": {
"version": "0.53.0",
"bottle": {
"rebuild": 0,
"root_url": "https://ghcr.io/v2/homebrew/core",
"files": {
"arm64_sonoma": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:240ccda9de55d948d0c635798079074099bfcb73ffda41428900fdc748aeea7b",
"sha256": "240ccda9de55d948d0c635798079074099bfcb73ffda41428900fdc748aeea7b"
},
"arm64_ventura": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:7b7ceb7896c6833965cc4eac9001255d8adde6c5432045d5a8ab6aea8a9e81d9",
"sha256": "7b7ceb7896c6833965cc4eac9001255d8adde6c5432045d5a8ab6aea8a9e81d9"
},
"arm64_monterey": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:78c2a4c3f4a2f6847b484527b0f0f916da71e3ee29e49890fd44b63fe7b38e26",
"sha256": "78c2a4c3f4a2f6847b484527b0f0f916da71e3ee29e49890fd44b63fe7b38e26"
},
"sonoma": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:abdca78dd8a8bd268053b3be195fe891bb74aef5502ab3a6b871ae0c6bb04540",
"sha256": "abdca78dd8a8bd268053b3be195fe891bb74aef5502ab3a6b871ae0c6bb04540"
},
"ventura": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:be711c707bf3b49fa0dd6e2ae576b309aad620f9b56a2c6e7b1ac5cf35cf652a",
"sha256": "be711c707bf3b49fa0dd6e2ae576b309aad620f9b56a2c6e7b1ac5cf35cf652a"
},
"monterey": {
"cellar": ":any_skip_relocation",
"url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:13487d68a971dbe035019364e19d70641af2a18c06e52925d238685b384a7979",
"sha256": "13487d68a971dbe035019364e19d70641af2a18c06e52925d238685b384a7979"
},
"x86_64_linux": {
"cellar": "/home/linuxbrew/.linuxbrew/Cellar",
"url": "https://ghcr.io/v2/homebrew/core/swiftlint/blobs/sha256:fbbc56fccfcfcd34564feb7325567e2ff3638d3c609396a5c4aa13311c7b26e0",
"sha256": "fbbc56fccfcfcd34564feb7325567e2ff3638d3c609396a5c4aa13311c7b26e0"
}
}
}
}
}
},
"system": {
"macos": {
"sonoma": {
"HOMEBREW_VERSION": "4.1.15",
"HOMEBREW_PREFIX": "/opt/homebrew",
"Homebrew/homebrew-core": "api",
"CLT": "15.0.0.0.1.1694021235",
"Xcode": "15.0",
"macOS": "14.0"
}
}
}
}
22 changes: 20 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ To edit the Kotlin files, open `example/android` in Android Studio and find the

## TypeScript Code Style

- Follow the `eslint` rules (`yarn lint`). They are inforced automatically via a pre-commit git hook.
- Follow the `eslint` rules (`yarn lint`). They are enforced automatically via a pre-commit git hook.
- Always add return values to functions (even if `void`)
- No unused imports
- Public functions should be documented with a description that explains _what_ it does
Expand All @@ -61,7 +61,7 @@ To edit the Kotlin files, open `example/android` in Android Studio and find the

We use [TypeScript](https://www.typescriptlang.org/) for type checking, [ESLint](https://eslint.org/) with [Prettier](https://prettier.io/) for linting and formatting the code, and [Jest](https://jestjs.io/) for testing.

Our pre-commit hooks verify that the linter and tests pass when committing.
Our pre-commit hooks verify that the linter will pass when committing.
Make sure your code passes TypeScript and ESLint. Run the following to verify:

```sh
Expand Down Expand Up @@ -102,6 +102,24 @@ and for automatic pre-commit formatting:
./gradlew addKtlintFormatGitPreCommitHook
```

### Swift

For Swift code [SwiftLint](https://github.com/realm/SwiftLint) is used.
To install SwiftLint, run `brew bundle install` in the root directory.
Our pre-commit hooks verify that the linter will pass when committing.

To verify Swift code, run the following:

```sh
swiftlint
```

To fix auto-fixable SwiftLint violations, run the following:

```sh
swiftlint lint --autocorrect
```

## Testing

Remember to add tests for your change if possible. Run the unit tests by:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "BitmovinPlayerReactNativeExample" */;
buildPhases = (
5E3559E12AFFB82ED8822C46 /* [CP] Check Pods Manifest.lock */,
A8979BB02ADD2D9500821960 /* SwiftLint */,
13B07F871A680F5B00A75B9A /* Sources */,
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
Expand All @@ -175,6 +176,7 @@
buildConfigurationList = 4CE3830228BFD10E002DDF82 /* Build configuration list for PBXNativeTarget "BitmovinPlayerReactNativeExample-tvOS" */;
buildPhases = (
3D81CB9D0E05C6D400C2E01A /* [CP] Check Pods Manifest.lock */,
A8979BB12ADD2DB500821960 /* SwiftLint */,
4CE382EA28BFD10C002DDF82 /* Sources */,
4CE382EB28BFD10C002DDF82 /* Frameworks */,
4CE382EC28BFD10C002DDF82 /* Resources */,
Expand Down Expand Up @@ -437,6 +439,46 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-BitmovinPlayerReactNativeExample/Pods-BitmovinPlayerReactNativeExample-resources.sh\"\n";
showEnvVarsInLog = 0;
};
A8979BB02ADD2D9500821960 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = SwiftLint;
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n\n(\n cd ../../\n if which swiftlint > /dev/null; then\n swiftlint\n else\n echo \"warning: SwiftLint not installed, run \\`brew bundle install\\` in project root to install\"\n fi\n)\n";
showEnvVarsInLog = 0;
};
A8979BB12ADD2DB500821960 /* SwiftLint */ = {
isa = PBXShellScriptBuildPhase;
alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = SwiftLint;
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if [[ \"$(uname -m)\" == arm64 ]]; then\n export PATH=\"/opt/homebrew/bin:$PATH\"\nfi\n\n(\n cd ../../\n if which swiftlint > /dev/null; then\n swiftlint\n else\n echo \"warning: SwiftLint not installed, run \\`brew bundle install\\` in project root to install\"\n fi\n)\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -583,4 +583,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: ce9c500fa6db0491e44c441b93bc9aa6bc652f0a

COCOAPODS: 1.12.1
COCOAPODS: 1.13.0
Loading

0 comments on commit 31ba779

Please sign in to comment.