Skip to content

Commit

Permalink
fix: cycle dependencies (#563)
Browse files Browse the repository at this point in the history
## 📜 Description

Fixed cycle dependencies in the code.

## 💡 Motivation and Context

Cycle dependencies may lead to unpredictable results especially if you
have many of them.

To fix them I used `eslint` rule - it's quite effective and we don't
need to change CI pipelines etc. Plus we can monitor such cycles
contioniously!

Closes
#562

## 📢 Changelog

<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->

### JS

- reorganized imports to avoid cycle deps;
- added new eslint rule usage.

## 🤔 How Has This Been Tested?

Tested on e2e tests on CI 🙂 

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
  • Loading branch information
kirillzyusko authored Aug 23, 2024
1 parent 34493cd commit 1ed4cd3
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 14 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ module.exports = {
"newlines-between": "always",
},
],
"import/no-cycle": ["error", { maxDepth: "∞" }],
// jest
"jest/expect-expect": [
"warn",
Expand Down
6 changes: 2 additions & 4 deletions src/components/KeyboardAvoidingView/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { useSharedValue } from "react-native-reanimated";

import {
useKeyboardContext,
useKeyboardHandler,
} from "react-native-keyboard-controller";
import { useKeyboardContext } from "../../context";
import { useKeyboardHandler } from "../../hooks";

export const useKeyboardAnimation = () => {
const { reanimated } = useKeyboardContext();
Expand Down
2 changes: 1 addition & 1 deletion src/components/KeyboardAvoidingView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Reanimated, {
useSharedValue,
} from "react-native-reanimated";

import { useWindowDimensions } from "react-native-keyboard-controller";
import { useWindowDimensions } from "../../hooks";

import { useKeyboardAnimation } from "./hooks";

Expand Down
2 changes: 1 addition & 1 deletion src/components/KeyboardAwareScrollView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
useFocusedInputHandler,
useReanimatedFocusedInput,
useWindowDimensions,
} from "react-native-keyboard-controller";
} from "../../hooks";

import { useSmoothKeyboardHandler } from "./useSmoothKeyboardHandler";
import { debounce, scrollDistanceWithRespectToSnapPoints } from "./utils";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
withTiming,
} from "react-native-reanimated";

import { useKeyboardHandler } from "react-native-keyboard-controller";
import { useKeyboardHandler } from "../../hooks";

const IS_ANDROID_ELEVEN_OR_HIGHER =
Platform.OS === "android" && Platform.Version >= 30;
Expand Down
2 changes: 1 addition & 1 deletion src/components/KeyboardStickyView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Reanimated, {
useAnimatedStyle,
} from "react-native-reanimated";

import { useReanimatedKeyboardAnimation } from "react-native-keyboard-controller";
import { useReanimatedKeyboardAnimation } from "../../hooks";

import type { View, ViewProps } from "react-native";

Expand Down
8 changes: 2 additions & 6 deletions src/components/KeyboardToolbar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import React, { useCallback, useEffect, useMemo, useState } from "react";
import { StyleSheet, Text, View } from "react-native";

import {
FocusedInputEvents,
KeyboardStickyView,
} from "react-native-keyboard-controller";

import { KeyboardController } from "../../bindings";
import { FocusedInputEvents, KeyboardController } from "../../bindings";
import useColorScheme from "../hooks/useColorScheme";
import KeyboardStickyView from "../KeyboardStickyView";

import Arrow from "./Arrow";
import Button from "./Button";
Expand Down

0 comments on commit 1ed4cd3

Please sign in to comment.