Skip to content

Commit f5591b3

Browse files
authored
[eslint] Package (#4088)
## Description This PR fixes eslint errors in package after enabling new `import` rules ## Test plan - `yarn ts-check` - `yarn lint-js` I've also run Sonnet to make sure that only `imports` were affected: <img width="1018" height="289" alt="image" src="https://github.com/user-attachments/assets/bdc7a858-ae67-4fc2-9152-cf12dc8cac38" />
1 parent 695c224 commit f5591b3

176 files changed

Lines changed: 893 additions & 942 deletions

File tree

Some content is hidden

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

packages/react-native-gesture-handler/src/RNGestureHandlerModule.web.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import React from 'react';
2-
1+
import type { Config, PropsRef } from './web/interfaces';
32
import type { ActionType } from './ActionType';
3+
import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate';
4+
import type { GestureRelations } from './v3/types';
45
import { Gestures } from './web/Gestures';
5-
import type { Config, PropsRef } from './web/interfaces';
66
import InteractionManager from './web/tools/InteractionManager';
77
import NodeManager from './web/tools/NodeManager';
8-
import { GestureHandlerWebDelegate } from './web/tools/GestureHandlerWebDelegate';
9-
import { GestureRelations } from './v3/types';
8+
import React from 'react';
109

1110
// init method is called inside attachGestureHandler function. However, this function may
1211
// fail when received view is not valid HTML element. On the other hand, dropGestureHandler

packages/react-native-gesture-handler/src/RNGestureHandlerModule.windows.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
import React from 'react';
2-
3-
import { ActionType } from './ActionType';
4-
5-
// GestureHandlers
6-
import PanGestureHandler from './web/handlers/PanGestureHandler';
7-
import TapGestureHandler from './web/handlers/TapGestureHandler';
1+
import type { ActionType } from './ActionType';
2+
import type { Config } from './web/interfaces';
3+
import FlingGestureHandler from './web/handlers/FlingGestureHandler';
84
import LongPressGestureHandler from './web/handlers/LongPressGestureHandler';
5+
import ManualGestureHandler from './web/handlers/ManualGestureHandler';
6+
import NativeViewGestureHandler from './web/handlers/NativeViewGestureHandler';
7+
import PanGestureHandler from './web/handlers/PanGestureHandler';
98
import PinchGestureHandler from './web/handlers/PinchGestureHandler';
9+
import type React from 'react';
1010
import RotationGestureHandler from './web/handlers/RotationGestureHandler';
11-
import FlingGestureHandler from './web/handlers/FlingGestureHandler';
12-
import NativeViewGestureHandler from './web/handlers/NativeViewGestureHandler';
13-
import ManualGestureHandler from './web/handlers/ManualGestureHandler';
14-
import { Config } from './web/interfaces';
11+
import TapGestureHandler from './web/handlers/TapGestureHandler';
1512

1613
export const Gestures = {
1714
NativeViewGestureHandler,

packages/react-native-gesture-handler/src/__tests__/Errors.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import React from 'react';
2-
import { render, cleanup } from '@testing-library/react-native';
31
import {
42
Gesture,
53
GestureDetector,
64
GestureHandlerRootView,
75
InterceptingGestureDetector,
86
useTapGesture,
97
} from '../index';
10-
import { findNodeHandle, View } from 'react-native';
8+
import { View, findNodeHandle } from 'react-native';
9+
import { cleanup, render } from '@testing-library/react-native';
10+
import React from 'react';
1111
import { VirtualDetector } from '../v3/detectors/VirtualDetector/VirtualDetector';
1212

1313
jest.mock('react-native-worklets', () =>

packages/react-native-gesture-handler/src/__tests__/Events.test.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
22
// Disabling lint for assymetric matchers, check proposal below
33
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/56937
4-
import React from 'react';
5-
import { render, cleanup } from '@testing-library/react-native';
6-
import { Text } from 'react-native';
74
import {
8-
GestureHandlerRootView,
9-
PanGestureHandler,
105
Gesture,
116
GestureDetector,
7+
GestureHandlerRootView,
128
State,
9+
} from '../index';
10+
import type {
1311
LegacyPanGesture,
1412
LegacyTapGesture,
13+
PanGestureHandler,
1514
} from '../index';
15+
import { cleanup, render } from '@testing-library/react-native';
1616
import { fireGestureHandler, getByGestureTestId } from '../jestUtils';
17+
import React from 'react';
18+
import { Text } from 'react-native';
1719

1820
beforeEach(cleanup);
1921

packages/react-native-gesture-handler/src/__tests__/RelationsTraversal.test.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import { tagMessage } from '../utils';
21
import {
3-
useExclusiveGestures,
42
useCompetingGestures,
3+
useExclusiveGestures,
54
useSimultaneousGestures,
65
} from '../v3/hooks/composition';
7-
import { useGesture } from '../v3/hooks/useGesture';
6+
import type { SingleGesture } from '../v3/types';
7+
import { SingleGestureName } from '../v3/types';
88
import { configureRelations } from '../v3/detectors/utils';
9-
import { SingleGesture, SingleGestureName } from '../v3/types';
109
import { renderHook } from '@testing-library/react-native';
10+
import { tagMessage } from '../utils';
11+
import { useGesture } from '../v3/hooks/useGesture';
1112

1213
type AnySingleGesture = SingleGesture<unknown, unknown, unknown>;
1314

packages/react-native-gesture-handler/src/__tests__/api_v3.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { usePanGesture } from '../v3/hooks/gestures';
2-
import { render, renderHook } from '@testing-library/react-native';
1+
import { RectButton, Touchable } from '../v3/components';
32
import { fireGestureHandler, getByGestureTestId } from '../jestUtils';
4-
import { State } from '../State';
3+
import { render, renderHook } from '@testing-library/react-native';
54
import GestureHandlerRootView from '../components/GestureHandlerRootView';
6-
import { RectButton, Touchable } from '../v3/components';
7-
import { act } from 'react';
85
import type { SingleGesture } from '../v3/types';
6+
import { State } from '../State';
7+
import { act } from 'react';
8+
import { usePanGesture } from '../v3/hooks/gestures';
99

1010
describe('[API v3] Hooks', () => {
1111
test('Pan gesture', () => {

packages/react-native-gesture-handler/src/__tests__/mocks.test.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
1-
import React from 'react';
2-
import { Text } from 'react-native';
3-
import { render, fireEvent } from '@testing-library/react-native';
4-
51
import {
6-
LegacyRawButton,
72
LegacyBaseButton,
8-
LegacyRectButton,
93
LegacyBorderlessButton,
104
LegacyPureNativeButton,
5+
LegacyRawButton,
6+
LegacyRectButton,
117
} from '../mocks/GestureButtons';
12-
138
import {
14-
LegacyScrollView,
159
LegacyFlatList,
10+
LegacyRefreshControl,
11+
LegacyScrollView,
1612
LegacySwitch,
1713
LegacyTextInput,
18-
LegacyRefreshControl,
1914
} from '../mocks/gestureComponents';
20-
2115
import {
2216
TouchableHighlight,
2317
TouchableNativeFeedback,
2418
TouchableOpacity,
2519
TouchableWithoutFeedback,
2620
} from '../mocks/Touchables';
27-
28-
import LegacyPressable from '../mocks/Pressable';
29-
21+
import { fireEvent, render } from '@testing-library/react-native';
3022
import GestureHandlerRootView from '../components/GestureHandlerRootView';
23+
import LegacyPressable from '../mocks/Pressable';
24+
import React from 'react';
25+
import { Text } from 'react-native';
3126
import { Touchable } from '../v3/components';
3227

3328
describe('Jest mocks – legacy components render without crashing', () => {

packages/react-native-gesture-handler/src/components/GestureButtons.tsx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
import * as React from 'react';
22
import { Animated, Platform, StyleSheet } from 'react-native';
3-
4-
import createNativeWrapper from '../handlers/createNativeWrapper';
5-
import GestureHandlerButton from './GestureHandlerButton';
6-
import { State } from '../State';
7-
8-
import {
9-
GestureEvent,
10-
HandlerStateChangeEvent,
11-
} from '../handlers/gestureHandlerCommon';
12-
import type { NativeViewGestureHandlerPayload } from '../handlers/GestureHandlerEventPayload';
133
import type {
144
BaseButtonWithRefProps,
15-
LegacyBaseButtonProps,
16-
RectButtonWithRefProps,
17-
LegacyRectButtonProps,
185
BorderlessButtonWithRefProps,
6+
LegacyBaseButtonProps,
197
LegacyBorderlessButtonProps,
208
LegacyRawButtonProps,
9+
LegacyRectButtonProps,
10+
RectButtonWithRefProps,
2111
} from './GestureButtonsProps';
12+
import type {
13+
GestureEvent,
14+
HandlerStateChangeEvent,
15+
} from '../handlers/gestureHandlerCommon';
16+
import GestureHandlerButton from './GestureHandlerButton';
2217
import type { HostComponent } from 'react-native';
18+
import type { NativeViewGestureHandlerPayload } from '../handlers/GestureHandlerEventPayload';
19+
import { State } from '../State';
20+
import createNativeWrapper from '../handlers/createNativeWrapper';
2321

2422
/**
2523
* @deprecated use `RawButton` instead

packages/react-native-gesture-handler/src/components/GestureButtonsProps.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import * as React from 'react';
2-
import {
1+
import type * as React from 'react';
2+
import type {
33
AccessibilityProps,
44
ColorValue,
55
LayoutChangeEvent,

packages/react-native-gesture-handler/src/components/GestureComponents.tsx

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
11
import * as React from 'react';
2-
import {
3-
PropsWithChildren,
2+
import type {
43
ForwardedRef,
5-
RefAttributes,
4+
PropsWithChildren,
65
ReactElement,
6+
RefAttributes,
77
} from 'react';
88
import {
9+
DrawerLayoutAndroid as RNDrawerLayoutAndroid,
10+
FlatList as RNFlatList,
11+
RefreshControl as RNRefreshControl,
912
ScrollView as RNScrollView,
10-
ScrollViewProps as RNScrollViewProps,
1113
Switch as RNSwitch,
12-
SwitchProps as RNSwitchProps,
1314
TextInput as RNTextInput,
14-
TextInputProps as RNTextInputProps,
15-
DrawerLayoutAndroid as RNDrawerLayoutAndroid,
15+
} from 'react-native';
16+
import type {
1617
DrawerLayoutAndroidProps as RNDrawerLayoutAndroidProps,
17-
FlatList as RNFlatList,
1818
FlatListProps as RNFlatListProps,
19-
RefreshControl as RNRefreshControl,
19+
ScrollViewProps as RNScrollViewProps,
20+
SwitchProps as RNSwitchProps,
21+
TextInputProps as RNTextInputProps,
2022
} from 'react-native';
21-
23+
import type { NativeViewGestureHandlerProps } from '../handlers/NativeViewGestureHandler';
2224
import createNativeWrapper from '../handlers/createNativeWrapper';
23-
24-
import {
25-
NativeViewGestureHandlerProps,
26-
nativeViewProps,
27-
} from '../handlers/NativeViewGestureHandler';
28-
25+
import { nativeViewProps } from '../handlers/NativeViewGestureHandler';
2926
import { toArray } from '../utils';
3027

3128
/**

0 commit comments

Comments
 (0)