Skip to content

Commit

Permalink
Import types consistently from @uppy/core (#5589)
Browse files Browse the repository at this point in the history
* Import types consistently from @uppy/core

* Add new eslint rule

* Clean up exports
  • Loading branch information
Murderlon authored Jan 9, 2025
1 parent 817ce72 commit 6e65cd8
Show file tree
Hide file tree
Showing 85 changed files with 293 additions and 208 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ module.exports = {
}, {
selector: 'ImportDeclaration[source.value=/^@uppy\\x2Futils\\x2Flib\\x2F.+\\.[mc]?[jt]sx?$/]',
message: 'Do not use file extension when importing from @uppy/utils',
},
{
selector: 'ImportDeclaration[source.value=/^@uppy\\x2F[a-z-0-9]+\\x2Fsrc\\x2F/]',
message: 'Importing from "src/" is not allowed. Import from root or from "lib/" if you must.',
}],
'import/extensions': ['error', 'ignorePackages'],
'import/prefer-default-export': 'off',
Expand Down
7 changes: 4 additions & 3 deletions packages/@uppy/audio/src/Audio.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { h } from 'preact'

import { UIPlugin, type UIPluginOptions } from '@uppy/core'
import { UIPlugin } from '@uppy/core'
import type {
Uppy,
UIPluginOptions,
Body,
Meta,
MinimalRequiredUppyFile,
} from '@uppy/utils/lib/UppyFile'
import type { Uppy } from '@uppy/core/lib/Uppy.js'
} from '@uppy/core'

import getFileTypeExtension from '@uppy/utils/lib/getFileTypeExtension'
import supportsMediaRecorder from './supportsMediaRecorder.js'
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/aws-s3/src/HTTPCommunicationQueue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Meta, Body, UppyFile } from '@uppy/utils/lib/UppyFile'
import type { Meta, Body, UppyFile } from '@uppy/core'
import type {
RateLimitedQueue,
WrapPromiseFunctionType,
Expand Down
7 changes: 4 additions & 3 deletions packages/@uppy/aws-s3/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import BasePlugin, {
import {
type DefinePluginOpts,
type PluginOpts,
} from '@uppy/core/lib/BasePlugin.js'
Uppy,
BasePlugin,
} from '@uppy/core'
import { RequestClient } from '@uppy/companion-client'
import type { RequestOptions } from '@uppy/utils/lib/CompanionClientProvider'
import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile'
import type { Uppy } from '@uppy/core'
import EventManager from '@uppy/core/lib/EventManager.js'
import { RateLimitedQueue } from '@uppy/utils/lib/RateLimitedQueue'
import {
Expand Down
6 changes: 4 additions & 2 deletions packages/@uppy/box/src/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import { UIPlugin, Uppy } from '@uppy/core'
import { ProviderViews } from '@uppy/provider-views'
import { h, type ComponentChild } from 'preact'

import type { UppyFile, Body, Meta } from '@uppy/utils/lib/UppyFile'
import type {
UppyFile,
Body,
Meta,
AsyncStore,
UnknownProviderPlugin,
UnknownProviderPluginState,
} from '@uppy/core/lib/Uppy.js'
} from '@uppy/core'
import locale from './locale.js'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore We don't want TS to generate types for the package.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { UIPluginOptions } from '@uppy/core'
import type { AsyncStore } from '@uppy/core/lib/Uppy.js'
import type { UIPluginOptions, AsyncStore } from '@uppy/core'

export interface CompanionPluginOptions extends UIPluginOptions {
storage?: AsyncStore
Expand Down
11 changes: 7 additions & 4 deletions packages/@uppy/companion-client/src/Provider.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import type { Uppy } from '@uppy/core'
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
import type { PluginOpts } from '@uppy/core/lib/BasePlugin.js'
import type {
Uppy,
Body,
Meta,
PluginOpts,
UnknownProviderPlugin,
} from '@uppy/core'
import type {
RequestOptions,
CompanionClientProvider,
} from '@uppy/utils/lib/CompanionClientProvider'
import type { UnknownProviderPlugin } from '@uppy/core/lib/Uppy.js'
import RequestClient, { authErrorStatusCode } from './RequestClient.js'
import type { CompanionPluginOptions } from './index.js'
import { isOriginAllowed } from './getAllowedHosts.js'
Expand Down
3 changes: 1 addition & 2 deletions packages/@uppy/companion-client/src/SearchProvider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
import type { Uppy } from '@uppy/core'
import type { Body, Meta, Uppy } from '@uppy/core'
import type { CompanionClientSearchProvider } from '@uppy/utils/lib/CompanionClientProvider'
import RequestClient, { type Opts } from './RequestClient.js'

Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/compressor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import prettierBytes from '@transloadit/prettier-bytes'
import CompressorJS from 'compressorjs'

import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile'
import type { DefinePluginOpts, PluginOpts } from '@uppy/core/lib/BasePlugin.js'
import type { DefinePluginOpts, PluginOpts } from '@uppy/core'

import locale from './locale.js'

Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/core/src/Uppy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import assert from 'node:assert'
import fs from 'node:fs'
import path from 'node:path'
import prettierBytes from '@transloadit/prettier-bytes'
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
import type { Body, Meta } from '@uppy/core'
import type { Locale } from '@uppy/utils/lib/Translator'
import Core from './index.js'
import UIPlugin from './UIPlugin.js'
Expand Down
36 changes: 25 additions & 11 deletions packages/@uppy/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
export { default } from './Uppy.js'
export {
default as Uppy,
type State,
type UnknownPlugin,
type UnknownProviderPlugin,
type UnknownSearchProviderPlugin,
type UploadResult,
type UppyEventMap,
type UppyOptions,
export { default, default as Uppy } from './Uppy.js'
export type {
State,
BaseProviderPlugin,
PartialTree,
PartialTreeFile,
PartialTreeFolder,
PartialTreeFolderNode,
PartialTreeFolderRoot,
PartialTreeId,
UnknownPlugin,
UnknownProviderPlugin,
UnknownProviderPluginState,
UnknownSearchProviderPlugin,
UnknownSearchProviderPluginState,
UploadResult,
UppyEventMap,
UppyOptions,
AsyncStore,
} from './Uppy.js'

export { default as UIPlugin } from './UIPlugin.js'
Expand All @@ -20,4 +29,9 @@ export { debugLogger } from './loggers.js'

export type { Store } from '@uppy/store-default'

export type { UppyFile, Meta, Body } from '@uppy/utils/lib/UppyFile'
export type {
UppyFile,
MinimalRequiredUppyFile,
Meta,
Body,
} from '@uppy/utils/lib/UppyFile'
22 changes: 12 additions & 10 deletions packages/@uppy/dashboard/src/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import {
UIPlugin,
type UIPluginOptions,
type UnknownPlugin,
type Uppy,
type UploadResult,
type State,
} from '@uppy/core'
import type { ComponentChild, VNode } from 'preact'
import type { DefinePluginOpts } from '@uppy/core/lib/BasePlugin.js'
import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile'
import { UIPlugin } from '@uppy/core'
import type {
Body,
Meta,
UppyFile,
UIPluginOptions,
UnknownPlugin,
Uppy,
UploadResult,
State,
DefinePluginOpts,
} from '@uppy/core'
import StatusBar from '@uppy/status-bar'
import Informer from '@uppy/informer'
import ThumbnailGenerator from '@uppy/thumbnail-generator'
Expand Down
11 changes: 9 additions & 2 deletions packages/@uppy/dashboard/src/components/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
import { h } from 'preact'
import classNames from 'classnames'
import isDragDropSupported from '@uppy/utils/lib/isDragDropSupported'
import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile'
import type { State, UIPlugin, UIPluginOptions, Uppy } from '@uppy/core'
import type {
Body,
Meta,
UppyFile,
State,
UIPlugin,
UIPluginOptions,
Uppy,
} from '@uppy/core'
import type { I18n } from '@uppy/utils/lib/Translator'
import type Translator from '@uppy/utils/lib/Translator'
import type { TargetedEvent } from 'preact/compat'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { h } from 'preact'
import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile'
import type { Body, Meta, UppyFile } from '@uppy/core'
import type Uppy from '@uppy/core'
import type { I18n } from '@uppy/utils/lib/Translator'
import copyToClipboard from '../../../utils/copyToClipboard.js'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable react/no-unused-prop-types */
/* eslint-disable react/destructuring-assignment */
import type { State, Uppy, UppyFile } from '@uppy/core'
import type { Body, Meta, State, Uppy, UppyFile } from '@uppy/core'
import type { I18n } from '@uppy/utils/lib/Translator'
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
import { h, type ComponentChild } from 'preact'

interface Props<M extends Meta, B extends Body> {
Expand Down
3 changes: 1 addition & 2 deletions packages/@uppy/dashboard/src/components/FileItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
import { h, Component, type ComponentChild } from 'preact'
import classNames from 'classnames'
import { shallowEqualObjects } from 'shallow-equal'
import type { UppyFile, Body, Meta } from '@uppy/utils/lib/UppyFile'
import type { UppyFile, Body, Meta, State } from '@uppy/core'
import type { I18n } from '@uppy/utils/lib/Translator'
import type Uppy from '@uppy/core'
import type { State } from '@uppy/core'
import FilePreviewAndLink from './FilePreviewAndLink/index.jsx'
import FileProgress from './FileProgress/index.jsx'
import FileInfo from './FileInfo/index.jsx'
Expand Down
3 changes: 1 addition & 2 deletions packages/@uppy/dashboard/src/components/FileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { useMemo } from 'preact/hooks'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore untyped
import VirtualList from '@uppy/utils/lib/VirtualList'
import type { UppyFile, Uppy, State } from '@uppy/core'
import type { UppyFile, Uppy, State, Body, Meta } from '@uppy/core'
import type { I18n } from '@uppy/utils/lib/Translator'
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
import FileItem from './FileItem/index.jsx'
import type { DashboardState } from '../Dashboard.js'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UppyFile } from '@uppy/utils/lib/UppyFile'
import type { UppyFile } from '@uppy/core'
import { h } from 'preact'

type $TSFixMe = any
Expand Down
12 changes: 8 additions & 4 deletions packages/@uppy/drag-drop/src/DragDrop.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { UIPlugin, type Uppy } from '@uppy/core'
import type { DefinePluginOpts } from '@uppy/core/lib/BasePlugin.js'
import type { UIPluginOptions } from '@uppy/core/lib/UIPlugin.js'
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
import { UIPlugin } from '@uppy/core'
import type {
UIPluginOptions,
Uppy,
DefinePluginOpts,
Body,
Meta,
} from '@uppy/core'
import type { TargetedEvent } from 'preact/compat'
import toArray from '@uppy/utils/lib/toArray'
import isDragDropSupported from '@uppy/utils/lib/isDragDropSupported'
Expand Down
6 changes: 2 additions & 4 deletions packages/@uppy/drop-target/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
import type { Uppy } from '@uppy/core/lib/Uppy.js'
import type { DefinePluginOpts, PluginOpts } from '@uppy/core/lib/BasePlugin.js'
import BasePlugin from '@uppy/core/lib/BasePlugin.js'
import type { Uppy, Body, Meta, DefinePluginOpts, PluginOpts } from '@uppy/core'
import { BasePlugin } from '@uppy/core'
import getDroppedFiles from '@uppy/utils/lib/getDroppedFiles'
import toArray from '@uppy/utils/lib/toArray'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down
6 changes: 4 additions & 2 deletions packages/@uppy/dropbox/src/Dropbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import { UIPlugin, Uppy } from '@uppy/core'
import { ProviderViews } from '@uppy/provider-views'
import { h, type ComponentChild } from 'preact'

import type { UppyFile, Body, Meta } from '@uppy/utils/lib/UppyFile'
import type {
UppyFile,
Body,
Meta,
AsyncStore,
UnknownProviderPlugin,
UnknownProviderPluginState,
} from '@uppy/core/lib/Uppy.js'
} from '@uppy/core'
import locale from './locale.js'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore We don't want TS to generate types for the package.json
Expand Down
6 changes: 4 additions & 2 deletions packages/@uppy/facebook/src/Facebook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import { UIPlugin, Uppy } from '@uppy/core'
import { ProviderViews } from '@uppy/provider-views'
import { h, type ComponentChild } from 'preact'

import type { UppyFile, Body, Meta } from '@uppy/utils/lib/UppyFile'
import type {
UppyFile,
Body,
Meta,
AsyncStore,
UnknownProviderPlugin,
UnknownProviderPluginState,
} from '@uppy/core/lib/Uppy.js'
} from '@uppy/core'
import locale from './locale.js'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore We don't want TS to generate types for the package.json
Expand Down
11 changes: 8 additions & 3 deletions packages/@uppy/file-input/src/FileInput.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { h, type ComponentChild } from 'preact'

import { UIPlugin, Uppy, type UIPluginOptions } from '@uppy/core'
import { UIPlugin } from '@uppy/core'
import type {
Uppy,
UIPluginOptions,
Body,
Meta,
DefinePluginOpts,
} from '@uppy/core'
import toArray from '@uppy/utils/lib/toArray'
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
import type { DefinePluginOpts } from '@uppy/core/lib/BasePlugin.js'
import type { TargetedEvent } from 'preact/compat'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore We don't want TS to generate types for the package.json
Expand Down
12 changes: 9 additions & 3 deletions packages/@uppy/form/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import BasePlugin, { type DefinePluginOpts } from '@uppy/core/lib/BasePlugin.js'
import { BasePlugin } from '@uppy/core'
import type {
DefinePluginOpts,
UIPluginOptions,
Uppy,
UppyEventMap,
Body,
Meta,
} from '@uppy/core'
import findDOMElement from '@uppy/utils/lib/findDOMElement'
import toArray from '@uppy/utils/lib/toArray'

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore untyped
import getFormData from 'get-form-data'

import type { UIPluginOptions, Uppy, UppyEventMap } from '@uppy/core'
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore We don't want TS to generate types for the package.json
import packageJson from '../package.json'
Expand Down
3 changes: 1 addition & 2 deletions packages/@uppy/golden-retriever/src/MetaDataStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { State as UppyState } from '@uppy/core'
import type { Meta, Body } from '@uppy/utils/lib/UppyFile'
import type { State as UppyState, Meta, Body } from '@uppy/core'

export type StoredState<M extends Meta, B extends Body> = {
expires: number
Expand Down
15 changes: 10 additions & 5 deletions packages/@uppy/golden-retriever/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import throttle from 'lodash/throttle.js'
import BasePlugin from '@uppy/core/lib/BasePlugin.js'
import type { PluginOpts, DefinePluginOpts } from '@uppy/core/lib/BasePlugin.js'
import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile'
import type Uppy from '@uppy/core'
import type { UploadResult } from '@uppy/core'
import { BasePlugin } from '@uppy/core'
import type {
Body,
Meta,
UppyFile,
Uppy,
UploadResult,
PluginOpts,
DefinePluginOpts,
} from '@uppy/core'
import ServiceWorkerStore, {
type ServiceWorkerStoredFile,
} from './ServiceWorkerStore.js'
Expand Down
3 changes: 1 addition & 2 deletions packages/@uppy/google-drive-picker/src/GoogleDrivePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import {
} from '@uppy/companion-client'

import type { PickedItem } from '@uppy/provider-views/lib/GooglePicker/googlePicker.js'
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
import type { AsyncStore, BaseProviderPlugin } from '@uppy/core/lib/Uppy.js'
import type { Body, Meta, AsyncStore, BaseProviderPlugin } from '@uppy/core'

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore We don't want TS to generate types for the package.json
Expand Down
Loading

0 comments on commit 6e65cd8

Please sign in to comment.