Преглед на файлове

Resolve all type `TODO`'s (#2963)

Merlijn Vos преди 3 години
родител
ревизия
f01538ba41
променени са 75 файла, в които са добавени 385 реда и са изтрити 230 реда
  1. 1 2
      examples/aws-companion/server.js
  2. 1 1
      examples/aws-presigned-url/serve.js
  3. 1 1
      examples/custom-provider/client/MyCustomProvider.js
  4. 1 1
      examples/custom-provider/client/main.js
  5. 1 1
      examples/custom-provider/server/index.js
  6. 4 4
      examples/node-xhr/server.js
  7. 1 1
      examples/react-native-expo/App.js
  8. 1 1
      examples/react-native-expo/FileList.js
  9. 1 1
      examples/react-native-expo/ProgressBar.js
  10. 1 1
      examples/uppy-with-companion/server/index.js
  11. 4 4
      examples/xhr-bundle/serve.js
  12. 24 29
      packages/@uppy/aws-s3-multipart/src/MultipartUploader.js
  13. 2 2
      packages/@uppy/aws-s3/src/MiniXHRUpload.js
  14. 2 2
      packages/@uppy/aws-s3/src/index.js
  15. 1 1
      packages/@uppy/box/src/index.js
  16. 13 2
      packages/@uppy/box/types/index.test-d.ts
  17. 19 22
      packages/@uppy/companion-client/src/RequestClient.js
  18. 2 2
      packages/@uppy/dashboard/src/components/Dashboard.js
  19. 5 5
      packages/@uppy/dashboard/src/components/FileItem/index.js
  20. 2 2
      packages/@uppy/dashboard/src/components/FileList.js
  21. 2 2
      packages/@uppy/dashboard/src/components/FilePreview.js
  22. 2 2
      packages/@uppy/dashboard/src/components/PickerPanelTopBar.js
  23. 2 2
      packages/@uppy/dashboard/src/index.js
  24. 1 1
      packages/@uppy/dashboard/src/utils/ignoreEvent.js
  25. 1 1
      packages/@uppy/dashboard/src/utils/trapFocus.js
  26. 9 2
      packages/@uppy/drop-target/types/index.test-d.ts
  27. 1 1
      packages/@uppy/dropbox/src/index.js
  28. 13 2
      packages/@uppy/dropbox/types/index.test-d.ts
  29. 1 1
      packages/@uppy/facebook/src/index.js
  30. 13 2
      packages/@uppy/facebook/types/index.test-d.ts
  31. 2 2
      packages/@uppy/file-input/src/index.js
  32. 1 1
      packages/@uppy/golden-retriever/src/IndexedDBStore.js
  33. 2 2
      packages/@uppy/google-drive/src/index.js
  34. 2 2
      packages/@uppy/image-editor/src/index.js
  35. 1 1
      packages/@uppy/informer/src/index.js
  36. 1 1
      packages/@uppy/instagram/src/index.js
  37. 13 2
      packages/@uppy/instagram/types/index.test-d.ts
  38. 1 1
      packages/@uppy/onedrive/src/index.js
  39. 13 2
      packages/@uppy/onedrive/types/index.test-d.ts
  40. 1 1
      packages/@uppy/progress-bar/src/index.js
  41. 12 2
      packages/@uppy/progress-bar/types/index.test-d.ts
  42. 1 1
      packages/@uppy/provider-views/src/Browser.js
  43. 5 5
      packages/@uppy/provider-views/src/ProviderView/ProviderView.js
  44. 4 4
      packages/@uppy/provider-views/src/SearchProviderView/SearchProviderView.js
  45. 6 6
      packages/@uppy/react-native/file-picker/instagram.js
  46. 2 2
      packages/@uppy/react-native/file-picker/url.js
  47. 2 2
      packages/@uppy/react/src/FileInput.js
  48. 1 1
      packages/@uppy/redux-dev-tools/src/index.js
  49. 2 2
      packages/@uppy/screen-capture/src/index.js
  50. 3 4
      packages/@uppy/status-bar/src/StatusBar.js
  51. 40 2
      packages/@uppy/status-bar/types/index.test-d.ts
  52. 1 1
      packages/@uppy/store-redux/src/index.test.js
  53. 16 16
      packages/@uppy/thumbnail-generator/src/index.js
  54. 1 1
      packages/@uppy/thumbnail-generator/src/index.test.js
  55. 18 2
      packages/@uppy/thumbnail-generator/types/index.test-d.ts
  56. 1 1
      packages/@uppy/transloadit/src/Assembly.js
  57. 4 4
      packages/@uppy/transloadit/src/index.js
  58. 1 2
      packages/@uppy/transloadit/src/index.test.js
  59. 1 1
      packages/@uppy/unsplash/src/index.js
  60. 13 2
      packages/@uppy/unsplash/types/index.test-d.ts
  61. 1 1
      packages/@uppy/url/src/index.js
  62. 3 6
      packages/@uppy/url/src/utils/forEachDroppedOrPastedUrl.js
  63. 3 1
      packages/@uppy/url/types/index.d.ts
  64. 22 2
      packages/@uppy/url/types/index.test-d.ts
  65. 1 1
      packages/@uppy/utils/src/Translator.js
  66. 26 27
      packages/@uppy/utils/src/getDroppedFiles/utils/webkitGetAsEntryApi/index.js
  67. 3 3
      packages/@uppy/utils/src/getSocketHost.js
  68. 4 4
      packages/@uppy/utils/src/getTimeStamp.js
  69. 1 1
      packages/@uppy/vue/src/dashboard-modal.js
  70. 1 1
      packages/@uppy/vue/src/dashboard.js
  71. 1 1
      packages/@uppy/vue/src/drag-drop.js
  72. 1 1
      packages/@uppy/vue/src/progress-bar.js
  73. 1 1
      packages/@uppy/vue/src/status-bar.js
  74. 1 1
      packages/@uppy/zoom/src/index.js
  75. 13 2
      packages/@uppy/zoom/types/index.test-d.ts

+ 1 - 2
examples/aws-companion/server.js

@@ -22,8 +22,7 @@ const options = {
       secret: process.env.COMPANION_GOOGLE_SECRET,
     },
     s3: {
-      getKey: (req, filename) =>
-        `whatever/${Math.random().toString(32).slice(2)}/${filename}`,
+      getKey: (req, filename) => `whatever/${Math.random().toString(32).slice(2)}/${filename}`,
       key: process.env.COMPANION_AWS_KEY,
       secret: process.env.COMPANION_AWS_SECRET,
       bucket: process.env.COMPANION_AWS_BUCKET,

+ 1 - 1
examples/aws-presigned-url/serve.js

@@ -1,4 +1,4 @@
-const spawn = require('child_process').spawn
+const { spawn } = require('child_process')
 const path = require('path')
 const fs = require('fs')
 const createWriteStream = require('fs-write-stream-atomic')

+ 1 - 1
examples/custom-provider/client/MyCustomProvider.js

@@ -37,7 +37,7 @@ module.exports = class MyCustomProvider extends UIPlugin {
       provider: this.provider,
     })
 
-    const target = this.opts.target
+    const { target } = this.opts
     if (target) {
       this.mount(target, this)
     }

+ 1 - 1
examples/custom-provider/client/main.js

@@ -1,8 +1,8 @@
 const Uppy = require('@uppy/core')
 const GoogleDrive = require('@uppy/google-drive')
 const Tus = require('@uppy/tus')
-const MyCustomProvider = require('./MyCustomProvider')
 const Dashboard = require('@uppy/dashboard')
+const MyCustomProvider = require('./MyCustomProvider')
 
 const uppy = new Uppy({
   debug: true,

+ 1 - 1
examples/custom-provider/server/index.js

@@ -1,9 +1,9 @@
 const express = require('express')
 // the ../../../packages is just to use the local version
 // instead of the npm version—in a real app use `require('@uppy/companion')`
-const uppy = require('../../../packages/@uppy/companion')
 const bodyParser = require('body-parser')
 const session = require('express-session')
+const uppy = require('../../../packages/@uppy/companion')
 
 const app = express()
 

+ 4 - 4
examples/node-xhr/server.js

@@ -1,5 +1,5 @@
-var formidable = require('formidable')
-var http = require('http')
+const formidable = require('formidable')
+const http = require('http')
 
 http.createServer((req, res) => {
   const headers = {
@@ -17,7 +17,7 @@ http.createServer((req, res) => {
   }
   if (req.url === '/upload' && req.method.toLowerCase() === 'post') {
     // parse a file upload
-    var form = new formidable.IncomingForm()
+    const form = new formidable.IncomingForm()
     form.uploadDir = './uploads'
     form.keepExtensions = true
 
@@ -28,7 +28,7 @@ http.createServer((req, res) => {
         res.write(JSON.stringify(err))
         return res.end()
       }
-      var file = files['files[]']
+      const file = files['files[]']
       console.log('saved file to', file.path)
       console.log('original name', file.name)
       console.log('type', file.type)

+ 1 - 1
examples/react-native-expo/App.js

@@ -70,7 +70,7 @@ export default class App extends React.Component {
     })
 
     this.uppy.on('info-visible', () => {
-      const info = this.uppy.getState().info
+      const { info } = this.uppy.getState()
       this.setState({
         info,
       })

+ 1 - 1
examples/react-native-expo/FileList.js

@@ -31,7 +31,7 @@ function UppyDashboardFileIcon (props) {
   if (!icon) {
     return <FileIcon />
   }
-  const color = getFileTypeIcon(props.type).color
+  const { color } = getFileTypeIcon(props.type)
   return (
     <View
       style={{

+ 1 - 1
examples/react-native-expo/ProgressBar.js

@@ -2,7 +2,7 @@ import React from 'react' // eslint-disable-line no-unused-vars
 import { View, Text } from 'react-native'
 
 export default function ProgressBar (props) {
-  const progress = props.progress
+  const { progress } = props
 
   const colorGreen = '#0b8600'
   const colorBlue = '#006bb7'

+ 1 - 1
examples/uppy-with-companion/server/index.js

@@ -1,7 +1,7 @@
 const express = require('express')
-const companion = require('../../../packages/@uppy/companion')
 const bodyParser = require('body-parser')
 const session = require('express-session')
+const companion = require('../../../packages/@uppy/companion')
 
 const app = express()
 

+ 4 - 4
examples/xhr-bundle/serve.js

@@ -1,8 +1,8 @@
-var app = require('express')()
-var cors = require('cors')
-var multer = require('multer')
+const app = require('express')()
+const cors = require('cors')
+const multer = require('multer')
 
-var upload = multer({
+const upload = multer({
   storage: multer.memoryStorage(),
 })
 

+ 24 - 29
packages/@uppy/aws-s3-multipart/src/MultipartUploader.js

@@ -101,8 +101,7 @@ class MultipartUploader {
   }
 
   _createUpload () {
-    this.createdPromise = Promise.resolve().then(() =>
-      this.options.createMultipartUpload())
+    this.createdPromise = Promise.resolve().then(() => this.options.createMultipartUpload())
     return this.createdPromise.then((result) => {
       if (this._aborted()) throw createAbortError()
 
@@ -124,11 +123,10 @@ class MultipartUploader {
   }
 
   _resumeUpload () {
-    return Promise.resolve().then(() =>
-      this.options.listParts({
-        uploadId: this.uploadId,
-        key: this.key,
-      })).then((parts) => {
+    return Promise.resolve().then(() => this.options.listParts({
+      uploadId: this.uploadId,
+      key: this.key,
+    })).then((parts) => {
       if (this._aborted()) throw createAbortError()
 
       parts.forEach((part) => {
@@ -202,16 +200,15 @@ class MultipartUploader {
       return false
     }
 
-    const doAttempt = (retryAttempt) =>
-      attempt().catch((err) => {
-        if (this._aborted()) throw createAbortError()
+    const doAttempt = (retryAttempt) => attempt().catch((err) => {
+      if (this._aborted()) throw createAbortError()
 
-        if (shouldRetry(err) && retryAttempt < retryDelays.length) {
-          return delay(retryDelays[retryAttempt], { signal })
-            .then(() => doAttempt(retryAttempt + 1))
-        }
-        throw err
-      })
+      if (shouldRetry(err) && retryAttempt < retryDelays.length) {
+        return delay(retryDelays[retryAttempt], { signal })
+          .then(() => doAttempt(retryAttempt + 1))
+      }
+      throw err
+    })
 
     return doAttempt(0).then((result) => {
       if (after) after()
@@ -238,13 +235,12 @@ class MultipartUploader {
     const body = this.chunks[index]
     this.chunkState[index].busy = true
 
-    return Promise.resolve().then(() =>
-      this.options.prepareUploadPart({
-        key: this.key,
-        uploadId: this.uploadId,
-        body,
-        number: index + 1,
-      })).then((result) => {
+    return Promise.resolve().then(() => this.options.prepareUploadPart({
+      key: this.key,
+      uploadId: this.uploadId,
+      body,
+      number: index + 1,
+    })).then((result) => {
       const valid = typeof result === 'object' && result
         && typeof result.url === 'string'
       if (!valid) {
@@ -363,12 +359,11 @@ class MultipartUploader {
     // Parts may not have completed uploading in sorted order, if limit > 1.
     this.parts.sort((a, b) => a.PartNumber - b.PartNumber)
 
-    return Promise.resolve().then(() =>
-      this.options.completeMultipartUpload({
-        key: this.key,
-        uploadId: this.uploadId,
-        parts: this.parts,
-      })).then((result) => {
+    return Promise.resolve().then(() => this.options.completeMultipartUpload({
+      key: this.key,
+      uploadId: this.uploadId,
+      parts: this.parts,
+    })).then((result) => {
       this.options.onSuccess(result)
     }, (err) => {
       this._onError(err)

+ 2 - 2
packages/@uppy/aws-s3/src/MiniXHRUpload.js

@@ -50,7 +50,7 @@ module.exports = class MiniXHRUpload {
   }
 
   _getOptions (file) {
-    const uppy = this.uppy
+    const { uppy } = this
 
     const overrides = uppy.getState().xhrUpload
     const opts = {
@@ -295,7 +295,7 @@ module.exports = class MiniXHRUpload {
         useFormData: opts.formData,
         headers: opts.headers,
       }).then((res) => {
-        const token = res.token
+        const { token } = res
         const host = getSocketHost(file.remote.companionUrl)
         const socket = new Socket({ target: `${host}/api/${token}`, autoOpen: false })
         this.uploaderEvents[file.id] = new EventTracker(this.uppy)

+ 2 - 2
packages/@uppy/aws-s3/src/index.js

@@ -114,7 +114,7 @@ module.exports = class AwsS3 extends BasePlugin {
     }
 
     const filename = file.meta.name
-    const type = file.meta.type
+    const { type } = file.meta
     const metadata = {}
     this.opts.metaFields.forEach((key) => {
       if (file.meta[key] != null) {
@@ -220,7 +220,7 @@ module.exports = class AwsS3 extends BasePlugin {
   }
 
   install () {
-    const uppy = this.uppy
+    const { uppy } = this
     this.uppy.addUploader(this.handleUpload)
 
     // Get the response data from a successful XMLHttpRequest instance.

+ 1 - 1
packages/@uppy/box/src/index.js

@@ -41,7 +41,7 @@ module.exports = class Box extends UIPlugin {
       provider: this.provider,
     })
 
-    const target = this.opts.target
+    const { target } = this.opts
     if (target) {
       this.mount(target, this)
     }

+ 13 - 2
packages/@uppy/box/types/index.test-d.ts

@@ -1,2 +1,13 @@
-// import Box from '..'
-// TODO implement
+import Uppy from '@uppy/core'
+import Box from '..'
+
+{
+  const uppy = new Uppy()
+  uppy.use(Box, {
+    companionUrl: '',
+    companionCookiesRule: 'same-origin',
+    replaceTargetContent: false,
+    target: 'body',
+    title: 'title',
+  })
+}

+ 19 - 22
packages/@uppy/companion-client/src/RequestClient.js

@@ -1,7 +1,7 @@
 'use strict'
 
-const AuthError = require('./AuthError')
 const fetchWithNetworkError = require('@uppy/utils/lib/fetchWithNetworkError')
+const AuthError = require('./AuthError')
 
 // Remove the trailing slash so we can always safely append /xyz.
 function stripSlash (url) {
@@ -55,7 +55,7 @@ module.exports = class RequestClient {
     const state = this.uppy.getState()
     const companion = state.companion || {}
     const host = this.opts.companionUrl
-    const headers = response.headers
+    const { headers } = response
     // Store the self-identified domain name for the Companion instance we just hit.
     if (headers.has('i-am') && headers.get('i-am') !== companion[host]) {
       this.uppy.setState({
@@ -129,12 +129,11 @@ module.exports = class RequestClient {
 
   get (path, skipPostResponse) {
     return this.preflightAndHeaders(path)
-      .then((headers) =>
-        fetchWithNetworkError(this._getUrl(path), {
-          method: 'get',
-          headers,
-          credentials: this.opts.companionCookiesRule || 'same-origin',
-        }))
+      .then((headers) => fetchWithNetworkError(this._getUrl(path), {
+        method: 'get',
+        headers,
+        credentials: this.opts.companionCookiesRule || 'same-origin',
+      }))
       .then(this._getPostResponseFunc(skipPostResponse))
       .then((res) => this._json(res))
       .catch((err) => {
@@ -147,13 +146,12 @@ module.exports = class RequestClient {
 
   post (path, data, skipPostResponse) {
     return this.preflightAndHeaders(path)
-      .then((headers) =>
-        fetchWithNetworkError(this._getUrl(path), {
-          method: 'post',
-          headers,
-          credentials: this.opts.companionCookiesRule || 'same-origin',
-          body: JSON.stringify(data),
-        }))
+      .then((headers) => fetchWithNetworkError(this._getUrl(path), {
+        method: 'post',
+        headers,
+        credentials: this.opts.companionCookiesRule || 'same-origin',
+        body: JSON.stringify(data),
+      }))
       .then(this._getPostResponseFunc(skipPostResponse))
       .then((res) => this._json(res))
       .catch((err) => {
@@ -166,13 +164,12 @@ module.exports = class RequestClient {
 
   delete (path, data, skipPostResponse) {
     return this.preflightAndHeaders(path)
-      .then((headers) =>
-        fetchWithNetworkError(`${this.hostname}/${path}`, {
-          method: 'delete',
-          headers,
-          credentials: this.opts.companionCookiesRule || 'same-origin',
-          body: data ? JSON.stringify(data) : null,
-        }))
+      .then((headers) => fetchWithNetworkError(`${this.hostname}/${path}`, {
+        method: 'delete',
+        headers,
+        credentials: this.opts.companionCookiesRule || 'same-origin',
+        body: data ? JSON.stringify(data) : null,
+      }))
       .then(this._getPostResponseFunc(skipPostResponse))
       .then((res) => this._json(res))
       .catch((err) => {

+ 2 - 2
packages/@uppy/dashboard/src/components/Dashboard.js

@@ -1,5 +1,6 @@
 const { h } = require('preact')
 const classNames = require('classnames')
+const isDragDropSupported = require('@uppy/utils/lib/isDragDropSupported')
 const FileList = require('./FileList')
 const AddFiles = require('./AddFiles')
 const AddFilesPanel = require('./AddFilesPanel')
@@ -8,7 +9,6 @@ const EditorPanel = require('./EditorPanel')
 const PanelTopBar = require('./PickerPanelTopBar')
 const FileCard = require('./FileCard')
 const Slide = require('./Slide')
-const isDragDropSupported = require('@uppy/utils/lib/isDragDropSupported')
 
 // http://dev.edenspiekermann.com/2016/02/11/introducing-accessible-modal-dialog
 // https://github.com/ghosh/micromodal
@@ -127,7 +127,7 @@ module.exports = function Dashboard (props) {
               <strong className="uppy-Dashboard-serviceMsg-title">
                 {props.i18n('sessionRestored')}
               </strong>
-              <div class="uppy-Dashboard-serviceMsg-text">
+              <div className="uppy-Dashboard-serviceMsg-text">
                 {renderRestoredText()}
               </div>
             </div>

+ 5 - 5
packages/@uppy/dashboard/src/components/FileItem/index.js

@@ -12,7 +12,7 @@ module.exports = class FileItem extends Component {
   }
 
   componentDidMount () {
-    const file = this.props.file
+    const { file } = this.props
     if (!file.preview) {
       this.props.handleRequestThumbnail(file)
     }
@@ -21,21 +21,21 @@ module.exports = class FileItem extends Component {
   // VirtualList mounts FileItems again and they emit `thumbnail:request`
   // Otherwise thumbnails are broken or missing after Golden Retriever restores files
   componentDidUpdate () {
-    const file = this.props.file
+    const { file } = this.props
     if (!file.preview) {
       this.props.handleRequestThumbnail(file)
     }
   }
 
   componentWillUnmount () {
-    const file = this.props.file
+    const { file } = this.props
     if (!file.preview) {
       this.props.handleCancelThumbnail(file)
     }
   }
 
   render () {
-    const file = this.props.file
+    const { file } = this.props
 
     const isProcessing = file.progress.preprocess || file.progress.postprocess
     const isUploaded = file.progress.uploadComplete && !isProcessing && !file.error
@@ -45,7 +45,7 @@ module.exports = class FileItem extends Component {
 
     // File that Golden Retriever was able to partly restore (only meta, not blob),
     // users still need to re-add it, so it’s a ghost
-    const isGhost = file.isGhost
+    const { isGhost } = file
 
     let showRemoveButton = this.props.individualCancellation
       ? !isUploaded

+ 2 - 2
packages/@uppy/dashboard/src/components/FileList.js

@@ -1,7 +1,7 @@
-const FileItem = require('./FileItem/index.js')
-const VirtualList = require('./VirtualList')
 const classNames = require('classnames')
 const { h } = require('preact')
+const FileItem = require('./FileItem/index.js')
+const VirtualList = require('./VirtualList')
 
 function chunks (list, size) {
   const chunked = []

+ 2 - 2
packages/@uppy/dashboard/src/components/FilePreview.js

@@ -1,8 +1,8 @@
-const getFileTypeIcon = require('../utils/getFileTypeIcon')
 const { h } = require('preact')
+const getFileTypeIcon = require('../utils/getFileTypeIcon')
 
 module.exports = function FilePreview (props) {
-  const file = props.file
+  const { file } = props
 
   if (file.preview) {
     return (

+ 2 - 2
packages/@uppy/dashboard/src/components/PickerPanelTopBar.js

@@ -26,7 +26,7 @@ function getUploadingState (isAllErrored, isAllComplete, isAllPaused, files = {}
   let state = uploadStates.STATE_WAITING
   const fileIDs = Object.keys(files)
   for (let i = 0; i < fileIDs.length; i++) {
-    const progress = files[fileIDs[i]].progress
+    const { progress } = files[fileIDs[i]]
     // If ANY files are being uploaded right now, show the uploading state.
     if (progress.uploadStarted && !progress.uploadComplete) {
       return uploadStates.STATE_UPLOADING
@@ -69,7 +69,7 @@ function UploadStatus (props) {
 }
 
 function PanelTopBar (props) {
-  let allowNewUpload = props.allowNewUpload
+  let { allowNewUpload } = props
   // TODO maybe this should be done in ../index.js, then just pass that down as `allowNewUpload`
   if (allowNewUpload && props.maxNumberOfFiles) {
     allowNewUpload = props.totalFileCount < props.maxNumberOfFiles

+ 2 - 2
packages/@uppy/dashboard/src/index.js

@@ -1,7 +1,6 @@
 const { h } = require('preact')
 const { UIPlugin } = require('@uppy/core')
 const Translator = require('@uppy/utils/lib/Translator')
-const DashboardUI = require('./components/Dashboard')
 const StatusBar = require('@uppy/status-bar')
 const Informer = require('@uppy/informer')
 const ThumbnailGenerator = require('@uppy/thumbnail-generator')
@@ -9,11 +8,12 @@ const findAllDOMElements = require('@uppy/utils/lib/findAllDOMElements')
 const toArray = require('@uppy/utils/lib/toArray')
 const getDroppedFiles = require('@uppy/utils/lib/getDroppedFiles')
 const getTextDirection = require('@uppy/utils/lib/getTextDirection')
-const trapFocus = require('./utils/trapFocus')
 const cuid = require('cuid')
+const trapFocus = require('./utils/trapFocus')
 const createSuperFocus = require('./utils/createSuperFocus')
 const memoize = require('memoize-one').default || require('memoize-one')
 const FOCUSABLE_ELEMENTS = require('@uppy/utils/lib/FOCUSABLE_ELEMENTS')
+const DashboardUI = require('./components/Dashboard')
 
 const TAB_KEY = 9
 const ESC_KEY = 27

+ 1 - 1
packages/@uppy/dashboard/src/utils/ignoreEvent.js

@@ -4,7 +4,7 @@
 // Url treats them as URLs that need to be imported
 
 function ignoreEvent (ev) {
-  const tagName = ev.target.tagName
+  const { tagName } = ev.target
   if (tagName === 'INPUT'
       || tagName === 'TEXTAREA') {
     ev.stopPropagation()

+ 1 - 1
packages/@uppy/dashboard/src/utils/trapFocus.js

@@ -1,6 +1,6 @@
 const toArray = require('@uppy/utils/lib/toArray')
-const getActiveOverlayEl = require('./getActiveOverlayEl')
 const FOCUSABLE_ELEMENTS = require('@uppy/utils/lib/FOCUSABLE_ELEMENTS')
+const getActiveOverlayEl = require('./getActiveOverlayEl')
 
 function focusOnFirstNode (event, nodes) {
   const node = nodes[0]

+ 9 - 2
packages/@uppy/drop-target/types/index.test-d.ts

@@ -1,2 +1,9 @@
-// import DropTarget from '..'
-// TODO implement
+import Uppy from '@uppy/core'
+import DropTarget from '..'
+
+{
+  const uppy = new Uppy()
+  uppy.use(DropTarget, {
+    target: 'body',
+  })
+}

+ 1 - 1
packages/@uppy/dropbox/src/index.js

@@ -38,7 +38,7 @@ module.exports = class Dropbox extends UIPlugin {
       provider: this.provider,
     })
 
-    const target = this.opts.target
+    const { target } = this.opts
     if (target) {
       this.mount(target, this)
     }

+ 13 - 2
packages/@uppy/dropbox/types/index.test-d.ts

@@ -1,2 +1,13 @@
-// import Dropbox from '..'
-// TODO implement
+import Uppy from '@uppy/core'
+import Dropbox from '..'
+
+{
+  const uppy = new Uppy()
+  uppy.use(Dropbox, {
+    companionUrl: '',
+    companionCookiesRule: 'same-origin',
+    replaceTargetContent: false,
+    target: 'body',
+    title: 'title',
+  })
+}

+ 1 - 1
packages/@uppy/facebook/src/index.js

@@ -38,7 +38,7 @@ module.exports = class Facebook extends UIPlugin {
       provider: this.provider,
     })
 
-    const target = this.opts.target
+    const { target } = this.opts
     if (target) {
       this.mount(target, this)
     }

+ 13 - 2
packages/@uppy/facebook/types/index.test-d.ts

@@ -1,2 +1,13 @@
-// import Facebook from '..'
-// TODO implement
+import Uppy from '@uppy/core'
+import Facebook from '..'
+
+{
+  const uppy = new Uppy()
+  uppy.use(Facebook, {
+    companionUrl: '',
+    companionCookiesRule: 'same-origin',
+    replaceTargetContent: false,
+    target: 'body',
+    title: 'title',
+  })
+}

+ 2 - 2
packages/@uppy/file-input/src/index.js

@@ -94,7 +94,7 @@ module.exports = class FileInput extends UIPlugin {
       zIndex: -1,
     }
 
-    const restrictions = this.uppy.opts.restrictions
+    const { restrictions } = this.uppy.opts
     const accept = restrictions.allowedFileTypes ? restrictions.allowedFileTypes.join(',') : null
 
     return (
@@ -124,7 +124,7 @@ module.exports = class FileInput extends UIPlugin {
   }
 
   install () {
-    const target = this.opts.target
+    const { target } = this.opts
     if (target) {
       this.mount(target, this)
     }

+ 1 - 1
packages/@uppy/golden-retriever/src/IndexedDBStore.js

@@ -29,7 +29,7 @@ function connect (dbName) {
   return new Promise((resolve, reject) => {
     request.onupgradeneeded = (event) => {
       const db = event.target.result
-      const transaction = event.currentTarget.transaction
+      const { transaction } = event.currentTarget
 
       if (event.oldVersion < 2) {
         // Added in v2: DB structure changed to a single shared object store

+ 2 - 2
packages/@uppy/google-drive/src/index.js

@@ -1,7 +1,7 @@
 const { UIPlugin } = require('@uppy/core')
 const { Provider } = require('@uppy/companion-client')
-const DriveProviderViews = require('./DriveProviderViews')
 const { h } = require('preact')
+const DriveProviderViews = require('./DriveProviderViews')
 
 module.exports = class GoogleDrive extends UIPlugin {
   static VERSION = require('../package.json').version
@@ -39,7 +39,7 @@ module.exports = class GoogleDrive extends UIPlugin {
       provider: this.provider,
     })
 
-    const target = this.opts.target
+    const { target } = this.opts
     if (target) {
       this.mount(target, this)
     }

+ 2 - 2
packages/@uppy/image-editor/src/index.js

@@ -1,7 +1,7 @@
 const { UIPlugin } = require('@uppy/core')
-const Editor = require('./Editor')
 const Translator = require('@uppy/utils/lib/Translator')
 const { h } = require('preact')
+const Editor = require('./Editor')
 
 module.exports = class ImageEditor extends UIPlugin {
   static VERSION = require('../package.json').version
@@ -120,7 +120,7 @@ module.exports = class ImageEditor extends UIPlugin {
       currentImage: null,
     })
 
-    const target = this.opts.target
+    const { target } = this.opts
     if (target) {
       this.mount(target, this)
     }

+ 1 - 1
packages/@uppy/informer/src/index.js

@@ -66,7 +66,7 @@ module.exports = class Informer extends UIPlugin {
   }
 
   install () {
-    const target = this.opts.target
+    const { target } = this.opts
     if (target) {
       this.mount(target, this)
     }

+ 1 - 1
packages/@uppy/instagram/src/index.js

@@ -42,7 +42,7 @@ module.exports = class Instagram extends UIPlugin {
       showBreadcrumbs: false,
     })
 
-    const target = this.opts.target
+    const { target } = this.opts
     if (target) {
       this.mount(target, this)
     }

+ 13 - 2
packages/@uppy/instagram/types/index.test-d.ts

@@ -1,2 +1,13 @@
-// import Instagram from '..'
-// TODO implement
+import Uppy from '@uppy/core'
+import Instagram from '..'
+
+{
+  const uppy = new Uppy()
+  uppy.use(Instagram, {
+    companionUrl: '',
+    companionCookiesRule: 'same-origin',
+    replaceTargetContent: false,
+    target: 'body',
+    title: 'title',
+  })
+}

+ 1 - 1
packages/@uppy/onedrive/src/index.js

@@ -40,7 +40,7 @@ module.exports = class OneDrive extends UIPlugin {
       provider: this.provider,
     })
 
-    const target = this.opts.target
+    const { target } = this.opts
     if (target) {
       this.mount(target, this)
     }

+ 13 - 2
packages/@uppy/onedrive/types/index.test-d.ts

@@ -1,2 +1,13 @@
-// import OneDrive from '..'
-// TODO implement
+import Uppy from '@uppy/core'
+import OneDrive from '..'
+
+{
+  const uppy = new Uppy()
+  uppy.use(OneDrive, {
+    companionUrl: '',
+    companionCookiesRule: 'same-origin',
+    replaceTargetContent: false,
+    target: 'body',
+    title: 'title',
+  })
+}

+ 1 - 1
packages/@uppy/progress-bar/src/index.js

@@ -45,7 +45,7 @@ module.exports = class ProgressBar extends UIPlugin {
   }
 
   install () {
-    const target = this.opts.target
+    const { target } = this.opts
     if (target) {
       this.mount(target, this)
     }

+ 12 - 2
packages/@uppy/progress-bar/types/index.test-d.ts

@@ -1,2 +1,12 @@
-// import ProgressBar from '..'
-// TODO implement
+import Uppy from '@uppy/core'
+import ProgressBar from '..'
+
+{
+  const uppy = new Uppy()
+  uppy.use(ProgressBar, {
+    replaceTargetContent: true,
+    target: 'body',
+    hideAfterFinish: true,
+    fixed: true,
+  })
+}

+ 1 - 1
packages/@uppy/provider-views/src/Browser.js

@@ -1,8 +1,8 @@
 const classNames = require('classnames')
+const { h } = require('preact')
 const Filter = require('./Filter')
 const ItemList = require('./ItemList')
 const FooterActions = require('./FooterActions')
-const { h } = require('preact')
 
 const Browser = (props) => {
   const {

+ 5 - 5
packages/@uppy/provider-views/src/ProviderView/ProviderView.js

@@ -1,12 +1,12 @@
 const { h } = require('preact')
-const AuthView = require('./AuthView')
-const Header = require('./Header')
-const Browser = require('../Browser')
-const LoaderView = require('../Loader')
 const generateFileID = require('@uppy/utils/lib/generateFileID')
 const getFileType = require('@uppy/utils/lib/getFileType')
 const findIndex = require('@uppy/utils/lib/findIndex')
 const isPreviewSupported = require('@uppy/utils/lib/isPreviewSupported')
+const AuthView = require('./AuthView')
+const Header = require('./Header')
+const Browser = require('../Browser')
+const LoaderView = require('../Loader')
 const SharedHandler = require('../SharedHandler')
 const CloseWrapper = require('../CloseWrapper')
 
@@ -393,7 +393,7 @@ module.exports = class ProviderView {
   }
 
   handleError (error) {
-    const uppy = this.plugin.uppy
+    const { uppy } = this.plugin
     uppy.log(error.toString())
     if (error.isAuthError) {
       return

+ 4 - 4
packages/@uppy/provider-views/src/SearchProviderView/SearchProviderView.js

@@ -1,10 +1,10 @@
 const { h } = require('preact')
-const SearchInput = require('./InputView')
-const Browser = require('../Browser')
-const LoaderView = require('../Loader')
 const generateFileID = require('@uppy/utils/lib/generateFileID')
 const getFileType = require('@uppy/utils/lib/getFileType')
 const isPreviewSupported = require('@uppy/utils/lib/isPreviewSupported')
+const SearchInput = require('./InputView')
+const Browser = require('../Browser')
+const LoaderView = require('../Loader')
 const Header = require('./Header')
 const SharedHandler = require('../SharedHandler')
 const CloseWrapper = require('../CloseWrapper')
@@ -149,7 +149,7 @@ module.exports = class ProviderView {
   }
 
   handleError (error) {
-    const uppy = this.plugin.uppy
+    const { uppy } = this.plugin
     uppy.log(error.toString())
     const message = uppy.i18n('companionError')
     uppy.info({ message, details: error.toString() }, 'error', 5000)

+ 6 - 6
packages/@uppy/react-native/file-picker/instagram.js

@@ -10,9 +10,9 @@ import Instagram from '@uppy/instagram'
 
 function getQueryParamValueFromUrl (name, url) {
   name = name.replace(/[[]/, '\\[').replace(/[\]]/, '\\]')
-  var regexS = `[\\?&]${name}=([^&#]*)`
-  var regex = new RegExp(regexS)
-  var results = regex.exec(url)
+  const regexS = `[\\?&]${name}=([^&#]*)`
+  const regex = new RegExp(regexS)
+  const results = regex.exec(url)
   return results == null ? null : results[1]
 }
 
@@ -40,7 +40,7 @@ export default class UppyRNInstagram extends React.Component {
   }
 
   componentDidMount () {
-    const uppy = this.props.uppy
+    const { uppy } = this.props
     const options = {
       id: 'uppyRN:Instagram',
       ...this.props,
@@ -56,7 +56,7 @@ export default class UppyRNInstagram extends React.Component {
   }
 
   componentWillUnmount () {
-    const uppy = this.props.uppy
+    const { uppy } = this.props
     uppy.removePlugin(this.plugin)
   }
 
@@ -84,7 +84,7 @@ export default class UppyRNInstagram extends React.Component {
         source={{ uri: this.state.authUrl }}
         style={{ marginTop: 20 }}
         onNavigationStateChange={(ev) => {
-          const url = ev.url
+          const { url } = ev
           const token = getQueryParamValueFromUrl('uppyAuthToken', url)
           console.log(token)
           this.plugin.provider.setAuthToken(token)

+ 2 - 2
packages/@uppy/react-native/file-picker/url.js

@@ -21,7 +21,7 @@ export default class UppyRNUrl extends React.Component {
   }
 
   componentDidMount () {
-    const uppy = this.props.uppy
+    const { uppy } = this.props
     const options = {
       id: 'uppyRN:Url',
       ...this.props,
@@ -34,7 +34,7 @@ export default class UppyRNUrl extends React.Component {
   }
 
   componentWillUnmount () {
-    const uppy = this.props.uppy
+    const { uppy } = this.props
     uppy.removePlugin(this.plugin)
   }
 

+ 2 - 2
packages/@uppy/react/src/FileInput.js

@@ -27,7 +27,7 @@ class FileInput extends React.Component {
   }
 
   installPlugin () {
-    const uppy = this.props.uppy
+    const { uppy } = this.props
     const options = {
       id: 'react:FileInput',
       ...this.props,
@@ -41,7 +41,7 @@ class FileInput extends React.Component {
   }
 
   uninstallPlugin (props = this.props) {
-    const uppy = props.uppy
+    const { uppy } = props
 
     uppy.removePlugin(this.plugin)
   }

+ 1 - 1
packages/@uppy/redux-dev-tools/src/index.js

@@ -39,7 +39,7 @@ module.exports = class ReduxDevTools extends UIPlugin {
             this.uppy.reset()
             return
           case 'IMPORT_STATE': {
-            const computedStates = message.payload.nextLiftedState.computedStates
+            const { computedStates } = message.payload.nextLiftedState
             this.uppy.store.state = { ...this.uppy.getState(), ...computedStates[computedStates.length - 1].state }
             this.uppy.updateAll(this.uppy.getState())
             return

+ 2 - 2
packages/@uppy/screen-capture/src/index.js

@@ -99,7 +99,7 @@ module.exports = class ScreenCapture extends UIPlugin {
       audioStreamActive: false,
     })
 
-    const target = this.opts.target
+    const { target } = this.opts
     if (target) {
       this.mount(target, this)
     }
@@ -205,7 +205,7 @@ module.exports = class ScreenCapture extends UIPlugin {
     const options = {}
     this.capturedMediaFile = null
     this.recordingChunks = []
-    const preferredVideoMimeType = this.opts.preferredVideoMimeType
+    const { preferredVideoMimeType } = this.opts
 
     this.selectVideoStreamSource()
       .then((videoStream) => {

+ 3 - 4
packages/@uppy/status-bar/src/StatusBar.js

@@ -1,9 +1,9 @@
 const throttle = require('lodash.throttle')
 const classNames = require('classnames')
-const statusBarStates = require('./StatusBarStates')
 const prettierBytes = require('@transloadit/prettier-bytes')
 const prettyETA = require('@uppy/utils/lib/prettyETA')
 const { h } = require('preact')
+const statusBarStates = require('./StatusBarStates')
 
 function calculateProcessingProgress (files) {
   // Collect pre or postprocessing progress states.
@@ -77,7 +77,7 @@ module.exports = (props) => {
     recoveredState,
   } = props
 
-  const uploadState = props.uploadState
+  const { uploadState } = props
 
   let progressValue = props.totalProgress
   let progressMode
@@ -292,8 +292,7 @@ const ProgressBarProcessing = (props) => {
   )
 }
 
-const renderDot = () =>
-  ' \u00B7 '
+const renderDot = () => ' \u00B7 '
 
 const ProgressDetails = (props) => {
   const ifShowFilesUploadedOfTotal = props.numUploads > 1

+ 40 - 2
packages/@uppy/status-bar/types/index.test-d.ts

@@ -1,2 +1,40 @@
-// import StatusBar from '..'
-// TODO implement
+import Uppy from '@uppy/core'
+import StatusBar from '..'
+
+{
+  const uppy = new Uppy()
+  uppy.use(StatusBar, {
+    replaceTargetContent: false,
+    target: 'body',
+    showProgressDetails: true,
+    hideUploadButton: false,
+    hideAfterFinish: false,
+    hideRetryButton: false,
+    hidePauseResumeButton: false,
+    hideCancelButton: false,
+    doneButtonHandler: () => {
+      // something
+    },
+    locale: {
+      strings: {
+        uploading: '',
+        upload: '',
+        complete: '',
+        uploadFailed: '',
+        paused: '',
+        retry: '',
+        retryUpload: '',
+        cancel: '',
+        pause: '',
+        resume: '',
+        done: '',
+        filesUploadedOfTotal: '',
+        dataUploadedOfTotal: '',
+        xTimeLeft: '',
+        uploadXFiles: '',
+        uploadXNewFiles: '',
+        xMoreFilesAdded: '',
+      },
+    },
+  })
+}

+ 1 - 1
packages/@uppy/store-redux/src/index.test.js

@@ -1,5 +1,5 @@
-const ReduxStore = require('./index')
 const Redux = require('redux')
+const ReduxStore = require('./index')
 
 describe('ReduxStore', () => {
   function createStore (reducers = {}) {

+ 16 - 16
packages/@uppy/thumbnail-generator/src/index.js

@@ -100,7 +100,7 @@ module.exports = class ThumbnailGenerator extends UIPlugin {
    * is used.
    */
   getProportionalDimensions (img, width, height, rotation) {
-    var aspect = img.width / img.height
+    let aspect = img.width / img.height
     if (rotation === 90 || rotation === 270) {
       aspect = img.height / img.width
     }
@@ -132,13 +132,13 @@ module.exports = class ThumbnailGenerator extends UIPlugin {
   protect (image) {
     // https://stackoverflow.com/questions/6081483/maximum-size-of-a-canvas-element
 
-    var ratio = image.width / image.height
+    const ratio = image.width / image.height
 
-    var maxSquare = 5000000 // ios max canvas square
-    var maxSize = 4096 // ie max canvas dimensions
+    const maxSquare = 5000000 // ios max canvas square
+    const maxSize = 4096 // ie max canvas dimensions
 
-    var maxW = Math.floor(Math.sqrt(maxSquare * ratio))
-    var maxH = Math.floor(maxSquare / Math.sqrt(maxSquare * ratio))
+    let maxW = Math.floor(Math.sqrt(maxSquare * ratio))
+    let maxH = Math.floor(maxSquare / Math.sqrt(maxSquare * ratio))
     if (maxW > maxSize) {
       maxW = maxSize
       maxH = Math.round(maxW / ratio)
@@ -148,7 +148,7 @@ module.exports = class ThumbnailGenerator extends UIPlugin {
       maxW = Math.round(ratio * maxH)
     }
     if (image.width > maxW) {
-      var canvas = document.createElement('canvas')
+      const canvas = document.createElement('canvas')
       canvas.width = maxW
       canvas.height = maxH
       canvas.getContext('2d').drawImage(image, 0, 0, maxW, maxH)
@@ -169,16 +169,16 @@ module.exports = class ThumbnailGenerator extends UIPlugin {
 
     image = this.protect(image)
 
-    var steps = Math.ceil(Math.log2(image.width / targetWidth))
+    let steps = Math.ceil(Math.log2(image.width / targetWidth))
     if (steps < 1) {
       steps = 1
     }
-    var sW = targetWidth * Math.pow(2, steps - 1)
-    var sH = targetHeight * Math.pow(2, steps - 1)
-    var x = 2
+    let sW = targetWidth * Math.pow(2, steps - 1)
+    let sH = targetHeight * Math.pow(2, steps - 1)
+    const x = 2
 
     while (steps--) {
-      var canvas = document.createElement('canvas')
+      const canvas = document.createElement('canvas')
       canvas.width = sW
       canvas.height = sH
       canvas.getContext('2d').drawImage(image, 0, 0, sW, sH)
@@ -192,19 +192,19 @@ module.exports = class ThumbnailGenerator extends UIPlugin {
   }
 
   rotateImage (image, translate) {
-    var w = image.width
-    var h = image.height
+    let w = image.width
+    let h = image.height
 
     if (translate.deg === 90 || translate.deg === 270) {
       w = image.height
       h = image.width
     }
 
-    var canvas = document.createElement('canvas')
+    const canvas = document.createElement('canvas')
     canvas.width = w
     canvas.height = h
 
-    var context = canvas.getContext('2d')
+    const context = canvas.getContext('2d')
     context.translate(w / 2, h / 2)
     if (translate.canvas) {
       context.rotate(translate.rad)

+ 1 - 1
packages/@uppy/thumbnail-generator/src/index.test.js

@@ -1,6 +1,6 @@
-const ThumbnailGeneratorPlugin = require('./index')
 const { UIPlugin } = require('@uppy/core')
 const emitter = require('namespace-emitter')
+const ThumbnailGeneratorPlugin = require('./index')
 
 const delay = duration => new Promise(resolve => setTimeout(resolve, duration))
 

+ 18 - 2
packages/@uppy/thumbnail-generator/types/index.test-d.ts

@@ -1,2 +1,18 @@
-// import ThumbnailGenerator from '..'
-// TODO implement
+import Uppy from '@uppy/core'
+import ThumbnailGenerator from '..'
+
+{
+  const uppy = new Uppy()
+  uppy.use(ThumbnailGenerator, {
+    thumbnailWidth: 100,
+    thumbnailHeight: 100,
+    thumbnailType: 'type',
+    waitForThumbnailsBeforeUpload: true,
+    lazy: true,
+    locale: {
+      strings: {
+        generatingThumbnails: '',
+      },
+    },
+  })
+}

+ 1 - 1
packages/@uppy/transloadit/src/Assembly.js

@@ -1,9 +1,9 @@
 const io = requireSocketIo
 const Emitter = require('component-emitter')
 const has = require('@uppy/utils/lib/hasProperty')
-const parseUrl = require('./parseUrl')
 const NetworkError = require('@uppy/utils/lib/NetworkError')
 const fetchWithNetworkError = require('@uppy/utils/lib/fetchWithNetworkError')
+const parseUrl = require('./parseUrl')
 
 // Lazy load socket.io to avoid a console error
 // in IE 10 when the Transloadit plugin is not used.

+ 4 - 4
packages/@uppy/transloadit/src/index.js

@@ -163,7 +163,7 @@ module.exports = class Transloadit extends BasePlugin {
     // remote, because this is the criteria to identify remote files.
     // We only replace the hostname for Transloadit's companions, so that
     // people can also self-host them while still using Transloadit for encoding.
-    let remote = file.remote
+    let { remote } = file
 
     if (file.remote && TL_COMPANION.test(file.remote.companionUrl)) {
       const newHost = status.companion_url
@@ -203,7 +203,7 @@ module.exports = class Transloadit extends BasePlugin {
       signature: options.signature,
     }).then((newAssembly) => {
       const assembly = new Assembly(newAssembly)
-      const status = assembly.status
+      const { status } = assembly
       const assemblyID = status.assembly_id
 
       const { assemblies, uploadsAssemblies } = this.getPluginState()
@@ -427,8 +427,8 @@ module.exports = class Transloadit extends BasePlugin {
    */
   _getPersistentData (setData) {
     const state = this.getPluginState()
-    const assemblies = state.assemblies
-    const uploadsAssemblies = state.uploadsAssemblies
+    const { assemblies } = state
+    const { uploadsAssemblies } = state
 
     setData({
       [this.id]: {

+ 1 - 2
packages/@uppy/transloadit/src/index.test.js

@@ -64,8 +64,7 @@ describe('Transloadit', () => {
       },
     })
 
-    uppy.getPlugin('Transloadit').client.createAssembly = () =>
-      Promise.reject(new Error('VIDEO_ENCODE_VALIDATION'))
+    uppy.getPlugin('Transloadit').client.createAssembly = () => Promise.reject(new Error('VIDEO_ENCODE_VALIDATION'))
 
     uppy.addFile({
       source: 'jest',

+ 1 - 1
packages/@uppy/unsplash/src/index.js

@@ -45,7 +45,7 @@ module.exports = class Unsplash extends UIPlugin {
       provider: this.provider,
     })
 
-    const target = this.opts.target
+    const { target } = this.opts
     if (target) {
       this.mount(target, this)
     }

+ 13 - 2
packages/@uppy/unsplash/types/index.test-d.ts

@@ -1,2 +1,13 @@
-// import Unsplash from '../'
-// TODO implement
+import Uppy from '@uppy/core'
+import Unsplash from '..'
+
+{
+  const uppy = new Uppy()
+  uppy.use(Unsplash, {
+    companionUrl: '',
+    companionCookiesRule: 'same-origin',
+    replaceTargetContent: false,
+    target: 'body',
+    title: 'title',
+  })
+}

+ 1 - 1
packages/@uppy/url/src/index.js

@@ -187,7 +187,7 @@ module.exports = class Url extends UIPlugin {
   }
 
   install () {
-    const target = this.opts.target
+    const { target } = this.opts
     if (target) {
       this.mount(target, this)
     }

+ 3 - 6
packages/@uppy/url/src/utils/forEachDroppedOrPastedUrl.js

@@ -67,15 +67,13 @@ module.exports = function forEachDroppedOrPastedUrl (dataTransfer, isDropOrPaste
       if (atLeastOneFileIsDragged) {
         return
       }
-      urlItems = items.filter((item) =>
-        item.kind === 'string'
+      urlItems = items.filter((item) => item.kind === 'string'
           && item.type === 'text/plain')
 
       break
     }
     case 'drop': {
-      urlItems = items.filter((item) =>
-        item.kind === 'string'
+      urlItems = items.filter((item) => item.kind === 'string'
         && item.type === 'text/uri-list')
       break
     }
@@ -85,7 +83,6 @@ module.exports = function forEachDroppedOrPastedUrl (dataTransfer, isDropOrPaste
   }
 
   urlItems.forEach((item) => {
-    item.getAsString((urlString) =>
-      callback(urlString))
+    item.getAsString((urlString) => callback(urlString))
   })
 }

+ 3 - 1
packages/@uppy/url/types/index.d.ts

@@ -9,6 +9,8 @@ export interface UrlOptions extends PluginOptions, RequestClientOptions {
     locale?: UrlLocale
 }
 
-declare class Url extends UIPlugin<UrlOptions> {}
+declare class Url extends UIPlugin<UrlOptions> {
+  public addFile(url: string): undefined | string | never
+}
 
 export default Url

+ 22 - 2
packages/@uppy/url/types/index.test-d.ts

@@ -1,2 +1,22 @@
-// import Url from '../'
-// TODO implement
+import Uppy from '@uppy/core'
+import Url from '..'
+
+{
+  const uppy = new Uppy()
+  uppy.use(Url, {
+    companionUrl: '',
+    companionCookiesRule: 'same-origin',
+    replaceTargetContent: false,
+    target: 'body',
+    title: 'title',
+    locale: {
+      strings: {
+        import: '',
+        enterUrlToImport: '',
+        failedToFetch: '',
+        enterCorrectUrl: '',
+      },
+    },
+  })
+    .getPlugin<Url>('Url').addFile('https://via.placeholder.com/150')
+}

+ 1 - 1
packages/@uppy/utils/src/Translator.js

@@ -64,7 +64,7 @@ module.exports = class Translator {
         // Ensure replacement value is escaped to prevent special $-prefixed
         // regex replace tokens. the "$$$$" is needed because each "$" needs to
         // be escaped with "$" itself, and we need two in the resulting output.
-        var replacement = options[arg]
+        let replacement = options[arg]
         if (typeof replacement === 'string') {
           replacement = dollarRegex[Symbol.replace](replacement, dollarBillsYall)
         }

+ 26 - 27
packages/@uppy/utils/src/getDroppedFiles/utils/webkitGetAsEntryApi/index.js

@@ -13,34 +13,33 @@ module.exports = function webkitGetAsEntryApi (dataTransfer, logDropError) {
    * @param {(FileSystemFileEntry|FileSystemDirectoryEntry)} entry
    * @returns {Promise} - empty promise that resolves when :files is enhanced with a file
    */
-  const createPromiseToAddFileOrParseDirectory = (entry) =>
-    new Promise((resolve) => {
-      // This is a base call
-      if (entry.isFile) {
-        // Creates a new File object which can be used to read the file.
-        entry.file(
-          (file) => {
-            file.relativePath = getRelativePath(entry)
-            files.push(file)
-            resolve()
-          },
-          // Make sure we resolve on error anyway, it's fine if only one file couldn't be read!
-          (error) => {
-            logDropError(error)
-            resolve()
-          }
-        )
+  const createPromiseToAddFileOrParseDirectory = (entry) => new Promise((resolve) => {
+    // This is a base call
+    if (entry.isFile) {
+      // Creates a new File object which can be used to read the file.
+      entry.file(
+        (file) => {
+          file.relativePath = getRelativePath(entry)
+          files.push(file)
+          resolve()
+        },
+        // Make sure we resolve on error anyway, it's fine if only one file couldn't be read!
+        (error) => {
+          logDropError(error)
+          resolve()
+        }
+      )
       // This is a recursive call
-      } else if (entry.isDirectory) {
-        const directoryReader = entry.createReader()
-        getFilesAndDirectoriesFromDirectory(directoryReader, [], logDropError, {
-          onSuccess: (entries) => {
-            const promises = entries.map((entry) => createPromiseToAddFileOrParseDirectory(entry))
-            Promise.all(promises).then(() => resolve())
-          },
-        })
-      }
-    })
+    } else if (entry.isDirectory) {
+      const directoryReader = entry.createReader()
+      getFilesAndDirectoriesFromDirectory(directoryReader, [], logDropError, {
+        onSuccess: (entries) => {
+          const promises = entries.map((entry) => createPromiseToAddFileOrParseDirectory(entry))
+          Promise.all(promises).then(() => resolve())
+        },
+      })
+    }
+  })
 
   // For each dropped item, - make sure it's a file/directory, and start deepening in!
   toArray(dataTransfer.items)

+ 3 - 3
packages/@uppy/utils/src/getSocketHost.js

@@ -1,8 +1,8 @@
 module.exports = function getSocketHost (url) {
   // get the host domain
-  var regex = /^(?:https?:\/\/|\/\/)?(?:[^@\n]+@)?(?:www\.)?([^\n]+)/i
-  var host = regex.exec(url)[1]
-  var socketProtocol = /^http:\/\//i.test(url) ? 'ws' : 'wss'
+  const regex = /^(?:https?:\/\/|\/\/)?(?:[^@\n]+@)?(?:www\.)?([^\n]+)/i
+  const host = regex.exec(url)[1]
+  const socketProtocol = /^http:\/\//i.test(url) ? 'ws' : 'wss'
 
   return `${socketProtocol}://${host}`
 }

+ 4 - 4
packages/@uppy/utils/src/getTimeStamp.js

@@ -2,10 +2,10 @@
  * Returns a timestamp in the format of `hours:minutes:seconds`
  */
 module.exports = function getTimeStamp () {
-  var date = new Date()
-  var hours = pad(date.getHours().toString())
-  var minutes = pad(date.getMinutes().toString())
-  var seconds = pad(date.getSeconds().toString())
+  const date = new Date()
+  const hours = pad(date.getHours().toString())
+  const minutes = pad(date.getMinutes().toString())
+  const seconds = pad(date.getSeconds().toString())
   return `${hours}:${minutes}:${seconds}`
 }
 

+ 1 - 1
packages/@uppy/vue/src/dashboard-modal.js

@@ -30,7 +30,7 @@ export default {
   },
   methods: {
     installPlugin () {
-      const uppy = this.uppy
+      const { uppy } = this
       const options = {
         id: 'vue:DashboardModal',
         plugins: this.plugins,

+ 1 - 1
packages/@uppy/vue/src/dashboard.js

@@ -27,7 +27,7 @@ export default {
   },
   methods: {
     installPlugin () {
-      const uppy = this.uppy
+      const { uppy } = this
       const options = {
         id: 'vue:Dashboard',
         inline: true,

+ 1 - 1
packages/@uppy/vue/src/drag-drop.js

@@ -24,7 +24,7 @@ export default {
   },
   methods: {
     installPlugin () {
-      const uppy = this.uppy
+      const { uppy } = this
       const options = {
         id: 'vue:DragDrop',
         ...this.props,

+ 1 - 1
packages/@uppy/vue/src/progress-bar.js

@@ -24,7 +24,7 @@ export default {
   },
   methods: {
     installPlugin () {
-      const uppy = this.uppy
+      const { uppy } = this
       const options = {
         id: 'vue:ProgressBar',
         ...this.props,

+ 1 - 1
packages/@uppy/vue/src/status-bar.js

@@ -24,7 +24,7 @@ export default {
   },
   methods: {
     installPlugin () {
-      const uppy = this.uppy
+      const { uppy } = this
       const options = {
         id: 'vue:StatusBar',
         ...this.props,

+ 1 - 1
packages/@uppy/zoom/src/index.js

@@ -39,7 +39,7 @@ module.exports = class Zoom extends UIPlugin {
       provider: this.provider,
     })
 
-    const target = this.opts.target
+    const { target } = this.opts
     if (target) {
       this.mount(target, this)
     }

+ 13 - 2
packages/@uppy/zoom/types/index.test-d.ts

@@ -1,2 +1,13 @@
-// import Zoom from '../'
-// TODO implement
+import Uppy from '@uppy/core'
+import Zoom from '..'
+
+{
+  const uppy = new Uppy()
+  uppy.use(Zoom, {
+    companionUrl: '',
+    companionCookiesRule: 'same-origin',
+    replaceTargetContent: false,
+    target: 'body',
+    title: 'title',
+  })
+}