Kaynağa Gözat

Renames & `eslint-disable react/require-default-props` removal (#5251)

* `eslint-disable react/require-default-props` - remove

* `GridItem.tsx`, `ListItem.tsx` - rename
Evgenia Karunus 10 ay önce
ebeveyn
işleme
2ba00ec6ca

+ 4 - 4
packages/@uppy/provider-views/src/Item/components/GridLi.tsx → packages/@uppy/provider-views/src/Item/components/GridItem.tsx

@@ -4,7 +4,7 @@ import classNames from 'classnames'
 import type { RestrictionError } from '@uppy/core/lib/Restricter'
 import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
 
-type GridListItemProps<M extends Meta, B extends Body> = {
+type GridItemProps<M extends Meta, B extends Body> = {
   className: string
   isDisabled: boolean
   restrictionError?: RestrictionError<M, B> | null
@@ -18,8 +18,8 @@ type GridListItemProps<M extends Meta, B extends Body> = {
   children?: ComponentChildren
 }
 
-function GridListItem<M extends Meta, B extends Body>(
-  props: GridListItemProps<M, B>,
+function GridItem<M extends Meta, B extends Body>(
+  props: GridItemProps<M, B>,
 ): h.JSX.Element {
   const {
     className,
@@ -73,4 +73,4 @@ function GridListItem<M extends Meta, B extends Body>(
   )
 }
 
-export default GridListItem
+export default GridItem

+ 7 - 5
packages/@uppy/provider-views/src/Item/components/ItemIcon.tsx

@@ -1,4 +1,3 @@
-/* eslint-disable react/require-default-props */
 import { h } from 'preact'
 
 function FileIcon() {
@@ -44,11 +43,15 @@ function VideoIcon() {
   )
 }
 
-export default function ItemIcon(props: {
+type ItemIconProps = {
   itemIconString: string
   alt?: string
-}): h.JSX.Element | null {
-  const { itemIconString } = props
+}
+
+export default function ItemIcon({
+  itemIconString,
+  alt = undefined,
+}: ItemIconProps): h.JSX.Element | null {
   if (itemIconString === null) return null
 
   switch (itemIconString) {
@@ -59,7 +62,6 @@ export default function ItemIcon(props: {
     case 'video':
       return <VideoIcon />
     default: {
-      const { alt } = props
       return (
         <img
           src={itemIconString}

+ 0 - 0
packages/@uppy/provider-views/src/Item/components/ListLi.tsx → packages/@uppy/provider-views/src/Item/components/ListItem.tsx


+ 5 - 5
packages/@uppy/provider-views/src/Item/index.tsx

@@ -7,8 +7,8 @@ import type { CompanionFile } from '@uppy/utils/lib/CompanionFile'
 import type { RestrictionError } from '@uppy/core/lib/Restricter'
 import type { Meta, Body } from '@uppy/utils/lib/UppyFile'
 import ItemIcon from './components/ItemIcon.tsx'
-import GridListItem from './components/GridLi.tsx'
-import ListItem from './components/ListLi.tsx'
+import GridItem from './components/GridItem.tsx'
+import ListItem from './components/ListItem.tsx'
 
 type ItemProps<M extends Meta, B extends Body> = {
   showTitles: boolean
@@ -46,7 +46,7 @@ export default function Item<M extends Meta, B extends Body>(
   switch (viewType) {
     case 'grid':
       return (
-        <GridListItem<M, B>
+        <GridItem<M, B>
           // eslint-disable-next-line react/jsx-props-no-spreading
           {...props}
           className={className}
@@ -64,7 +64,7 @@ export default function Item<M extends Meta, B extends Body>(
       )
     case 'unsplash':
       return (
-        <GridListItem<M, B>
+        <GridItem<M, B>
           // eslint-disable-next-line react/jsx-props-no-spreading
           {...props}
           className={className}
@@ -79,7 +79,7 @@ export default function Item<M extends Meta, B extends Body>(
           >
             {author!.name}
           </a>
-        </GridListItem>
+        </GridItem>
       )
     default:
       throw new Error(`There is no such type ${viewType}`)

+ 8 - 13
packages/@uppy/provider-views/src/ProviderView/AuthView.tsx

@@ -1,4 +1,3 @@
-/* eslint-disable react/require-default-props */
 import { h } from 'preact'
 import { useCallback } from 'preact/hooks'
 import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
@@ -105,18 +104,14 @@ const defaultRenderForm = ({
   onAuth: AuthViewProps<Meta, Body>['handleAuth']
 }) => <DefaultForm pluginName={pluginName} i18n={i18n} onAuth={onAuth} />
 
-export default function AuthView<M extends Meta, B extends Body>(
-  props: AuthViewProps<M, B>,
-) {
-  const {
-    loading,
-    pluginName,
-    pluginIcon,
-    i18n,
-    handleAuth,
-    renderForm = defaultRenderForm,
-  } = props
-
+export default function AuthView<M extends Meta, B extends Body>({
+  loading,
+  pluginName,
+  pluginIcon,
+  i18n,
+  handleAuth,
+  renderForm = defaultRenderForm,
+}: AuthViewProps<M, B>) {
   return (
     <div className="uppy-Provider-auth">
       <div className="uppy-Provider-authIcon">{pluginIcon()}</div>