Skip to content

Commit 07d42e9

Browse files
chore(sonar): no need to import react
1 parent 72a5166 commit 07d42e9

Some content is hidden

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

57 files changed

+84
-113
lines changed

.eslintrc.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ module.exports = {
4646
project: './tsconfig.json',
4747
},
4848
rules: {
49+
'react/react-in-jsx-scope': 'off',
50+
'react/jsx-uses-react': 'off',
4951
'prettier/prettier': [
5052
'error',
5153
{
@@ -79,6 +81,18 @@ module.exports = {
7981
caughtErrorsIgnorePattern: '^_',
8082
},
8183
],
84+
'no-restricted-imports': [
85+
'error',
86+
{
87+
paths: [
88+
{
89+
name: 'react',
90+
importNames: ['default'],
91+
message: 'No need to import React',
92+
},
93+
],
94+
},
95+
],
8296
curly: [2, 'all'],
8397
},
8498
},

docs/src/content/docs/ui-and-theme/Forms.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ Here is how you can create your login screen:
5353

5454
```tsx
5555
import { zodResolver } from '@hookform/resolvers/zod';
56-
import React from 'react';
5756
import { useForm } from 'react-hook-form';
5857
import z from 'zod';
5958

src/api/common/api-provider.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { useReactQueryDevTools } from '@dev-plugins/react-query';
22
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
3-
import React from 'react';
4-
53
export const queryClient = new QueryClient();
64

75
export function APIProvider({ children }: { children: React.ReactNode }) {

src/app/(app)/_layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable react/no-unstable-nested-components */
22
import { Link, Redirect, SplashScreen, Tabs } from 'expo-router';
3-
import React, { useCallback, useEffect } from 'react';
3+
import { useCallback, useEffect } from 'react';
44

55
import { useAuth, useIsFirstTime } from '@/core';
66
import { Pressable, Text } from '@/ui';

src/app/(app)/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FlashList } from '@shopify/flash-list';
2-
import React from 'react';
2+
import { useCallback } from 'react';
33

44
import type { Post } from '@/api';
55
import { usePosts } from '@/api';
@@ -8,7 +8,7 @@ import { EmptyList, FocusAwareStatusBar, Text, View } from '@/ui';
88

99
export default function Feed() {
1010
const { data, isPending, isError } = usePosts();
11-
const renderItem = React.useCallback(
11+
const renderItem = useCallback(
1212
({ item }: { item: Post }) => <Card {...item} />,
1313
[]
1414
);

src/app/(app)/settings.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable react/react-in-jsx-scope */
21
import { Env } from '@env';
32
import { useColorScheme } from 'nativewind';
43

src/app/(app)/style.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react';
2-
31
import { Buttons } from '@/components/buttons';
42
import { Colors } from '@/components/colors';
53
import { Inputs } from '@/components/inputs';

src/app/_layout.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ export { ErrorBoundary } from 'expo-router';
1717
// Import global CSS file
1818
import '../../global.css';
1919

20-
import React from 'react';
21-
2220
export const unstable_settings = {
2321
initialRouteName: '(app)',
2422
};

src/app/feed/[id].tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Stack, useLocalSearchParams } from 'expo-router';
2-
import React from 'react';
32

43
import { usePost } from '@/api';
54
import { ActivityIndicator, FocusAwareStatusBar, Text, View } from '@/ui';

src/app/feed/add-post.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { zodResolver } from '@hookform/resolvers/zod';
22
import { Stack } from 'expo-router';
3-
import React from 'react';
43
import { useForm } from 'react-hook-form';
54
import { showMessage } from 'react-native-flash-message';
65
import { z } from 'zod';

src/app/login.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useRouter } from 'expo-router';
2-
import React from 'react';
32

43
import type { LoginFormProps } from '@/components/login-form';
54
import { LoginForm } from '@/components/login-form';

src/app/onboarding.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { useRouter } from 'expo-router';
2-
import React from 'react';
32

43
import { Cover } from '@/components/cover';
54
import { useIsFirstTime } from '@/core/hooks';

src/components/buttons.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react';
2-
31
import { Button, View } from '@/ui';
42

53
import { Title } from './title';

src/components/card.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Link } from 'expo-router';
2-
import React from 'react';
32

43
import type { Post } from '@/api';
54
import { Image, Pressable, Text, View } from '@/ui';

src/components/colors.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { render, screen, within } from '@testing-library/react-native';
2-
import React from 'react';
32

43
import { colors } from '@/ui';
54

src/components/colors.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react';
2-
31
import { Text, View } from '@/ui';
42
import colors from '@/ui/colors';
53

src/components/cover.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable max-lines-per-function */
2-
import React from 'react';
32
import type { SvgProps } from 'react-native-svg';
43
import Svg, { Circle, Path, Polygon } from 'react-native-svg';
54
// TODO: should be updated to simple images

src/components/inputs.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import { useState } from 'react';
22

33
import type { Option } from '@/ui';
44
import { Input, Select, View } from '@/ui';
@@ -13,7 +13,7 @@ const options: Option[] = [
1313
];
1414

1515
export const Inputs = () => {
16-
const [value, setValue] = React.useState<string | number | undefined>();
16+
const [value, setValue] = useState<string | number | undefined>();
1717
return (
1818
<>
1919
<Title text="Form" />
@@ -36,7 +36,7 @@ export const Inputs = () => {
3636
};
3737

3838
const CheckboxExample = () => {
39-
const [checked, setChecked] = React.useState(false);
39+
const [checked, setChecked] = useState(false);
4040
return (
4141
<Checkbox.Root
4242
checked={checked}
@@ -51,7 +51,7 @@ const CheckboxExample = () => {
5151
};
5252

5353
const RadioExample = () => {
54-
const [selected, setSelected] = React.useState(false);
54+
const [selected, setSelected] = useState(false);
5555
return (
5656
<Radio.Root
5757
checked={selected}
@@ -66,7 +66,7 @@ const RadioExample = () => {
6666
};
6767

6868
const SwitchExample = () => {
69-
const [active, setActive] = React.useState(false);
69+
const [active, setActive] = useState(false);
7070
return (
7171
<Switch.Root
7272
checked={active}

src/components/login-form.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react';
2-
31
import { cleanup, fireEvent, render, screen, waitFor } from '@/core/test-utils';
42

53
import type { LoginFormProps } from './login-form';

src/components/login-form.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { zodResolver } from '@hookform/resolvers/zod';
2-
import React from 'react';
32
import type { SubmitHandler } from 'react-hook-form';
43
import { useForm } from 'react-hook-form';
54
import { KeyboardAvoidingView } from 'react-native-keyboard-controller';

src/components/settings/item.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react';
2-
31
import type { TxKeyPath } from '@/core';
42
import { Pressable, Text, View } from '@/ui';
53
import { ArrowRight } from '@/ui/icons';

src/components/settings/items-container.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react';
2-
31
import type { TxKeyPath } from '@/core';
42
import { Text, View } from '@/ui';
53

src/components/settings/language-item.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import { useCallback, useMemo } from 'react';
22

33
import { useSelectedLanguage } from '@/core';
44
import { translate } from '@/core';
@@ -11,23 +11,23 @@ import { Item } from './item';
1111
export const LanguageItem = () => {
1212
const { language, setLanguage } = useSelectedLanguage();
1313
const modal = useModal();
14-
const onSelect = React.useCallback(
14+
const onSelect = useCallback(
1515
(option: Option) => {
1616
setLanguage(option.value as Language);
1717
modal.dismiss();
1818
},
1919
[setLanguage, modal]
2020
);
2121

22-
const langs = React.useMemo(
22+
const langs = useMemo(
2323
() => [
2424
{ label: translate('settings.english'), value: 'en' },
2525
{ label: translate('settings.arabic'), value: 'ar' },
2626
],
2727
[]
2828
);
2929

30-
const selectedLanguage = React.useMemo(
30+
const selectedLanguage = useMemo(
3131
() => langs.find((lang) => lang.value === language),
3232
[language, langs]
3333
);

src/components/settings/theme-item.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import { useCallback, useMemo } from 'react';
22

33
import type { ColorSchemeType } from '@/core';
44
import { translate, useSelectedTheme } from '@/core';
@@ -11,15 +11,15 @@ export const ThemeItem = () => {
1111
const { selectedTheme, setSelectedTheme } = useSelectedTheme();
1212
const modal = useModal();
1313

14-
const onSelect = React.useCallback(
14+
const onSelect = useCallback(
1515
(option: Option) => {
1616
setSelectedTheme(option.value as ColorSchemeType);
1717
modal.dismiss();
1818
},
1919
[setSelectedTheme, modal]
2020
);
2121

22-
const themes = React.useMemo(
22+
const themes = useMemo(
2323
() => [
2424
{ label: `${translate('settings.theme.dark')} 🌙`, value: 'dark' },
2525
{ label: `${translate('settings.theme.light')} 🌞`, value: 'light' },
@@ -28,7 +28,7 @@ export const ThemeItem = () => {
2828
[]
2929
);
3030

31-
const theme = React.useMemo(
31+
const theme = useMemo(
3232
() => themes.find((t) => t.value === selectedTheme),
3333
[selectedTheme, themes]
3434
);

src/components/title.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react';
2-
31
import { Text, View } from '@/ui';
42

53
type Props = {

src/components/typography.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import React from 'react';
2-
31
import { Text, View } from '@/ui';
42

53
import { Title } from './title';

src/core/hooks/use-selected-theme.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { colorScheme, useColorScheme } from 'nativewind';
2-
import React from 'react';
2+
import { useCallback } from 'react';
33
import { useMMKVString } from 'react-native-mmkv';
44

55
import { storage } from '../storage';
@@ -17,7 +17,7 @@ export const useSelectedTheme = () => {
1717
const { colorScheme: _color, setColorScheme } = useColorScheme();
1818
const [theme, _setTheme] = useMMKVString(SELECTED_THEME, storage);
1919

20-
const setSelectedTheme = React.useCallback(
20+
const setSelectedTheme = useCallback(
2121
(t: ColorSchemeType) => {
2222
setColorScheme(t);
2323
_setTheme(t);

src/core/test-utils.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import { NavigationContainer } from '@react-navigation/native';
55
import type { RenderOptions } from '@testing-library/react-native';
66
import { render } from '@testing-library/react-native';
77
import type { ReactElement } from 'react';
8-
import React from 'react';
9-
108
const createAppWrapper = () => {
119
return ({ children }: { children: React.ReactNode }) => (
1210
<BottomSheetModalProvider>

src/ui/button.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable max-lines-per-function */
2-
import React from 'react';
32
import { Text } from 'react-native';
43

54
import { cleanup, fireEvent, render, screen } from '@/core/test-utils';

src/ui/button.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import { forwardRef, useMemo } from 'react';
22
import type { PressableProps, View } from 'react-native';
33
import { ActivityIndicator, Pressable, Text } from 'react-native';
44
import type { VariantProps } from 'tailwind-variants';
@@ -92,7 +92,7 @@ interface Props extends ButtonVariants, Omit<PressableProps, 'disabled'> {
9292
textClassName?: string;
9393
}
9494

95-
export const Button = React.forwardRef<View, Props>(
95+
export const Button = forwardRef<View, Props>(
9696
(
9797
{
9898
label: text,
@@ -107,7 +107,7 @@ export const Button = React.forwardRef<View, Props>(
107107
},
108108
ref
109109
) => {
110-
const styles = React.useMemo(
110+
const styles = useMemo(
111111
() => button({ variant, disabled, size }),
112112
[variant, disabled, size]
113113
);

src/ui/checkbox.test.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
/* eslint-disable max-lines-per-function */
22
import 'react-native';
33

4-
import React from 'react';
5-
64
import { cleanup, fireEvent, render, screen } from '@/core/test-utils';
75

86
import { Checkbox, Radio, Switch } from './checkbox';

src/ui/checkbox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { MotiView } from 'moti';
2-
import React, { useCallback } from 'react';
2+
import { useCallback } from 'react';
33
import {
44
I18nManager,
55
Pressable,

src/ui/focus-aware-status-bar.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { useIsFocused } from '@react-navigation/native';
22
import { useColorScheme } from 'nativewind';
3-
import React from 'react';
43
import { StatusBar } from 'react-native';
54

65
type Props = React.ComponentProps<typeof StatusBar>;

src/ui/icons/arrow-right.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import { StyleSheet } from 'react-native';
32
import type { SvgProps } from 'react-native-svg';
43
import Svg, { Path } from 'react-native-svg';

src/ui/icons/caret-down.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import type { SvgProps } from 'react-native-svg';
32
import Svg, { Path } from 'react-native-svg';
43

src/ui/icons/feed.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import type { SvgProps } from 'react-native-svg';
32
import Svg, { Path } from 'react-native-svg';
43

src/ui/icons/github.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import type { SvgProps } from 'react-native-svg';
32
import Svg, { ClipPath, Defs, G, Path } from 'react-native-svg';
43

src/ui/icons/home.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import type { SvgProps } from 'react-native-svg';
32
import Svg, { Path } from 'react-native-svg';
43

src/ui/icons/language.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import type { SvgProps } from 'react-native-svg';
32
import Svg, { G, Path, Text, TSpan } from 'react-native-svg';
43

src/ui/icons/rate.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import React from 'react';
21
import type { SvgProps } from 'react-native-svg';
32
import Svg, { ClipPath, Defs, G, Path } from 'react-native-svg';
43

0 commit comments

Comments
 (0)