Skip to content

Commit a205014

Browse files
committed
add no-restricted-imports rule on InteractionManager and TransitionTracker
1 parent 43b4bf2 commit a205014

127 files changed

Lines changed: 137 additions & 0 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.

eslint.config.mjs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const restrictedImportPaths = [
3535
'ActivityIndicator',
3636
'Animated',
3737
'findNodeHandle',
38+
'InteractionManager',
3839
],
3940
message: [
4041
'',
@@ -45,6 +46,7 @@ const restrictedImportPaths = [
4546
"For 'ScrollView', please use '@components/ScrollView' instead.",
4647
"For 'ActivityIndicator', please use '@components/ActivityIndicator' instead.",
4748
"For 'Animated', please use 'Animated' from 'react-native-reanimated' instead.",
49+
"For 'InteractionManager', please use afterTransition callbacks on Navigation/KeyboardUtils or other alternatives. See contributingGuides/INTERACTION_MANAGER.md.",
4850
].join('\n'),
4951
},
5052
{
@@ -135,6 +137,11 @@ const restrictedImportPaths = [
135137
];
136138

137139
const restrictedImportPatterns = [
140+
{
141+
group: ['**/TransitionTracker', './TransitionTracker', '../TransitionTracker'],
142+
message:
143+
"TransitionTracker is an internal primitive. Please use higher-level APIs (Navigation with 'afterTransition'/'waitForTransition', KeyboardUtils, useConfirmModal). See contributingGuides/INTERACTION_MANAGER.md.",
144+
},
138145
{
139146
group: ['**/assets/animations/**/*.json'],
140147
message: "Do not import animations directly. Please use the '@components/LottieAnimations' import instead.",

src/components/AddUnreportedExpenseFooter.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
// eslint-disable-next-line no-restricted-imports
23
import {InteractionManager} from 'react-native';
34
import type {OnyxCollection, OnyxEntry} from 'react-native-onyx';
45
import useLocalize from '@hooks/useLocalize';

src/components/AutoSubmitModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, {useCallback, useMemo} from 'react';
2+
// eslint-disable-next-line no-restricted-imports
23
import {InteractionManager, View} from 'react-native';
34
import {useMemoizedLazyIllustrations} from '@hooks/useLazyAsset';
45
import useLocalize from '@hooks/useLocalize';

src/components/AvatarCropModal/AvatarCropModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, {useCallback, useEffect, useMemo, useState} from 'react';
2+
// eslint-disable-next-line no-restricted-imports
23
import {InteractionManager, View} from 'react-native';
34
import type {LayoutChangeEvent} from 'react-native';
45
import {Gesture, GestureHandlerRootView} from 'react-native-gesture-handler';

src/components/ContactPermissionModal/index.native.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, {useEffect, useState} from 'react';
2+
// eslint-disable-next-line no-restricted-imports
23
import {InteractionManager} from 'react-native';
34
import {RESULTS} from 'react-native-permissions';
45
import ConfirmModal from '@components/ConfirmModal';

src/components/DatePicker/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {format, setYear} from 'date-fns';
22
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
3+
// eslint-disable-next-line no-restricted-imports
34
import {InteractionManager, View} from 'react-native';
45
import TextInput from '@components/TextInput';
56
import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types';

src/components/FeatureTrainingModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type {ImageContentFit} from 'expo-image';
22
import type {SourceLoadEventPayload} from 'expo-video';
33
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
4+
// eslint-disable-next-line no-restricted-imports
45
import {Image, InteractionManager, View} from 'react-native';
56
// eslint-disable-next-line no-restricted-imports
67
import type {ImageResizeMode, ImageSourcePropType, LayoutChangeEvent, ScrollView as RNScrollView, StyleProp, TextStyle, ViewStyle} from 'react-native';

src/components/Form/FormProvider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {deepEqual} from 'fast-equals';
22
import type {ForwardedRef, ReactNode, RefObject} from 'react';
33
import React, {createRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState} from 'react';
4+
// eslint-disable-next-line no-restricted-imports
45
import {InteractionManager} from 'react-native';
56
import type {StyleProp, TextInputSubmitEditingEvent, ViewStyle} from 'react-native';
67
import type {ValueOf} from 'type-fest';

src/components/Form/FormWrapper.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, {useContext, useImperativeHandle, useRef} from 'react';
22
import type {ForwardedRef, RefObject} from 'react';
33
// eslint-disable-next-line no-restricted-imports
44
import type {ScrollView as RNScrollView, StyleProp, ViewStyle} from 'react-native';
5+
// eslint-disable-next-line no-restricted-imports
56
import {InteractionManager, Keyboard, View} from 'react-native';
67
import FormAlertWithSubmitButton from '@components/FormAlertWithSubmitButton';
78
import FormElement from '@components/FormElement';

src/components/Lottie/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {NavigationContainerRefContext, NavigationContext} from '@react-navigatio
22
import type {AnimationObject, LottieViewProps} from 'lottie-react-native';
33
import LottieView from 'lottie-react-native';
44
import React, {useContext, useEffect, useRef, useState} from 'react';
5+
// eslint-disable-next-line no-restricted-imports
56
import {InteractionManager, View} from 'react-native';
67
import type DotLottieAnimation from '@components/LottieAnimations/types';
78
import useAppState from '@hooks/useAppState';

0 commit comments

Comments
 (0)