]> source.dussan.org Git - sonarqube.git/commitdiff
Remove extra React.PropsWithChildren wrappers introduced by the React 18 codemod
authorDavid Cho-Lerat <david.cho-lerat@sonarsource.com>
Fri, 1 Dec 2023 16:36:45 +0000 (17:36 +0100)
committersonartech <sonartech@sonarsource.com>
Fri, 1 Dec 2023 20:02:43 +0000 (20:02 +0000)
25 files changed:
server/sonar-web/src/main/js/app/components/admin/withAdminPagesOutletContext.tsx
server/sonar-web/src/main/js/app/components/app-state/withAppStateContext.tsx
server/sonar-web/src/main/js/app/components/available-features/withAvailableFeatures.tsx
server/sonar-web/src/main/js/app/components/componentContext/withComponentContext.tsx
server/sonar-web/src/main/js/app/components/languages/withLanguagesContext.tsx
server/sonar-web/src/main/js/app/components/metrics/withMetricsContext.tsx
server/sonar-web/src/main/js/apps/quality-profiles/qualityProfilesContext.tsx
server/sonar-web/src/main/js/apps/settings/components/inputs/Input.tsx
server/sonar-web/src/main/js/apps/settings/components/inputs/InputForSecured.tsx
server/sonar-web/src/main/js/apps/settings/components/inputs/PrimitiveInput.tsx
server/sonar-web/src/main/js/components/hoc/utils.ts
server/sonar-web/src/main/js/components/hoc/whenLoggedIn.tsx
server/sonar-web/src/main/js/components/hoc/withCLanguageFeature.tsx
server/sonar-web/src/main/js/components/hoc/withIndexationContext.tsx
server/sonar-web/src/main/js/components/hoc/withIndexationGuard.tsx
server/sonar-web/src/main/js/components/hoc/withKeyboardNavigation.tsx
server/sonar-web/src/main/js/components/hoc/withLocation.tsx
server/sonar-web/src/main/js/components/hoc/withNotifications.tsx
server/sonar-web/src/main/js/components/hoc/withRouter.tsx
server/sonar-web/src/main/js/components/icons/ProjectLinkIcon.tsx
server/sonar-web/src/main/js/components/rules/MoreInfoRuleDescription.tsx
server/sonar-web/src/main/js/components/tutorials/jenkins/JenkinsStep.tsx
server/sonar-web/src/main/js/components/workspace/WorkspaceHeader.tsx
server/sonar-web/src/main/js/helpers/testUtils.ts
server/sonar-web/src/main/js/queries/branch.tsx

index b5d3da6ff84743cd5aea9345b66e55524f47998b..3de71cd7aa0e252af55e291f15e60e29d87aba54 100644 (file)
@@ -22,9 +22,7 @@ import { useOutletContext } from 'react-router-dom';
 import { AdminPagesContext } from '../../../types/admin';
 
 export default function withAdminPagesOutletContext(
-  WrappedComponent: React.ComponentType<
-    React.PropsWithChildren<React.PropsWithChildren<AdminPagesContext>>
-  >,
+  WrappedComponent: React.ComponentType<React.PropsWithChildren<AdminPagesContext>>,
 ) {
   return function WithAdminPagesOutletContext() {
     const { adminPages } = useOutletContext<AdminPagesContext>();
index 5a0b13d06af679858c0a46af581407a7ccd897bb..51cd7d808a4807a1cbd157b518625bba10a3c21b 100644 (file)
@@ -27,9 +27,7 @@ export interface WithAppStateContextProps {
 }
 
 export default function withAppStateContext<P>(
-  WrappedComponent: React.ComponentType<
-    React.PropsWithChildren<React.PropsWithChildren<P & WithAppStateContextProps>>
-  >,
+  WrappedComponent: React.ComponentType<React.PropsWithChildren<P & WithAppStateContextProps>>,
 ) {
   return class WithAppStateContext extends React.PureComponent<
     Omit<P, keyof WithAppStateContextProps>
index 5a25ac62230f8f73992890329afc501c9ab8bb50..278938b48ad7e6c48c54a693a2c266ee15da6dfc 100644 (file)
@@ -27,9 +27,7 @@ export interface WithAvailableFeaturesProps {
 }
 
 export default function withAvailableFeatures<P>(
-  WrappedComponent: React.ComponentType<
-    React.PropsWithChildren<React.PropsWithChildren<P & WithAvailableFeaturesProps>>
-  >,
+  WrappedComponent: React.ComponentType<React.PropsWithChildren<P & WithAvailableFeaturesProps>>,
 ) {
   return class WithAvailableFeatures extends React.PureComponent<
     Omit<P, keyof WithAvailableFeaturesProps>
index 122706e9f6304ca779c682b58bfc558cb06c82e9..eeab47a144d37b3d9ad0f9d065a1ee417690d142 100644 (file)
@@ -23,7 +23,7 @@ import { ComponentContextShape } from '../../../types/component';
 import { ComponentContext } from './ComponentContext';
 
 export default function withComponentContext<P extends Partial<ComponentContextShape>>(
-  WrappedComponent: React.ComponentType<React.PropsWithChildren<React.PropsWithChildren<P>>>,
+  WrappedComponent: React.ComponentType<React.PropsWithChildren<P>>,
 ) {
   return class WithComponentContext extends React.PureComponent<
     Omit<P, keyof ComponentContextShape>
index 6b2324f4d249c6231846e311ee028f066da9b0ff..fd562c9e388eabc94c57d28e454a4eeb35279ae1 100644 (file)
@@ -27,9 +27,7 @@ export interface WithLanguagesContextProps {
 }
 
 export default function withLanguagesContext<P>(
-  WrappedComponent: React.ComponentType<
-    React.PropsWithChildren<React.PropsWithChildren<P & WithLanguagesContextProps>>
-  >,
+  WrappedComponent: React.ComponentType<React.PropsWithChildren<P & WithLanguagesContextProps>>,
 ) {
   return class WithLanguagesContext extends React.PureComponent<
     Omit<P, keyof WithLanguagesContextProps>
index 7c069e4ac368d5b495548fe29a7fd31145b6f829..496cecb8ffad427163126b87a240cb79b0a6d763 100644 (file)
@@ -27,9 +27,7 @@ export interface WithMetricsContextProps {
 }
 
 export default function withMetricsContext<P>(
-  WrappedComponent: React.ComponentType<
-    React.PropsWithChildren<React.PropsWithChildren<P & WithMetricsContextProps>>
-  >,
+  WrappedComponent: React.ComponentType<React.PropsWithChildren<P & WithMetricsContextProps>>,
 ) {
   return class WithMetricsContext extends React.PureComponent<
     Omit<P, keyof WithMetricsContextProps>
index 30e6b39962decdc016373b6e3d4c9014e9939e4d..3d3a933875ee20272cb704174399893633437a35 100644 (file)
@@ -34,20 +34,15 @@ export interface QualityProfilesContextProps {
 }
 
 export function withQualityProfilesContext<P extends Partial<QualityProfilesContextProps>>(
-  WrappedComponent: React.ComponentType<React.PropsWithChildren<React.PropsWithChildren<P>>>,
-): React.ComponentType<
-  React.PropsWithChildren<React.PropsWithChildren<Omit<P, keyof QualityProfilesContextProps>>>
-> {
+  WrappedComponent: React.ComponentType<React.PropsWithChildren<P>>,
+): React.ComponentType<React.PropsWithChildren<Omit<P, keyof QualityProfilesContextProps>>> {
   function ComponentWithQualityProfilesProps(props: P) {
     const context = useOutletContext<QualityProfilesContextProps>();
     return <WrappedComponent {...props} {...context} />;
   }
 
-  (
-    ComponentWithQualityProfilesProps as React.FC<
-      React.PropsWithChildren<React.PropsWithChildren<P>>
-    >
-  ).displayName = getWrappedDisplayName(WrappedComponent, 'withQualityProfilesContext');
+  (ComponentWithQualityProfilesProps as React.FC<React.PropsWithChildren<P>>).displayName =
+    getWrappedDisplayName(WrappedComponent, 'withQualityProfilesContext');
 
   return ComponentWithQualityProfilesProps;
 }
index b6740aa146682cbefcef33c947ab305ff2adac27..caf3af3f7b27a704210677121a726c1b3cd4968b 100644 (file)
@@ -37,9 +37,8 @@ export default function Input(props: Readonly<DefaultInputProps>) {
   const { definition } = setting;
   const name = getUniqueName(definition);
 
-  let Input: React.ComponentType<
-    React.PropsWithChildren<React.PropsWithChildren<DefaultSpecializedInputProps>>
-  > = PrimitiveInput;
+  let Input: React.ComponentType<React.PropsWithChildren<DefaultSpecializedInputProps>> =
+    PrimitiveInput;
 
   if (isCategoryDefinition(definition) && definition.multiValues) {
     Input = MultiValueInput;
index 0262e59d35e862dc26ed96103a81cd14980deee1..752c8974eb7ad781300a45f4600d35e8a8b6f6a0 100644 (file)
@@ -33,9 +33,7 @@ interface State {
 }
 
 interface Props extends DefaultInputProps {
-  input: React.ComponentType<
-    React.PropsWithChildren<React.PropsWithChildren<DefaultSpecializedInputProps>>
-  >;
+  input: React.ComponentType<React.PropsWithChildren<DefaultSpecializedInputProps>>;
 }
 
 export default class InputForSecured extends React.PureComponent<Props, State> {
index 6c23cbafaeb8070905812d4a2760052b3ea80ac6..509dc583b86a49dadece53ac8eac60787aa93e3f 100644 (file)
@@ -31,9 +31,7 @@ import InputForText from './InputForText';
 
 function withOptions(
   options: string[],
-): React.ComponentType<
-  React.PropsWithChildren<React.PropsWithChildren<DefaultSpecializedInputProps>>
-> {
+): React.ComponentType<React.PropsWithChildren<DefaultSpecializedInputProps>> {
   return function Wrapped(props: DefaultSpecializedInputProps) {
     return <InputForSingleSelectList options={options} {...props} />;
   };
@@ -44,7 +42,7 @@ export default function PrimitiveInput(props: DefaultSpecializedInputProps) {
   const { definition } = setting;
   const typeMapping: {
     [type in SettingType]?: React.ComponentType<
-      React.PropsWithChildren<React.PropsWithChildren<DefaultSpecializedInputProps>>
+      React.PropsWithChildren<DefaultSpecializedInputProps>
     >;
   } = {
     STRING: InputForString,
index de17d1bdf59a7f9a4b4d600625ae5303a7cd8f55..fe06d8ac8f35bdd496022595bfba8a403408c877 100644 (file)
@@ -18,7 +18,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 export function getWrappedDisplayName<P>(
-  WrappedComponent: React.ComponentType<React.PropsWithChildren<React.PropsWithChildren<P>>>,
+  WrappedComponent: React.ComponentType<React.PropsWithChildren<P>>,
   hocName: string,
 ) {
   const wrappedDisplayName = WrappedComponent.displayName ?? WrappedComponent.name ?? 'Component';
index 682f3c22ce1fa9a136b1fd1ea3efa81205a48f31..5c0ae8915a5cff07a2c7aa39fd4f722e551322f2 100644 (file)
@@ -23,9 +23,7 @@ import handleRequiredAuthentication from '../../helpers/handleRequiredAuthentica
 import { CurrentUser, isLoggedIn } from '../../types/users';
 import { getWrappedDisplayName } from './utils';
 
-export function whenLoggedIn<P>(
-  WrappedComponent: React.ComponentType<React.PropsWithChildren<React.PropsWithChildren<P>>>,
-) {
+export function whenLoggedIn<P>(WrappedComponent: React.ComponentType<React.PropsWithChildren<P>>) {
   class Wrapper extends React.Component<P & { currentUser: CurrentUser }> {
     static displayName = getWrappedDisplayName(WrappedComponent, 'whenLoggedIn');
 
index a7eb2b41b75951b0f04f9e01b523cce59504ee46..b7707a554bfe4e2cb279679a929d3a66fd16a1a2 100644 (file)
@@ -23,7 +23,7 @@ import { getWrappedDisplayName } from './utils';
 
 export function withCLanguageFeature<P>(
   WrappedComponent: React.ComponentType<
-    React.PropsWithChildren<React.PropsWithChildren<P & { hasCLanguageFeature: boolean }>>
+    React.PropsWithChildren<P & { hasCLanguageFeature: boolean }>
   >,
 ) {
   class Wrapper extends React.Component<Omit<P, 'hasCLanguageFeature'>> {
index a6e50ed6e0f7bb9815f319e40030627eafffcb54..6389f1fe692320f074bbf1ebc669f29419b7a608 100644 (file)
@@ -27,9 +27,7 @@ export interface WithIndexationContextProps {
 }
 
 export default function withIndexationContext<P>(
-  WrappedComponent: React.ComponentType<
-    React.PropsWithChildren<React.PropsWithChildren<P & WithIndexationContextProps>>
-  >,
+  WrappedComponent: React.ComponentType<React.PropsWithChildren<P & WithIndexationContextProps>>,
 ) {
   return class WithIndexationContext extends React.PureComponent<
     Omit<P, keyof WithIndexationContextProps>
index 66efb6f5441addfcd63a48439add2c846ecc65ce..d496db7cb39e1ba350a2b4eee8168113a19c8430 100644 (file)
@@ -25,7 +25,7 @@ export default function withIndexationGuard<P>({
   Component,
   showIndexationMessage,
 }: {
-  Component: React.ComponentType<React.PropsWithChildren<React.PropsWithChildren<P>>>;
+  Component: React.ComponentType<React.PropsWithChildren<P>>;
   showIndexationMessage: (props: P) => boolean;
 }) {
   return function WithIndexationGuard(props: React.PropsWithChildren<P>) {
index ccf20bab442a6ced8ae4fba48415de58cada719a..582b5b46e825b9165ac30e9ef309a4a856ab9555 100644 (file)
@@ -37,7 +37,7 @@ export interface WithKeyboardNavigationProps {
 
 export default function withKeyboardNavigation<P>(
   WrappedComponent: React.ComponentType<
-    React.PropsWithChildren<React.PropsWithChildren<P & Partial<WithKeyboardNavigationProps>>>
+    React.PropsWithChildren<P & Partial<WithKeyboardNavigationProps>>
   >,
 ) {
   return class Wrapper extends React.Component<P & WithKeyboardNavigationProps> {
index 21713420d5219cefd43f2fcfb628f8a36395a1f4..2ef061c2df49e5d3090b1735b77247fc92b8cd45 100644 (file)
@@ -21,9 +21,7 @@ import * as React from 'react';
 import { Location, useLocation } from 'react-router-dom';
 
 export default function withLocation<P>(
-  WrappedComponent: React.ComponentType<
-    React.PropsWithChildren<React.PropsWithChildren<P & { location: Location }>>
-  >,
+  WrappedComponent: React.ComponentType<React.PropsWithChildren<P & { location: Location }>>,
 ) {
   return function WithLocation(props: Omit<P, 'location'>) {
     const location = useLocation();
index 236a9b7a91b9bcfba45be3c6ed575488834ab5b7..344b4e04dff05d5421e329a38c34a30e723efd0e 100644 (file)
@@ -46,9 +46,7 @@ export interface WithNotificationsProps {
 }
 
 export function withNotifications<P>(
-  WrappedComponent: React.ComponentType<
-    React.PropsWithChildren<React.PropsWithChildren<P & WithNotificationsProps>>
-  >,
+  WrappedComponent: React.ComponentType<React.PropsWithChildren<P & WithNotificationsProps>>,
 ) {
   class Wrapper extends React.Component<P, State> {
     mounted = false;
index b352d94c2685404bcdf847c43eb1c68769b0c878..0a286faffa938eedc1b93ef16010425d359120d9 100644 (file)
@@ -45,10 +45,8 @@ export interface WithRouterProps {
 }
 
 export function withRouter<P extends Partial<WithRouterProps>>(
-  WrappedComponent: React.ComponentType<React.PropsWithChildren<React.PropsWithChildren<P>>>,
-): React.ComponentType<
-  React.PropsWithChildren<React.PropsWithChildren<Omit<P, keyof WithRouterProps>>>
-> {
+  WrappedComponent: React.ComponentType<React.PropsWithChildren<P>>,
+): React.ComponentType<React.PropsWithChildren<Omit<P, keyof WithRouterProps>>> {
   function ComponentWithRouterProp(props: P) {
     const router = useRouter();
     const params = useParams();
@@ -57,9 +55,8 @@ export function withRouter<P extends Partial<WithRouterProps>>(
     return <WrappedComponent {...props} location={location} params={params} router={router} />;
   }
 
-  (
-    ComponentWithRouterProp as React.FC<React.PropsWithChildren<React.PropsWithChildren<P>>>
-  ).displayName = getWrappedDisplayName(WrappedComponent, 'withRouter');
+  (ComponentWithRouterProp as React.FC<React.PropsWithChildren<P>>).displayName =
+    getWrappedDisplayName(WrappedComponent, 'withRouter');
 
   return ComponentWithRouterProp;
 }
index 880f59ecc1137bf0d83fdcd9fe23efb8c674a0c0..4c01773c226ec929be110f56ec1f8cb409348326 100644 (file)
@@ -43,9 +43,7 @@ export default function ProjectLinkIcon({
   type,
   ...iconProps
 }: IconProps & ProjectLinkIconProps) {
-  const getIcon = (): FC<
-    React.PropsWithChildren<React.PropsWithChildren<IconProps | MIUIIconProps>>
-  > => {
+  const getIcon = (): FC<React.PropsWithChildren<IconProps | MIUIIconProps>> => {
     switch (type) {
       case 'issue':
         return miui ? PulseIcon : BugTrackerIcon;
index 118a54a1ef8cab76fd0eddbdf9c33f88173e57b7..54870af792c69164c86e7fd911e99942e37b9507 100644 (file)
@@ -37,9 +37,7 @@ interface Props {
   sections?: RuleDescriptionSection[];
 }
 
-const EDUCATION_PRINCIPLES_MAP: Dict<
-  React.ComponentType<React.PropsWithChildren<React.PropsWithChildren<unknown>>>
-> = {
+const EDUCATION_PRINCIPLES_MAP: Dict<React.ComponentType<React.PropsWithChildren>> = {
   defense_in_depth: DefenseInDepth,
   never_trust_user_input: NeverTrustUserInput,
 };
index 162d2a742e7db2e311422fe5ca0ab9ecbf2b1d6c..d1b33805c1f08571250fe72b0735b0667e0def9c 100644 (file)
@@ -37,9 +37,7 @@ const BUILD_TOOLS_WITH_NO_ADDITIONAL_OPTIONS = [
 ];
 
 const BUILDTOOL_COMPONENT_MAP: {
-  [x in BuildTools]: React.ComponentType<
-    React.PropsWithChildren<React.PropsWithChildren<LanguageProps>>
-  >;
+  [x in BuildTools]: React.ComponentType<React.PropsWithChildren<LanguageProps>>;
 } = {
   [BuildTools.Maven]: Maven,
   [BuildTools.Gradle]: Gradle,
index 2d5d7af9978f30da3b830296af39a756851d0823..86d6d169dbfaa581bfa756e921254cd75ed783f1 100644 (file)
@@ -84,7 +84,7 @@ export default class WorkspaceHeader extends React.PureComponent<Props> {
 }
 
 interface WorkspaceHeaderButtonProps {
-  icon: React.FC<React.PropsWithChildren<React.PropsWithChildren<IconProps>>>;
+  icon: React.FC<React.PropsWithChildren<IconProps>>;
   onClick: () => void;
   tooltip: string;
 }
index d4b9704c79a74f7ac25aa6fad43cc846ecabeb42..e90027801385c4a9763da47a27bdef2adb163916 100644 (file)
 import { ComponentClass, FunctionComponent } from 'react';
 
 export type ComponentPropsType<
-  T extends
-    | ComponentClass
-    | FunctionComponent<React.PropsWithChildren<React.PropsWithChildren<any>>>,
+  T extends ComponentClass | FunctionComponent<React.PropsWithChildren<any>>,
 > = T extends ComponentClass<infer P>
   ? P
-  : T extends FunctionComponent<React.PropsWithChildren<React.PropsWithChildren<infer P>>>
+  : T extends FunctionComponent<React.PropsWithChildren<infer P>>
   ? P
   : never;
 
index ffbdff3369f6887e18fc5ce05fda911b04326d3c..31ca666967f0f8bcc86c1e54847f480a79badd4a 100644 (file)
@@ -334,9 +334,7 @@ export function withBranchLikes<P extends { component?: Component }>(
       >
     >
   >,
-): React.ComponentType<
-  React.PropsWithChildren<React.PropsWithChildren<Omit<P, 'branchLike' | 'branchLikes'>>>
-> {
+): React.ComponentType<React.PropsWithChildren<Omit<P, 'branchLike' | 'branchLikes'>>> {
   return function WithBranchLike(p: P) {
     const { data, isFetching } = useBranchesQuery(p.component);
     return (
@@ -353,10 +351,8 @@ export function withBranchLikes<P extends { component?: Component }>(
 export function withBranchStatusRefresh<
   P extends { refreshBranchStatus: ReturnType<typeof useRefreshBranchStatus> },
 >(
-  WrappedComponent: React.ComponentType<React.PropsWithChildren<React.PropsWithChildren<P>>>,
-): React.ComponentType<
-  React.PropsWithChildren<React.PropsWithChildren<Omit<P, 'refreshBranchStatus'>>>
-> {
+  WrappedComponent: React.ComponentType<React.PropsWithChildren<P>>,
+): React.ComponentType<React.PropsWithChildren<Omit<P, 'refreshBranchStatus'>>> {
   return function WithBranchStatusRefresh(props: P) {
     const refresh = useRefreshBranchStatus();