Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: [IOAPPX-405] Removing unused react imports #6562

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
62e4af2
chore(deps): add missing babel packages
LeleDallas Dec 17, 2024
b479526
chore(lint): turn off react import
LeleDallas Dec 17, 2024
9af2341
chore(babel): set up loose config to launch script
LeleDallas Dec 17, 2024
b5fe12a
chore: removed unused react imports
LeleDallas Dec 17, 2024
4c1fb77
Merge branch 'master' into IOAPPX-405-remove-react-import-
LeleDallas Dec 17, 2024
a23ba39
chore: add eslint-plugin-ft-flow
LeleDallas Dec 18, 2024
c6f8c89
Merge branch 'master' into IOAPPX-405-remove-react-import-
LeleDallas Dec 18, 2024
c268d8f
chore: fix merge duplicated declaration
LeleDallas Dec 18, 2024
d6e11f2
Merge branch 'master' into IOAPPX-405-remove-react-import-
LeleDallas Dec 18, 2024
bcc444f
Merge branch 'master' into IOAPPX-405-remove-react-import-
LeleDallas Dec 18, 2024
2e4252a
Merge branch 'master' into IOAPPX-405-remove-react-import-
LeleDallas Dec 18, 2024
9b83764
Merge branch 'master' into IOAPPX-405-remove-react-import-
LeleDallas Dec 18, 2024
4e44cdf
Merge branch 'master' into IOAPPX-405-remove-react-import-
LeleDallas Dec 18, 2024
d4d1236
Merge branch 'master' into IOAPPX-405-remove-react-import-
Vangaorth Dec 18, 2024
1e78ae8
chore: removed missing react import
LeleDallas Dec 19, 2024
37100f1
Merge branch 'master' into IOAPPX-405-remove-react-import-
LeleDallas Dec 19, 2024
408fae1
Merge branch 'master' into IOAPPX-405-remove-react-import-
Vangaorth Dec 19, 2024
99e5e60
Merge branch 'master' into IOAPPX-405-remove-react-import-
LeleDallas Dec 19, 2024
048e915
chore: removed unused import
LeleDallas Dec 19, 2024
b7be7d4
Merge branch 'master' into IOAPPX-405-remove-react-import-
LeleDallas Dec 20, 2024
3f48f06
Merge remote-tracking branch 'origin/master' into IOAPPX-405-remove-r…
LeleDallas Dec 23, 2024
6a5b342
Merge branch 'master' into IOAPPX-405-remove-react-import-
LeleDallas Dec 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 12 additions & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ module.exports = {
"@stylistic/eslint-plugin-js"
],
rules: {
//Rules from react 17 https://legacy.reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html#eslint
"react/react-in-jsx-scope": "off",
"react/jsx-uses-react": "off",
"comma-dangle": ["error", "never"],
"no-case-declarations": "off",
"no-inner-declarations": "off",
Expand Down Expand Up @@ -124,24 +127,27 @@ module.exports = {
"no-restricted-imports": [
"error",
{
"paths": [
paths: [
{
name: "i18n-js",
message: 'Importing I18n from "i18n-js" is not allowed. Import it from "ts/i18n.ts" instead.',
},
message:
'Importing I18n from "i18n-js" is not allowed. Import it from "ts/i18n.ts" instead.'
},
{
name: "@pagopa/ts-commons",
importNames: ["pot"],
message: 'Importing { pot } from "@pagopa/ts-commons" is not allowed. Use \'import * as pot from "@pagopa/ts-commons/lib/pot"\' instead.',
message:
'Importing { pot } from "@pagopa/ts-commons" is not allowed. Use \'import * as pot from "@pagopa/ts-commons/lib/pot"\' instead.'
}
],
patterns: [
{
group: ["**/config"],
importNames: ["privacyUrl"],
message: 'Importing "privacyUrl" from "config.ts" module is restricted. Please use "tosConfigSelector" to obtain it instead.'
message:
'Importing "privacyUrl" from "config.ts" module is restricted. Please use "tosConfigSelector" to obtain it instead.'
}
]
]
}
]
},
Expand Down
20 changes: 16 additions & 4 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@ module.exports = {
[
"react-native-reanimated/plugin",
{
globals: ["__scanCodes"]
}
]
]
globals: ["__scanCodes"],
},
],
[
"@babel/plugin-transform-class-properties",
{ loose: true },
],
[
"@babel/plugin-transform-private-methods",
{ loose: true },
],
[
"@babel/plugin-transform-private-property-in-object",
{ loose: true },
],
],
};
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
]
},
"dependencies": {
"@babel/plugin-transform-class-properties": "^7.25.9",
"@babel/plugin-transform-private-methods": "^7.25.9",
"@babel/plugin-transform-private-property-in-object": "^7.25.9",
"@babel/plugin-transform-react-jsx": "^7.25.9",
"@gorhom/bottom-sheet": "^4.1.5",
"@pagopa/io-app-design-system": "4.3.0",
"@pagopa/io-pagopa-commons": "^3.1.0",
Expand Down Expand Up @@ -178,7 +182,7 @@
"xstate": "^5"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/core": "^7.26.0",
"@babel/plugin-transform-regenerator": "^7.18.6",
"@babel/preset-env": "^7.20.0",
"@babel/preset-typescript": "^7.23.3",
Expand Down Expand Up @@ -226,6 +230,7 @@
"chalk": "^2.4.1",
"eslint": "^8.19.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-ft-flow": "latest",
"eslint-plugin-functional": "^4.1.1",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jest": "^28.8.3",
Expand Down
1 change: 0 additions & 1 deletion ts/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
IOThemeContextProvider,
ToastProvider
} from "@pagopa/io-app-design-system";
import * as React from "react";
import { GestureHandlerRootView } from "react-native-gesture-handler";
import { SafeAreaProvider } from "react-native-safe-area-context";
import { Provider } from "react-redux";
Expand Down
4 changes: 2 additions & 2 deletions ts/RootContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as O from "fp-ts/lib/Option";
import { pipe } from "fp-ts/lib/function";
import * as React from "react";
import { PureComponent } from "react";
import {
AppState,
AppStateStatus,
Expand Down Expand Up @@ -43,7 +43,7 @@ type Props = ReturnType<typeof mapStateToProps> &
* - the UpdateAppModal, if the backend is not compatible with the installed app version
* - the root for displaying light modals
*/
class RootContainer extends React.PureComponent<Props> {
class RootContainer extends PureComponent<Props> {
private subscription: NativeEventSubscription | undefined;
constructor(props: Props) {
super(props);
Expand Down
6 changes: 3 additions & 3 deletions ts/__mocks__/@gorhom/bottom-sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* reference: https://github.com/gorhom/react-native-bottom-sheet/blob/master/mock.js
*/
import React, { PropsWithChildren } from "react";
import { Component, PropsWithChildren } from "react";

const NOOP = () => {};
const NOOP_VALUE = { value: 0, set: NOOP, get: () => 0 };
Expand All @@ -18,7 +18,7 @@ const BottomSheetBackdrop = NOOP;

const BottomSheetComponent = (props: PropsWithChildren) => props.children;

class BottomSheetModal extends React.Component<PropsWithChildren> {
class BottomSheetModal extends Component<PropsWithChildren> {
snapToIndex() {}
snapToPosition() {}
expand() {}
Expand All @@ -33,7 +33,7 @@ class BottomSheetModal extends React.Component<PropsWithChildren> {
}
}

class BottomSheet extends React.Component<PropsWithChildren> {
class BottomSheet extends Component<PropsWithChildren> {
snapToIndex() {}
snapToPosition() {}
expand() {}
Expand Down
4 changes: 2 additions & 2 deletions ts/__mocks__/react-native-text-input-mask.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Mocked version of TextInputMask
*/
import React from "react";
import { Component } from "react";

class TextInputMask extends React.Component {
class TextInputMask extends Component {
public render() {
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions ts/components/AnimatedImage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import { ComponentProps } from "react";
import { Image } from "react-native";
import Animated, {
Easing,
Expand All @@ -7,7 +7,7 @@ import Animated, {
withTiming
} from "react-native-reanimated";

export type AnimatedImageProps = React.ComponentProps<typeof Image>;
export type AnimatedImageProps = ComponentProps<typeof Image>;

/**
* AnimatedImage component renders an image with a fade-in animation
Expand Down
1 change: 0 additions & 1 deletion ts/components/AppVersion.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import {
GestureResponderEvent,
Pressable,
Expand Down
23 changes: 12 additions & 11 deletions ts/components/BonusCard/BonusCard.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import {
Avatar,
BodySmall,
H2,
HSpacer,
IOColors,
BodySmall,
VSpacer
} from "@pagopa/io-app-design-system";
import React from "react";

import { Fragment, ReactNode, useMemo } from "react";
import { ImageURISource, StyleSheet, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import Placeholder from "rn-placeholder";
import {
heightPercentageToDP,
widthPercentageToDP
} from "react-native-responsive-screen";
import { isDesignSystemEnabledSelector } from "../../store/reducers/persistedPreferences";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import Placeholder from "rn-placeholder";
import { useIOSelector } from "../../store/hooks";
import { isDesignSystemEnabledSelector } from "../../store/reducers/persistedPreferences";
import { BonusCardCounter } from "./BonusCardCounter";
import { BonusCardShape } from "./BonusCardShape";
import { BonusCardStatus } from "./BonusCardStatus";
Expand All @@ -29,10 +30,10 @@ type ContentProps = {
logoUris?: Array<ImageURISource | number>;
name: string;
organizationName: string;
status: React.ReactNode;
status: ReactNode;
counters?: ReadonlyArray<BonusCardCounter>;
cardFooter?: React.ReactNode;
cardBackground?: React.ReactNode;
cardFooter?: ReactNode;
cardBackground?: ReactNode;
};

type LoadingStateProps =
Expand Down Expand Up @@ -86,10 +87,10 @@ const BonusCardContent = (props: BonusCard) => {
{counters.map((counter, index) => {
const isLast = index === counters.length - 1;
return (
<React.Fragment key={`${counter.label}_${index}`}>
<Fragment key={`${counter.label}_${index}`}>
<BonusCardCounter {...counter} />
{!isLast && <HSpacer size={16} />}
</React.Fragment>
</Fragment>
);
})}
</View>
Expand All @@ -110,7 +111,7 @@ export const BonusCard = (props: BonusCard) => {
// This will generate a new key based on isLoading state.
// A new key will force BonusCardShape to rerender, remeasuring the layout and adapting to new
// container size.
const shapeKey = React.useMemo(
const shapeKey = useMemo(
() => props.isLoading && Math.random().toString(36).slice(2),
[props.isLoading]
);
Expand Down
4 changes: 2 additions & 2 deletions ts/components/BonusCard/BonusCardCounter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { H3, IOColors, LabelMini, VSpacer } from "@pagopa/io-app-design-system";
import * as React from "react";
import { useEffect } from "react";
import { StyleSheet, View } from "react-native";
import Animated, {
useAnimatedStyle,
Expand Down Expand Up @@ -78,7 +78,7 @@ const BonusProgressBar = ({ progress }: BonusProgressBarProps) => {
: IOColors.blue;

const width = useSharedValue(100);
React.useEffect(() => {
useEffect(() => {
// eslint-disable-next-line functional/immutable-data
width.value = progress * 100;
});
Expand Down
4 changes: 2 additions & 2 deletions ts/components/BonusCard/BonusCardScreenComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { HeaderActionProps } from "@pagopa/io-app-design-system";
import { default as React, ReactNode } from "react";
import { ReactNode } from "react";
import { Dimensions } from "react-native";
import Animated, { useAnimatedRef } from "react-native-reanimated";
import { useHeaderSecondLevel } from "../../hooks/useHeaderSecondLevel";
import { SupportRequestParams } from "../../hooks/useStartSupportRequest";
import { IOScrollView, IOScrollViewActions } from "../ui/IOScrollView";
import { useHeaderSecondLevel } from "../../hooks/useHeaderSecondLevel";
import { BonusCard } from "./BonusCard";

type BaseProps = {
Expand Down
1 change: 0 additions & 1 deletion ts/components/BonusCard/BonusCardShape.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { IOColors, useIOTheme } from "@pagopa/io-app-design-system";
import React from "react";
import { StyleSheet, View } from "react-native";
import { Circle, ClipPath, Defs, Path, Rect, Svg } from "react-native-svg";
import { isDesignSystemEnabledSelector } from "../../store/reducers/persistedPreferences";
Expand Down
7 changes: 4 additions & 3 deletions ts/components/BonusCard/BonusCardStatus.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { IOColors } from "@pagopa/io-app-design-system";
import React from "react";

import { ReactNode } from "react";
import { StyleSheet, View } from "react-native";
import Placeholder from "rn-placeholder";
import { isDesignSystemEnabledSelector } from "../../store/reducers/persistedPreferences";
import { useIOSelector } from "../../store/hooks";
import { isDesignSystemEnabledSelector } from "../../store/reducers/persistedPreferences";

type LoadingProps = {
isLoading: true;
};

type BaseProps = {
isLoading?: never;
children: React.ReactNode;
children: ReactNode;
};

export type BonusCardStatus = LoadingProps | BaseProps;
Expand Down
1 change: 0 additions & 1 deletion ts/components/BonusCard/__tests__/BonusCard.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { LabelMini } from "@pagopa/io-app-design-system";
import { render } from "@testing-library/react-native";
import React from "react";
import { Provider } from "react-redux";
import configureMockStore from "redux-mock-store";
import I18n from "../../../i18n";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { render } from "@testing-library/react-native";
import React from "react";
import { Provider } from "react-redux";
import { Store, createStore } from "redux";
import { applicationChangeState } from "../../../store/actions/application";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { render } from "@testing-library/react-native";
import React from "react";
import { Provider } from "react-redux";
import { Store, createStore } from "redux";
import I18n from "../../../i18n";
Expand Down
2 changes: 1 addition & 1 deletion ts/components/BulletList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
IOStyles,
VSpacer
} from "@pagopa/io-app-design-system";
import React, { ComponentProps, memo, useCallback } from "react";
import { ComponentProps, memo, useCallback } from "react";
import { View } from "react-native";

const BULLET_ITEM = "\u2022";
Expand Down
1 change: 0 additions & 1 deletion ts/components/CalendarList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { Calendar } from "react-native-calendar-events";
import {
ContentWrapper,
Expand Down
6 changes: 3 additions & 3 deletions ts/components/CalendarsListContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as pot from "@pagopa/ts-commons/lib/pot";
import React, { memo, useCallback, useEffect, useState } from "react";
import { Fragment, memo, useCallback, useEffect, useState } from "react";
import RNCalendarEvents, { Calendar } from "react-native-calendar-events";
import {
ListItemHeader,
Expand Down Expand Up @@ -133,7 +133,7 @@ const CalendarsListContainer = ({
return (
pot.isSome(calendarsByAccount) &&
calendarsByAccount.value.map((section, index) => (
<React.Fragment key={index}>
<Fragment key={index}>
<ListItemHeader label={section.title} />
<RadioGroup<string>
type="radioListItem"
Expand All @@ -144,7 +144,7 @@ const CalendarsListContainer = ({
/>
{/* not show the end spacer if the element is the last */}
{index < calendarsByAccount.value.length - 1 && <VSpacer size={24} />}
</React.Fragment>
</Fragment>
))
);
};
Expand Down
2 changes: 1 addition & 1 deletion ts/components/Carousel.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IOAppMargin, WithTestID } from "@pagopa/io-app-design-system";
import React, {
import {
JSXElementConstructor,
ReactElement,
Ref,
Expand Down
6 changes: 3 additions & 3 deletions ts/components/DebugInfoOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
hexToRgba,
useIOTheme
} from "@pagopa/io-app-design-system";
import * as React from "react";
import { useState } from "react";

import { FunctionComponent, useState } from "react";
import { Platform, Pressable, SafeAreaView, StyleSheet } from "react-native";
import { widthPercentageToDP } from "react-native-responsive-screen";
import { connect } from "react-redux";
Expand Down Expand Up @@ -56,7 +56,7 @@ const styles = StyleSheet.create({
}
});

const DebugInfoOverlay: React.FunctionComponent<Props> = (props: Props) => {
const DebugInfoOverlay: FunctionComponent<Props> = (props: Props) => {
const theme = useIOTheme();
const appVersion = getAppVersion();
const [showRootName, setShowRootName] = useState(true);
Expand Down
Loading
Loading