Skip to content

Commit 499d751

Browse files
committed
Add format-js
1 parent 9b845bd commit 499d751

6 files changed

Lines changed: 1173 additions & 1196 deletions

File tree

apps/BasicExample/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"start": "react-native start",
1010
"test": "jest",
1111
"ts-check": "yarn tsc --noEmit",
12-
"lint-js": "eslint --ext '.js,.ts,.tsx' src/ && yarn prettier --check './src/**/*.{js,jsx,ts,tsx}'"
12+
"lint-js": "eslint --ext '.js,.ts,.tsx' src/ && yarn prettier --check './src/**/*.{js,jsx,ts,tsx}'",
13+
"format-js": "prettier --write --list-different './src/**/*.{js,jsx,ts,tsx}'"
1314
},
1415
"dependencies": {
1516
"react": "19.0.0",

apps/CommonApp/App.tsx

Lines changed: 72 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useEffect} from 'react';
1+
import React, { useEffect } from 'react';
22
import {
33
Text,
44
View,
@@ -13,7 +13,7 @@ import {
1313
StackNavigationProp,
1414
StackScreenProps,
1515
} from '@react-navigation/stack';
16-
import {NavigationContainer, ParamListBase} from '@react-navigation/native';
16+
import { NavigationContainer, ParamListBase } from '@react-navigation/native';
1717
import {
1818
GestureHandlerRootView,
1919
RectButton,
@@ -24,7 +24,7 @@ import OverflowParent from './src/release_tests/overflowParent';
2424
import DoublePinchRotate from './src/release_tests/doubleScalePinchAndRotate';
2525
import DoubleDraggable from './src/release_tests/doubleDraggable';
2626
import GesturizedPressable from './src/release_tests/gesturizedPressable';
27-
import {ComboWithGHScroll} from './src/release_tests/combo';
27+
import { ComboWithGHScroll } from './src/release_tests/combo';
2828
import {
2929
TouchablesIndex,
3030
TouchableExample,
@@ -43,10 +43,10 @@ import TwoFingerPan from './src/release_tests/twoFingerPan';
4343
import SvgCompatibility from './src/release_tests/svg';
4444
import NestedText from './src/release_tests/nestedText';
4545

46-
import {PinchableBox} from './src/recipes/scaleAndRotate';
46+
import { PinchableBox } from './src/recipes/scaleAndRotate';
4747
import PanAndScroll from './src/recipes/panAndScroll';
4848

49-
import {BottomSheet} from './src/showcase/bottomSheet';
49+
import { BottomSheet } from './src/showcase/bottomSheet';
5050
import Swipeables from './src/showcase/swipeable';
5151
import ChatHeads from './src/showcase/chatHeads';
5252

@@ -79,16 +79,16 @@ import Pressable from './src/new_api/pressable';
7979

8080
import EmptyExample from './src/empty/EmptyExample';
8181
import RectButtonBorders from './src/release_tests/rectButton';
82-
import {ListWithHeader} from './src/ListWithHeader';
83-
import {COLORS} from './src/common';
82+
import { ListWithHeader } from './src/ListWithHeader';
83+
import { COLORS } from './src/common';
8484

8585
import MacosDraggable from './src/simple/draggable';
8686
import Tap from './src/simple/tap';
8787
import LongPressExample from './src/simple/longPress';
8888
import ManualExample from './src/simple/manual';
8989
import SimpleFling from './src/simple/fling';
9090

91-
import {Icon} from '@swmansion/icons';
91+
import { Icon } from '@swmansion/icons';
9292

9393
interface Example {
9494
name: string;
@@ -103,23 +103,23 @@ interface ExamplesSection {
103103
const EXAMPLES: ExamplesSection[] = [
104104
{
105105
sectionTitle: 'Empty',
106-
data: [{name: 'Empty Example', component: EmptyExample}],
106+
data: [{ name: 'Empty Example', component: EmptyExample }],
107107
},
108108
{
109109
sectionTitle: 'New api',
110110
data: [
111-
{name: 'Ball with velocity', component: VelocityTest},
112-
{name: 'Camera', component: Camera},
113-
{name: 'Transformations', component: Transformations},
114-
{name: 'Overlap', component: Overlap},
115-
{name: 'Bottom Sheet', component: BottomSheetNewApi},
116-
{name: 'Calculator', component: Calculator},
117-
{name: 'Chat Heads', component: ChatHeadsNewApi},
118-
{name: 'Drag and drop', component: DragNDrop},
119-
{name: 'New Swipeable', component: Swipeable},
120-
{name: 'Pressable', component: Pressable},
121-
{name: 'Hover', component: Hover},
122-
{name: 'Hoverable icons', component: HoverableIcons},
111+
{ name: 'Ball with velocity', component: VelocityTest },
112+
{ name: 'Camera', component: Camera },
113+
{ name: 'Transformations', component: Transformations },
114+
{ name: 'Overlap', component: Overlap },
115+
{ name: 'Bottom Sheet', component: BottomSheetNewApi },
116+
{ name: 'Calculator', component: Calculator },
117+
{ name: 'Chat Heads', component: ChatHeadsNewApi },
118+
{ name: 'Drag and drop', component: DragNDrop },
119+
{ name: 'New Swipeable', component: Swipeable },
120+
{ name: 'Pressable', component: Pressable },
121+
{ name: 'Hover', component: Hover },
122+
{ name: 'Hoverable icons', component: HoverableIcons },
123123
{
124124
name: 'Horizontal Drawer (Reanimated 2 & RNGH 2)',
125125
component: BetterHorizontalDrawer,
@@ -133,11 +133,11 @@ const EXAMPLES: ExamplesSection[] = [
133133
{
134134
sectionTitle: 'Basic examples',
135135
data: [
136-
{name: 'Draggable', component: Draggable},
137-
{name: 'Multitap', component: MultiTap},
138-
{name: 'Bouncing box', component: BouncingBox},
139-
{name: 'Pan responder', component: PanResponder},
140-
{name: 'Horizontal drawer', component: HorizontalDrawer},
136+
{ name: 'Draggable', component: Draggable },
137+
{ name: 'Multitap', component: MultiTap },
138+
{ name: 'Bouncing box', component: BouncingBox },
139+
{ name: 'Pan responder', component: PanResponder },
140+
{ name: 'Horizontal drawer', component: HorizontalDrawer },
141141
{
142142
name: 'Pager & drawer',
143143
component: PagerAndDrawer,
@@ -148,22 +148,22 @@ const EXAMPLES: ExamplesSection[] = [
148148
component: ForceTouch,
149149
unsupportedPlatforms: new Set(['web', 'android', 'macos']),
150150
},
151-
{name: 'Fling', component: Fling},
151+
{ name: 'Fling', component: Fling },
152152
],
153153
},
154154
{
155155
sectionTitle: 'Recipes',
156156
data: [
157-
{name: 'Pinch & rotate', component: PinchableBox},
158-
{name: 'Pan & scroll', component: PanAndScroll},
157+
{ name: 'Pinch & rotate', component: PinchableBox },
158+
{ name: 'Pan & scroll', component: PanAndScroll },
159159
],
160160
},
161161
{
162162
sectionTitle: 'Showcase',
163163
data: [
164-
{name: 'Bottom sheet', component: BottomSheet},
165-
{name: 'Swipeables', component: Swipeables},
166-
{name: 'Chat heads', component: ChatHeads},
164+
{ name: 'Bottom sheet', component: BottomSheet },
165+
{ name: 'Swipeables', component: Swipeables },
166+
{ name: 'Chat heads', component: ChatHeads },
167167
],
168168
},
169169
{
@@ -194,33 +194,33 @@ const EXAMPLES: ExamplesSection[] = [
194194
name: 'Svg integration with Gesture Handler',
195195
component: SvgCompatibility,
196196
},
197-
{name: 'Double pinch & rotate', component: DoublePinchRotate},
198-
{name: 'Double draggable', component: DoubleDraggable},
199-
{name: 'Rows', component: Rows},
200-
{name: 'Nested Fling', component: NestedFling},
197+
{ name: 'Double pinch & rotate', component: DoublePinchRotate },
198+
{ name: 'Double draggable', component: DoubleDraggable },
199+
{ name: 'Rows', component: Rows },
200+
{ name: 'Nested Fling', component: NestedFling },
201201
{
202202
name: 'Combo',
203203
component: ComboWithGHScroll,
204204
unsupportedPlatforms: new Set(['web']),
205205
},
206-
{name: 'Touchables', component: TouchablesIndex as React.ComponentType},
207-
{name: 'MouseButtons', component: MouseButtons},
206+
{ name: 'Touchables', component: TouchablesIndex as React.ComponentType },
207+
{ name: 'MouseButtons', component: MouseButtons },
208208
{
209209
name: 'ContextMenu',
210210
component: ContextMenu,
211211
unsupportedPlatforms: new Set(['android', 'ios', 'macos']),
212212
},
213-
{name: 'PointerType', component: PointerType},
214-
{name: 'Reanimated Drawer Layout', component: ReanimatedDrawerLayout},
215-
{name: 'Swipeable Reanimation', component: SwipeableReanimation},
216-
{name: 'RectButton (borders)', component: RectButtonBorders},
217-
{name: 'Gesturized pressable', component: GesturizedPressable},
213+
{ name: 'PointerType', component: PointerType },
214+
{ name: 'Reanimated Drawer Layout', component: ReanimatedDrawerLayout },
215+
{ name: 'Swipeable Reanimation', component: SwipeableReanimation },
216+
{ name: 'RectButton (borders)', component: RectButtonBorders },
217+
{ name: 'Gesturized pressable', component: GesturizedPressable },
218218
{
219219
name: 'Web styles reset',
220220
component: WebStylesResetExample,
221221
unsupportedPlatforms: new Set(['android', 'ios', 'macos']),
222222
},
223-
{name: 'Stylus data', component: StylusData},
223+
{ name: 'Stylus data', component: StylusData },
224224
{
225225
name: 'Two finger Pan',
226226
component: TwoFingerPan,
@@ -236,11 +236,11 @@ const EXAMPLES: ExamplesSection[] = [
236236
{
237237
sectionTitle: 'Simple',
238238
data: [
239-
{name: 'Simple Draggable', component: MacosDraggable},
240-
{name: 'Tap', component: Tap},
241-
{name: 'LongPress', component: LongPressExample},
242-
{name: 'Manual', component: ManualExample},
243-
{name: 'Simple Fling', component: SimpleFling},
239+
{ name: 'Simple Draggable', component: MacosDraggable },
240+
{ name: 'Tap', component: Tap },
241+
{ name: 'LongPress', component: LongPressExample },
242+
{ name: 'Manual', component: ManualExample },
243+
{ name: 'Simple Fling', component: SimpleFling },
244244
],
245245
},
246246
];
@@ -250,7 +250,7 @@ const LAST_EXAMPLE_KEY = 'lastExample';
250250

251251
type RootStackParamList = {
252252
Home: undefined;
253-
TouchableExample: {item: string};
253+
TouchableExample: { item: string };
254254
} & {
255255
[Screen: string]: undefined;
256256
};
@@ -277,17 +277,19 @@ export default function App() {
277277
}}>
278278
<Stack.Screen
279279
name="Home"
280-
options={{headerShown: false}}
280+
options={{ headerShown: false }}
281281
component={MainScreen}
282282
/>
283-
{EXAMPLES.flatMap(({data}) => data).flatMap(({name, component}) => (
284-
<Stack.Screen
285-
key={name}
286-
name={name}
287-
getComponent={() => component}
288-
options={{title: name}}
289-
/>
290-
))}
283+
{EXAMPLES.flatMap(({ data }) => data).flatMap(
284+
({ name, component }) => (
285+
<Stack.Screen
286+
key={name}
287+
name={name}
288+
getComponent={() => component}
289+
options={{ title: name }}
290+
/>
291+
)
292+
)}
291293
<Stack.Screen name="TouchableExample" component={TouchableExample} />
292294
</Stack.Navigator>
293295
</NavigationContainer>
@@ -297,20 +299,20 @@ export default function App() {
297299

298300
function navigate(
299301
navigation: StackNavigationProp<ParamListBase>,
300-
dest: string,
302+
dest: string
301303
) {
302304
AsyncStorage.setItem(LAST_EXAMPLE_KEY, dest);
303305
navigation.navigate(dest);
304306
}
305307

306-
function MainScreen({navigation}: StackScreenProps<ParamListBase>) {
308+
function MainScreen({ navigation }: StackScreenProps<ParamListBase>) {
307309
useEffect(() => {
308310
AsyncStorage.multiGet([OPEN_LAST_EXAMPLE_KEY, LAST_EXAMPLE_KEY]).then(
309311
([openLastExample, lastExample]) => {
310312
if (openLastExample[1] === 'true' && lastExample[1]) {
311313
navigate(navigation, lastExample[1]);
312314
}
313-
},
315+
}
314316
);
315317
// we only want to run this effect once
316318
// eslint-disable-next-line react-hooks/exhaustive-deps
@@ -321,16 +323,16 @@ function MainScreen({navigation}: StackScreenProps<ParamListBase>) {
321323
<ListWithHeader
322324
style={styles.list}
323325
sections={EXAMPLES}
324-
keyExtractor={example => example.name}
326+
keyExtractor={(example) => example.name}
325327
ListHeaderComponent={OpenLastExampleSetting}
326-
renderItem={({item}) => (
328+
renderItem={({ item }) => (
327329
<MainScreenItem
328330
name={item.name}
329-
onPressItem={name => navigate(navigation, name)}
331+
onPressItem={(name) => navigate(navigation, name)}
330332
enabled={!item.unsupportedPlatforms?.has(Platform.OS)}
331333
/>
332334
)}
333-
renderSectionHeader={({section: {sectionTitle}}) => (
335+
renderSectionHeader={({ section: { sectionTitle } }) => (
334336
<Text style={styles.sectionTitle}>{sectionTitle}</Text>
335337
)}
336338
ItemSeparatorComponent={() => <View style={styles.separator} />}
@@ -343,7 +345,7 @@ function OpenLastExampleSetting() {
343345
const [openLastExample, setOpenLastExample] = React.useState(false);
344346

345347
useEffect(() => {
346-
AsyncStorage.getItem(OPEN_LAST_EXAMPLE_KEY).then(value => {
348+
AsyncStorage.getItem(OPEN_LAST_EXAMPLE_KEY).then((value) => {
347349
setOpenLastExample(value === 'true');
348350
});
349351
}, []);
@@ -380,7 +382,7 @@ interface MainScreenItemProps {
380382
enabled: boolean;
381383
}
382384

383-
function MainScreenItem({name, onPressItem, enabled}: MainScreenItemProps) {
385+
function MainScreenItem({ name, onPressItem, enabled }: MainScreenItemProps) {
384386
return (
385387
<RectButton
386388
enabled={enabled}
@@ -400,7 +402,7 @@ const styles = StyleSheet.create({
400402
backgroundColor: COLORS.offWhite,
401403
},
402404
sectionTitle: {
403-
...(Platform.OS !== 'macos' ? {backgroundColor: '#f8f9ff'} : {}),
405+
...(Platform.OS !== 'macos' ? { backgroundColor: '#f8f9ff' } : {}),
404406
...Platform.select({
405407
ios: {
406408
fontSize: 17,
@@ -447,7 +449,7 @@ const styles = StyleSheet.create({
447449
...(Platform.OS !== 'macos'
448450
? {
449451
shadowColor: '#000',
450-
shadowOffset: {width: 0, height: 2},
452+
shadowOffset: { width: 0, height: 2 },
451453
shadowOpacity: 0.25,
452454
shadowRadius: 3.84,
453455
}

apps/CommonApp/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"start": "react-native start",
1010
"test": "jest",
1111
"ts-check": "yarn tsc --noEmit",
12-
"lint-js": "eslint --ext '.js,.ts,.tsx' src/ && yarn prettier --check './src/**/*.{js,jsx,ts,tsx}'"
12+
"lint-js": "eslint --ext '.js,.ts,.tsx' src/ && yarn prettier --check './src/**/*.{js,jsx,ts,tsx}'",
13+
"format-js": "prettier --write --list-different App.tsx './src/**/*.{js,jsx,ts,tsx}'"
1314
},
1415
"dependencies": {
1516
"@react-native-async-storage/async-storage": "^2.1.2",

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"scripts": {
1313
"postinstall": "husky",
1414
"ts-check": "yarn workspaces foreach --all --parallel --topological-dev run ts-check",
15-
"lint-js": "yarn workspaces foreach --all --parallel --topological-dev run lint-js"
15+
"lint-js": "yarn workspaces foreach --all --parallel --topological-dev run lint-js",
16+
"format-js": "yarn workspaces foreach --all --parallel --topological-dev run format-js"
1617
},
1718
"devDependencies": {
1819
"@types/react": "^19.0.12",

packages/react-native-gesture-handler/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"build": "yarn tsc -p tsconfig.build.json",
99
"precommit": "lint-staged",
1010
"ts-check": "yarn tsc --noEmit",
11-
"format:js": "prettier --write --list-different './{src,example,FabricExample,MacOSExample}/**/*.{js,jsx,ts,tsx}'",
11+
"format-js": "prettier --write --list-different './src/**/*.{js,jsx,ts,tsx}'",
1212
"format:android": "node ./scripts/format-android.js",
1313
"format:apple": "find apple/ -iname *.h -o -iname *.m -o -iname *.cpp -o -iname *.mm | xargs clang-format -i",
1414
"lint-js": "eslint --ext '.js,.ts,.tsx' src/ && yarn prettier --check './src/**/*.{js,jsx,ts,tsx}'",

0 commit comments

Comments
 (0)