Skip to content

Commit 98c14b4

Browse files
authored
chore: add CI for JS, iOS and Android formatting (software-mansion#1782)
Added CI workflow and local pre-commit hook for formatting and linting the newly added JS, iOS and Android code.
1 parent 77267be commit 98c14b4

File tree

177 files changed

+16873
-16036
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

177 files changed

+16873
-16036
lines changed

.clang-format

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
AccessModifierOffset: -1
3+
AlignAfterOpenBracket: AlwaysBreak
4+
AlignConsecutiveAssignments: false
5+
AlignConsecutiveDeclarations: false
6+
AlignEscapedNewlinesLeft: true
7+
AlignOperands: false
8+
AlignTrailingComments: false
9+
AllowAllParametersOfDeclarationOnNextLine: false
10+
AllowShortBlocksOnASingleLine: false
11+
AllowShortCaseLabelsOnASingleLine: false
12+
AllowShortFunctionsOnASingleLine: Empty
13+
AllowShortIfStatementsOnASingleLine: false
14+
AllowShortLoopsOnASingleLine: false
15+
AlwaysBreakAfterReturnType: None
16+
AlwaysBreakBeforeMultilineStrings: true
17+
AlwaysBreakTemplateDeclarations: true
18+
BinPackArguments: false
19+
BinPackParameters: false
20+
BraceWrapping:
21+
AfterClass: false
22+
AfterControlStatement: false
23+
AfterEnum: false
24+
AfterFunction: false
25+
AfterNamespace: false
26+
AfterObjCDeclaration: false
27+
AfterStruct: false
28+
AfterUnion: false
29+
BeforeCatch: false
30+
BeforeElse: false
31+
IndentBraces: false
32+
BreakBeforeBinaryOperators: None
33+
BreakBeforeBraces: Attach
34+
BreakBeforeTernaryOperators: true
35+
BreakConstructorInitializersBeforeComma: false
36+
BreakAfterJavaFieldAnnotations: false
37+
BreakStringLiterals: false
38+
ColumnLimit: 80
39+
CommentPragmas: '^ IWYU pragma:'
40+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
41+
ConstructorInitializerIndentWidth: 4
42+
ContinuationIndentWidth: 4
43+
Cpp11BracedListStyle: true
44+
DerivePointerAlignment: false
45+
DisableFormat: false
46+
ForEachMacros: [ FOR_EACH_RANGE, FOR_EACH, ]
47+
IncludeCategories:
48+
- Regex: '^<.*\.h(pp)?>'
49+
Priority: 1
50+
- Regex: '^<.*'
51+
Priority: 2
52+
- Regex: '.*'
53+
Priority: 3
54+
IndentCaseLabels: true
55+
IndentWidth: 2
56+
IndentWrappedFunctionNames: false
57+
KeepEmptyLinesAtTheStartOfBlocks: false
58+
MacroBlockBegin: ''
59+
MacroBlockEnd: ''
60+
MaxEmptyLinesToKeep: 1
61+
NamespaceIndentation: None
62+
ObjCBlockIndentWidth: 2
63+
ObjCSpaceAfterProperty: true
64+
ObjCSpaceBeforeProtocolList: true
65+
PenaltyBreakBeforeFirstCallParameter: 1
66+
PenaltyBreakComment: 300
67+
PenaltyBreakFirstLessLess: 120
68+
PenaltyBreakString: 1000
69+
PenaltyExcessCharacter: 1000000
70+
PenaltyReturnTypeOnItsOwnLine: 200
71+
PointerAlignment: Right
72+
ReflowComments: true
73+
SortIncludes: true
74+
SpaceAfterCStyleCast: false
75+
SpaceBeforeAssignmentOperators: true
76+
SpaceBeforeParens: ControlStatements
77+
SpaceInEmptyParentheses: false
78+
SpacesBeforeTrailingComments: 1
79+
SpacesInAngles: false
80+
SpacesInContainerLiterals: true
81+
SpacesInCStyleCastParentheses: false
82+
SpacesInParentheses: false
83+
SpacesInSquareBrackets: false
84+
Standard: Cpp11
85+
TabWidth: 8
86+
UseTab: Never
87+
---
88+
Language: ObjC
89+
ColumnLimit: 120
90+
BreakBeforeBraces: WebKit
91+
...

.github/workflows/js-build-test.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,8 @@ jobs:
2525
run: yarn
2626
- name: Build
2727
run: yarn bob
28-
- name: Lint
29-
run: yarn lint
30-
- name: Tests
31-
run: yarn jest
28+
- name: Test and lint
29+
run: yarn test
3230
- name: Build Example App
3331
working-directory: Example/
3432
run: yarn && yarn tsc

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
yarn lint-staged

Example/ios/Podfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ SPEC CHECKSUMS:
501501
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
502502
DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662
503503
FBLazyVector: bcdeff523be9f87a135b7c6fde8736db94904716
504-
FBReactNativeSpec: 226f8b0f1a2e736a49301883ee34bca88cdc24f6
504+
FBReactNativeSpec: 0c3f104f594b34d7b3a923cd12e03b0d4e12eaf5
505505
Flipper: 26fc4b7382499f1281eb8cb921e5c3ad6de91fe0
506506
Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c
507507
Flipper-DoubleConversion: 57ffbe81ef95306cc9e69c4aa3aeeeeb58a6a28c

USAGE.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ export default function TestComponent() {
105105
};
106106
return (
107107
<>
108-
<SvgUri
109-
width="100"
110-
height="100"
111-
uri="https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/ruby.svg"
112-
onError={onError}
113-
onLoad={onLoad}
114-
/>
115-
{loading && <ActivityIndicator size="large" color="#0000ff"/>}
108+
<SvgUri
109+
width="100"
110+
height="100"
111+
uri="https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/ruby.svg"
112+
onError={onError}
113+
onLoad={onLoad}
114+
/>
115+
{loading && <ActivityIndicator size="large" color="#0000ff" />}
116116
</>
117117
);
118118
}
@@ -129,16 +129,20 @@ import * as React from 'react';
129129
import { SvgUri } from 'react-native-svg';
130130

131131
export default () => {
132-
const [uri, setUri] = React.useState('https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/not_existing.svg')
132+
const [uri, setUri] = React.useState(
133+
'https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/not_existing.svg',
134+
);
133135
return (
134136
<SvgUri
135-
onError={() => setUri('https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/ruby.svg')}
137+
onError={() =>
138+
setUri('https://dev.w3.org/SVG/tools/svgweb/samples/svg-files/ruby.svg')
139+
}
136140
width="100%"
137141
height="100%"
138142
uri={uri}
139143
/>
140144
);
141-
}
145+
};
142146
```
143147

144148
# Use with svg files

android/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ buildscript {
1010

1111
dependencies {
1212
classpath("com.android.tools.build:gradle:3.6.1")
13+
classpath "com.diffplug.spotless:spotless-plugin-gradle:5.15.0"
1314
}
1415
}
1516
}
@@ -26,6 +27,10 @@ if (isNewArchitectureEnabled()) {
2627
apply plugin: "com.facebook.react"
2728
}
2829

30+
if (project == rootProject) {
31+
apply from: 'spotless.gradle'
32+
}
33+
2934
apply plugin: 'com.android.library'
3035

3136
def safeExtGet(prop, fallback) {
59.3 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)