Skip to content

Commit 6e65cd8

Browse files
authored
Import types consistently from @uppy/core (#5589)
* Import types consistently from @uppy/core * Add new eslint rule * Clean up exports
1 parent 817ce72 commit 6e65cd8

File tree

85 files changed

+293
-208
lines changed

Some content is hidden

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

85 files changed

+293
-208
lines changed

.eslintrc.js

+4
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,10 @@ module.exports = {
441441
}, {
442442
selector: 'ImportDeclaration[source.value=/^@uppy\\x2Futils\\x2Flib\\x2F.+\\.[mc]?[jt]sx?$/]',
443443
message: 'Do not use file extension when importing from @uppy/utils',
444+
},
445+
{
446+
selector: 'ImportDeclaration[source.value=/^@uppy\\x2F[a-z-0-9]+\\x2Fsrc\\x2F/]',
447+
message: 'Importing from "src/" is not allowed. Import from root or from "lib/" if you must.',
444448
}],
445449
'import/extensions': ['error', 'ignorePackages'],
446450
'import/prefer-default-export': 'off',

packages/@uppy/audio/src/Audio.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { h } from 'preact'
22

3-
import { UIPlugin, type UIPluginOptions } from '@uppy/core'
3+
import { UIPlugin } from '@uppy/core'
44
import type {
5+
Uppy,
6+
UIPluginOptions,
57
Body,
68
Meta,
79
MinimalRequiredUppyFile,
8-
} from '@uppy/utils/lib/UppyFile'
9-
import type { Uppy } from '@uppy/core/lib/Uppy.js'
10+
} from '@uppy/core'
1011

1112
import getFileTypeExtension from '@uppy/utils/lib/getFileTypeExtension'
1213
import supportsMediaRecorder from './supportsMediaRecorder.js'

packages/@uppy/aws-s3/src/HTTPCommunicationQueue.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Meta, Body, UppyFile } from '@uppy/utils/lib/UppyFile'
1+
import type { Meta, Body, UppyFile } from '@uppy/core'
22
import type {
33
RateLimitedQueue,
44
WrapPromiseFunctionType,

packages/@uppy/aws-s3/src/index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import BasePlugin, {
1+
import {
22
type DefinePluginOpts,
33
type PluginOpts,
4-
} from '@uppy/core/lib/BasePlugin.js'
4+
Uppy,
5+
BasePlugin,
6+
} from '@uppy/core'
57
import { RequestClient } from '@uppy/companion-client'
68
import type { RequestOptions } from '@uppy/utils/lib/CompanionClientProvider'
79
import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile'
8-
import type { Uppy } from '@uppy/core'
910
import EventManager from '@uppy/core/lib/EventManager.js'
1011
import { RateLimitedQueue } from '@uppy/utils/lib/RateLimitedQueue'
1112
import {

packages/@uppy/box/src/Box.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import { UIPlugin, Uppy } from '@uppy/core'
88
import { ProviderViews } from '@uppy/provider-views'
99
import { h, type ComponentChild } from 'preact'
1010

11-
import type { UppyFile, Body, Meta } from '@uppy/utils/lib/UppyFile'
1211
import type {
12+
UppyFile,
13+
Body,
14+
Meta,
1315
AsyncStore,
1416
UnknownProviderPlugin,
1517
UnknownProviderPluginState,
16-
} from '@uppy/core/lib/Uppy.js'
18+
} from '@uppy/core'
1719
import locale from './locale.js'
1820
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1921
// @ts-ignore We don't want TS to generate types for the package.json

packages/@uppy/companion-client/src/CompanionPluginOptions.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { UIPluginOptions } from '@uppy/core'
2-
import type { AsyncStore } from '@uppy/core/lib/Uppy.js'
1+
import type { UIPluginOptions, AsyncStore } from '@uppy/core'
32

43
export interface CompanionPluginOptions extends UIPluginOptions {
54
storage?: AsyncStore

packages/@uppy/companion-client/src/Provider.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
import type { Uppy } from '@uppy/core'
2-
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
3-
import type { PluginOpts } from '@uppy/core/lib/BasePlugin.js'
1+
import type {
2+
Uppy,
3+
Body,
4+
Meta,
5+
PluginOpts,
6+
UnknownProviderPlugin,
7+
} from '@uppy/core'
48
import type {
59
RequestOptions,
610
CompanionClientProvider,
711
} from '@uppy/utils/lib/CompanionClientProvider'
8-
import type { UnknownProviderPlugin } from '@uppy/core/lib/Uppy.js'
912
import RequestClient, { authErrorStatusCode } from './RequestClient.js'
1013
import type { CompanionPluginOptions } from './index.js'
1114
import { isOriginAllowed } from './getAllowedHosts.js'

packages/@uppy/companion-client/src/SearchProvider.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
2-
import type { Uppy } from '@uppy/core'
1+
import type { Body, Meta, Uppy } from '@uppy/core'
32
import type { CompanionClientSearchProvider } from '@uppy/utils/lib/CompanionClientProvider'
43
import RequestClient, { type Opts } from './RequestClient.js'
54

packages/@uppy/compressor/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import prettierBytes from '@transloadit/prettier-bytes'
77
import CompressorJS from 'compressorjs'
88

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

1212
import locale from './locale.js'
1313

packages/@uppy/core/src/Uppy.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import assert from 'node:assert'
66
import fs from 'node:fs'
77
import path from 'node:path'
88
import prettierBytes from '@transloadit/prettier-bytes'
9-
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
9+
import type { Body, Meta } from '@uppy/core'
1010
import type { Locale } from '@uppy/utils/lib/Translator'
1111
import Core from './index.js'
1212
import UIPlugin from './UIPlugin.js'

packages/@uppy/core/src/index.ts

+25-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
1-
export { default } from './Uppy.js'
2-
export {
3-
default as Uppy,
4-
type State,
5-
type UnknownPlugin,
6-
type UnknownProviderPlugin,
7-
type UnknownSearchProviderPlugin,
8-
type UploadResult,
9-
type UppyEventMap,
10-
type UppyOptions,
1+
export { default, default as Uppy } from './Uppy.js'
2+
export type {
3+
State,
4+
BaseProviderPlugin,
5+
PartialTree,
6+
PartialTreeFile,
7+
PartialTreeFolder,
8+
PartialTreeFolderNode,
9+
PartialTreeFolderRoot,
10+
PartialTreeId,
11+
UnknownPlugin,
12+
UnknownProviderPlugin,
13+
UnknownProviderPluginState,
14+
UnknownSearchProviderPlugin,
15+
UnknownSearchProviderPluginState,
16+
UploadResult,
17+
UppyEventMap,
18+
UppyOptions,
19+
AsyncStore,
1120
} from './Uppy.js'
1221

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

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

23-
export type { UppyFile, Meta, Body } from '@uppy/utils/lib/UppyFile'
32+
export type {
33+
UppyFile,
34+
MinimalRequiredUppyFile,
35+
Meta,
36+
Body,
37+
} from '@uppy/utils/lib/UppyFile'

packages/@uppy/dashboard/src/Dashboard.tsx

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
import {
2-
UIPlugin,
3-
type UIPluginOptions,
4-
type UnknownPlugin,
5-
type Uppy,
6-
type UploadResult,
7-
type State,
8-
} from '@uppy/core'
91
import type { ComponentChild, VNode } from 'preact'
10-
import type { DefinePluginOpts } from '@uppy/core/lib/BasePlugin.js'
11-
import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile'
2+
import { UIPlugin } from '@uppy/core'
3+
import type {
4+
Body,
5+
Meta,
6+
UppyFile,
7+
UIPluginOptions,
8+
UnknownPlugin,
9+
Uppy,
10+
UploadResult,
11+
State,
12+
DefinePluginOpts,
13+
} from '@uppy/core'
1214
import StatusBar from '@uppy/status-bar'
1315
import Informer from '@uppy/informer'
1416
import ThumbnailGenerator from '@uppy/thumbnail-generator'

packages/@uppy/dashboard/src/components/Dashboard.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22
import { h } from 'preact'
33
import classNames from 'classnames'
44
import isDragDropSupported from '@uppy/utils/lib/isDragDropSupported'
5-
import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile'
6-
import type { State, UIPlugin, UIPluginOptions, Uppy } from '@uppy/core'
5+
import type {
6+
Body,
7+
Meta,
8+
UppyFile,
9+
State,
10+
UIPlugin,
11+
UIPluginOptions,
12+
Uppy,
13+
} from '@uppy/core'
714
import type { I18n } from '@uppy/utils/lib/Translator'
815
import type Translator from '@uppy/utils/lib/Translator'
916
import type { TargetedEvent } from 'preact/compat'

packages/@uppy/dashboard/src/components/FileItem/Buttons/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { h } from 'preact'
2-
import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile'
2+
import type { Body, Meta, UppyFile } from '@uppy/core'
33
import type Uppy from '@uppy/core'
44
import type { I18n } from '@uppy/utils/lib/Translator'
55
import copyToClipboard from '../../../utils/copyToClipboard.js'

packages/@uppy/dashboard/src/components/FileItem/FileProgress/index.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/* eslint-disable react/no-unused-prop-types */
22
/* eslint-disable react/destructuring-assignment */
3-
import type { State, Uppy, UppyFile } from '@uppy/core'
3+
import type { Body, Meta, State, Uppy, UppyFile } from '@uppy/core'
44
import type { I18n } from '@uppy/utils/lib/Translator'
5-
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
65
import { h, type ComponentChild } from 'preact'
76

87
interface Props<M extends Meta, B extends Body> {

packages/@uppy/dashboard/src/components/FileItem/index.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
import { h, Component, type ComponentChild } from 'preact'
33
import classNames from 'classnames'
44
import { shallowEqualObjects } from 'shallow-equal'
5-
import type { UppyFile, Body, Meta } from '@uppy/utils/lib/UppyFile'
5+
import type { UppyFile, Body, Meta, State } from '@uppy/core'
66
import type { I18n } from '@uppy/utils/lib/Translator'
77
import type Uppy from '@uppy/core'
8-
import type { State } from '@uppy/core'
98
import FilePreviewAndLink from './FilePreviewAndLink/index.jsx'
109
import FileProgress from './FileProgress/index.jsx'
1110
import FileInfo from './FileInfo/index.jsx'

packages/@uppy/dashboard/src/components/FileList.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import { useMemo } from 'preact/hooks'
33
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
44
// @ts-ignore untyped
55
import VirtualList from '@uppy/utils/lib/VirtualList'
6-
import type { UppyFile, Uppy, State } from '@uppy/core'
6+
import type { UppyFile, Uppy, State, Body, Meta } from '@uppy/core'
77
import type { I18n } from '@uppy/utils/lib/Translator'
8-
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
98
import FileItem from './FileItem/index.jsx'
109
import type { DashboardState } from '../Dashboard.js'
1110

packages/@uppy/dashboard/src/components/PickerPanelTopBar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { UppyFile } from '@uppy/utils/lib/UppyFile'
1+
import type { UppyFile } from '@uppy/core'
22
import { h } from 'preact'
33

44
type $TSFixMe = any

packages/@uppy/drag-drop/src/DragDrop.tsx

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
import { UIPlugin, type Uppy } from '@uppy/core'
2-
import type { DefinePluginOpts } from '@uppy/core/lib/BasePlugin.js'
3-
import type { UIPluginOptions } from '@uppy/core/lib/UIPlugin.js'
4-
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
1+
import { UIPlugin } from '@uppy/core'
2+
import type {
3+
UIPluginOptions,
4+
Uppy,
5+
DefinePluginOpts,
6+
Body,
7+
Meta,
8+
} from '@uppy/core'
59
import type { TargetedEvent } from 'preact/compat'
610
import toArray from '@uppy/utils/lib/toArray'
711
import isDragDropSupported from '@uppy/utils/lib/isDragDropSupported'

packages/@uppy/drop-target/src/index.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
2-
import type { Uppy } from '@uppy/core/lib/Uppy.js'
3-
import type { DefinePluginOpts, PluginOpts } from '@uppy/core/lib/BasePlugin.js'
4-
import BasePlugin from '@uppy/core/lib/BasePlugin.js'
1+
import type { Uppy, Body, Meta, DefinePluginOpts, PluginOpts } from '@uppy/core'
2+
import { BasePlugin } from '@uppy/core'
53
import getDroppedFiles from '@uppy/utils/lib/getDroppedFiles'
64
import toArray from '@uppy/utils/lib/toArray'
75
// eslint-disable-next-line @typescript-eslint/ban-ts-comment

packages/@uppy/dropbox/src/Dropbox.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import { UIPlugin, Uppy } from '@uppy/core'
88
import { ProviderViews } from '@uppy/provider-views'
99
import { h, type ComponentChild } from 'preact'
1010

11-
import type { UppyFile, Body, Meta } from '@uppy/utils/lib/UppyFile'
1211
import type {
12+
UppyFile,
13+
Body,
14+
Meta,
1315
AsyncStore,
1416
UnknownProviderPlugin,
1517
UnknownProviderPluginState,
16-
} from '@uppy/core/lib/Uppy.js'
18+
} from '@uppy/core'
1719
import locale from './locale.js'
1820
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1921
// @ts-ignore We don't want TS to generate types for the package.json

packages/@uppy/facebook/src/Facebook.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ import { UIPlugin, Uppy } from '@uppy/core'
88
import { ProviderViews } from '@uppy/provider-views'
99
import { h, type ComponentChild } from 'preact'
1010

11-
import type { UppyFile, Body, Meta } from '@uppy/utils/lib/UppyFile'
1211
import type {
12+
UppyFile,
13+
Body,
14+
Meta,
1315
AsyncStore,
1416
UnknownProviderPlugin,
1517
UnknownProviderPluginState,
16-
} from '@uppy/core/lib/Uppy.js'
18+
} from '@uppy/core'
1719
import locale from './locale.js'
1820
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1921
// @ts-ignore We don't want TS to generate types for the package.json

packages/@uppy/file-input/src/FileInput.tsx

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { h, type ComponentChild } from 'preact'
22

3-
import { UIPlugin, Uppy, type UIPluginOptions } from '@uppy/core'
3+
import { UIPlugin } from '@uppy/core'
4+
import type {
5+
Uppy,
6+
UIPluginOptions,
7+
Body,
8+
Meta,
9+
DefinePluginOpts,
10+
} from '@uppy/core'
411
import toArray from '@uppy/utils/lib/toArray'
5-
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
6-
import type { DefinePluginOpts } from '@uppy/core/lib/BasePlugin.js'
712
import type { TargetedEvent } from 'preact/compat'
813
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
914
// @ts-ignore We don't want TS to generate types for the package.json

packages/@uppy/form/src/index.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
import BasePlugin, { type DefinePluginOpts } from '@uppy/core/lib/BasePlugin.js'
1+
import { BasePlugin } from '@uppy/core'
2+
import type {
3+
DefinePluginOpts,
4+
UIPluginOptions,
5+
Uppy,
6+
UppyEventMap,
7+
Body,
8+
Meta,
9+
} from '@uppy/core'
210
import findDOMElement from '@uppy/utils/lib/findDOMElement'
311
import toArray from '@uppy/utils/lib/toArray'
412

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

9-
import type { UIPluginOptions, Uppy, UppyEventMap } from '@uppy/core'
10-
import type { Body, Meta } from '@uppy/utils/lib/UppyFile'
1117
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
1218
// @ts-ignore We don't want TS to generate types for the package.json
1319
import packageJson from '../package.json'

packages/@uppy/golden-retriever/src/MetaDataStore.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { State as UppyState } from '@uppy/core'
2-
import type { Meta, Body } from '@uppy/utils/lib/UppyFile'
1+
import type { State as UppyState, Meta, Body } from '@uppy/core'
32

43
export type StoredState<M extends Meta, B extends Body> = {
54
expires: number

packages/@uppy/golden-retriever/src/index.ts

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import throttle from 'lodash/throttle.js'
2-
import BasePlugin from '@uppy/core/lib/BasePlugin.js'
3-
import type { PluginOpts, DefinePluginOpts } from '@uppy/core/lib/BasePlugin.js'
4-
import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile'
5-
import type Uppy from '@uppy/core'
6-
import type { UploadResult } from '@uppy/core'
2+
import { BasePlugin } from '@uppy/core'
3+
import type {
4+
Body,
5+
Meta,
6+
UppyFile,
7+
Uppy,
8+
UploadResult,
9+
PluginOpts,
10+
DefinePluginOpts,
11+
} from '@uppy/core'
712
import ServiceWorkerStore, {
813
type ServiceWorkerStoredFile,
914
} from './ServiceWorkerStore.js'

packages/@uppy/google-drive-picker/src/GoogleDrivePicker.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ import {
99
} from '@uppy/companion-client'
1010

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

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

0 commit comments

Comments
 (0)