diff --git a/babel.config.js b/babel.config.js index 476f6bd12..3a11f2344 100644 --- a/babel.config.js +++ b/babel.config.js @@ -8,15 +8,15 @@ module.exports = (api) => { presets: [ ['@babel/preset-env', { modules: false, - loose: true, - targets - }] + loose : true, + targets, + }], ], plugins: [ ['@babel/plugin-proposal-class-properties', { loose: true }], '@babel/plugin-transform-object-assign', ['@babel/plugin-transform-react-jsx', { pragma: 'h' }], - process.env.IS_RELEASE_BUILD && 'babel-plugin-inline-package-json' - ].filter(Boolean) + process.env.IS_RELEASE_BUILD && 'babel-plugin-inline-package-json', + ].filter(Boolean), } } diff --git a/bin/after-version-bump.js b/bin/after-version-bump.js index 17c862b37..768cc9a8a 100755 --- a/bin/after-version-bump.js +++ b/bin/after-version-bump.js @@ -16,6 +16,7 @@ const { promisify } = require('util') const once = require('events.once') const globby = require('globby') const fs = require('fs') + const readFile = promisify(fs.readFile) const writeFile = promisify(fs.writeFile) @@ -36,7 +37,7 @@ async function updateVersions (files, packageName) { const urlPart = packageName === 'uppy' ? packageName : packageName.slice(1) const replacements = new Map([ - [RegExp(`${urlPart}/v\\d+\\.\\d+\\.\\d+\\/`, 'g'), `${urlPart}/v${version}/`] + [RegExp(`${urlPart}/v\\d+\\.\\d+\\.\\d+\\/`, 'g'), `${urlPart}/v${version}/`], // maybe more later ]) @@ -59,11 +60,11 @@ async function gitAdd (files) { async function npmRunBuild () { const npmRun = spawn('npm', ['run', 'build'], { stdio: 'inherit', - env: { + env : { ...process.env, - FRESH: true, // force rebuild everything - IS_RELEASE_BUILD: true - } + FRESH : true, // force rebuild everything + IS_RELEASE_BUILD: true, + }, }) const [exitCode] = await once(npmRun, 'exit') if (exitCode !== 0) { @@ -91,7 +92,7 @@ async function main () { 'website/src/docs/**', 'website/src/examples/**', 'website/themes/uppy/layout/**', - '!**/node_modules/**' + '!**/node_modules/**', ]) await updateVersions(files, 'uppy') @@ -106,7 +107,7 @@ async function main () { await npmRunBuild() } -main().catch(function (err) { +main().catch((err) => { console.error(err.stack) process.exit(1) }) diff --git a/bin/build-bundle.js b/bin/build-bundle.js index c6f0978cf..f3de4a3b1 100644 --- a/bin/build-bundle.js +++ b/bin/build-bundle.js @@ -20,12 +20,12 @@ function buildBundle (srcFile, bundleFile, { minify = false, standalone = '' } = b.transform(babelify) b.on('error', handleErr) - return new Promise(function (resolve, reject) { + return new Promise((resolve, reject) => { b.bundle() - .pipe(exorcist(bundleFile + '.map')) + .pipe(exorcist(`${bundleFile}.map`)) .pipe(fs.createWriteStream(bundleFile), 'utf8') .on('error', handleErr) - .on('finish', function () { + .on('finish', () => { if (minify) { console.info(chalk.green(`✓ Built Minified Bundle [${standalone}]:`), chalk.magenta(bundleFile)) } else { @@ -44,23 +44,23 @@ const methods = [ buildBundle( './packages/uppy/bundle.js', './packages/uppy/dist/uppy.js', - { standalone: 'Uppy' } + { standalone: 'Uppy' }, ), buildBundle( './packages/uppy/bundle.js', './packages/uppy/dist/uppy.min.js', - { standalone: 'Uppy', minify: true } + { standalone: 'Uppy', minify: true }, ), buildBundle( './packages/@uppy/robodog/bundle.js', './packages/@uppy/robodog/dist/robodog.js', - { standalone: 'Robodog' } + { standalone: 'Robodog' }, ), buildBundle( './packages/@uppy/robodog/bundle.js', './packages/@uppy/robodog/dist/robodog.min.js', - { standalone: 'Robodog', minify: true } - ) + { standalone: 'Robodog', minify: true }, + ), ] // Build minified versions of all the locales @@ -71,11 +71,11 @@ glob.sync(localePackagePath).forEach((localePath) => { buildBundle( `./packages/@uppy/locales/src/${localeName}.js`, `./packages/@uppy/locales/dist/${localeName}.min.js`, - { minify: true } - ) + { minify: true }, + ), ) }) -Promise.all(methods).then(function () { +Promise.all(methods).then(() => { console.info(chalk.yellow('✓ JS bundles 🎉')) }) diff --git a/bin/build-css.js b/bin/build-css.js index 4dc88cff2..a1ba4d658 100644 --- a/bin/build-css.js +++ b/bin/build-css.js @@ -30,9 +30,9 @@ async function compileCSS () { file, importer (url, from, done) { resolve(url, { - basedir: path.dirname(from), - filename: from, - extensions: ['.scss'] + basedir : path.dirname(from), + filename : from, + extensions: ['.scss'], }, (err, res) => { if (err) return done(err) @@ -43,17 +43,17 @@ async function compileCSS () { done({ file: res }) }) - } + }, }) const plugins = [ autoprefixer, postcssLogical(), - postcssDirPseudoClass() + postcssDirPseudoClass(), ] const postcssResult = await postcss(plugins) .process(scssResult.css, { from: file }) - postcssResult.warnings().forEach(function (warn) { + postcssResult.warnings().forEach((warn) => { console.warn(warn.toString()) }) @@ -72,19 +72,19 @@ async function compileCSS () { await writeFile(outfile, postcssResult.css) console.info( chalk.green('✓ Built Uppy CSS:'), - chalk.magenta(path.relative(cwd, outfile)) + chalk.magenta(path.relative(cwd, outfile)), ) const minifiedResult = await postcss([ - cssnano({ safe: true }) + cssnano({ safe: true }), ]).process(postcssResult.css, { from: outfile }) - minifiedResult.warnings().forEach(function (warn) { + minifiedResult.warnings().forEach((warn) => { console.warn(warn.toString()) }) await writeFile(outfile.replace(/\.css$/, '.min.css'), minifiedResult.css) console.info( chalk.green('✓ Minified Bundle CSS:'), - chalk.magenta(path.relative(cwd, outfile).replace(/\.css$/, '.min.css')) + chalk.magenta(path.relative(cwd, outfile).replace(/\.css$/, '.min.css')), ) } } diff --git a/bin/build-lib.js b/bin/build-lib.js index 7db4872b1..4941be4bc 100644 --- a/bin/build-lib.js +++ b/bin/build-lib.js @@ -18,7 +18,7 @@ const META_FILES = [ 'babel.config.js', 'package.json', 'package-lock.json', - 'bin/build-lib.js' + 'bin/build-lib.js', ] function lastModified (file) { @@ -27,8 +27,7 @@ function lastModified (file) { async function buildLib () { const metaMtimes = await Promise.all(META_FILES.map((filename) => - lastModified(path.join(__dirname, '..', filename)) - )) + lastModified(path.join(__dirname, '..', filename)))) const metaMtime = Math.max(...metaMtimes) const files = await glob(SOURCE) @@ -51,13 +50,14 @@ async function buildLib () { await mkdirp(path.dirname(libFile)) await Promise.all([ writeFile(libFile, code), - writeFile(libFile + '.map', JSON.stringify(map)) + writeFile(`${libFile}.map`, JSON.stringify(map)), ]) console.log(chalk.green('Compiled lib:'), chalk.magenta(libFile)) } } console.log('Using Babel version:', require('@babel/core/package.json').version) + buildLib().catch((err) => { console.error(err.stack) process.exit(1) diff --git a/bin/check-npm-version.js b/bin/check-npm-version.js index 944d23a9a..e23fb003a 100644 --- a/bin/check-npm-version.js +++ b/bin/check-npm-version.js @@ -1,5 +1,4 @@ #!/usr/bin/env node -'use strict' const userAgent = process.env.npm_config_user_agent if (!userAgent) { diff --git a/bin/disc.js b/bin/disc.js index b4fea787f..748e391b6 100644 --- a/bin/disc.js +++ b/bin/disc.js @@ -13,16 +13,16 @@ function minifyify (filename) { if (filename.endsWith('.js')) { return minify({ sourceMap: false, - toplevel: true, - compress: { unsafe: true } + toplevel : true, + compress : { unsafe: true }, }) } return new PassThrough() } const bundler = browserify(path.join(__dirname, '../packages/uppy/index.js'), { - fullPaths: true, - standalone: 'Uppy' + fullPaths : true, + standalone: 'Uppy', }) bundler.transform(babelify) diff --git a/bin/locale-packs.js b/bin/locale-packs.js index e6259f069..e75163f63 100644 --- a/bin/locale-packs.js +++ b/bin/locale-packs.js @@ -4,6 +4,7 @@ const chalk = require('chalk') const path = require('path') const stringifyObject = require('stringify-object') const fs = require('fs') + const uppy = new Uppy() let localePack = {} const plugins = {} @@ -23,13 +24,11 @@ if (mode === 'build') { function getSources (pluginName) { const dependencies = { // because 'provider-views' doesn't have its own locale, it uses Core's defaultLocale - core: ['provider-views'] + core: ['provider-views'], } const globPath = path.join(__dirname, '..', 'packages', '@uppy', pluginName, 'lib', '**', '*.js') - let contents = glob.sync(globPath).map((file) => { - return fs.readFileSync(file, 'utf-8') - }) + let contents = glob.sync(globPath).map((file) => fs.readFileSync(file, 'utf-8')) if (dependencies[pluginName]) { dependencies[pluginName].forEach((addPlugin) => { @@ -52,10 +51,10 @@ function buildPluginsList () { for (const file of files) { const dirName = path.dirname(file) const pluginName = path.basename(dirName) - if (pluginName === 'locales' || - pluginName === 'react-native' || - pluginName === 'vue' || - pluginName === 'svelte') { + if (pluginName === 'locales' + || pluginName === 'react-native' + || pluginName === 'vue' + || pluginName === 'svelte') { continue } const Plugin = require(dirName) @@ -68,37 +67,35 @@ function buildPluginsList () { global.location = { protocol: 'https' } global.navigator = { userAgent: '' } global.localStorage = { - key: () => { }, - getItem: () => { } + key : () => { }, + getItem: () => { }, } global.window = { indexedDB: { - open: () => { return {} } - } + open: () => ({}), + }, } global.document = { - createElement: () => { - return { style: {} } - } + createElement: () => ({ style: {} }), } try { if (pluginName === 'provider-views') { plugin = new Plugin(plugins['drag-drop'], { companionPattern: '', - companionUrl: 'https://companion.uppy.io' + companionUrl : 'https://companion.uppy.io', }) } else if (pluginName === 'store-redux') { plugin = new Plugin({ store: { dispatch: () => { } } }) } else { plugin = new Plugin(uppy, { companionPattern: '', - companionUrl: 'https://companion.uppy.io', - params: { + companionUrl : 'https://companion.uppy.io', + params : { auth: { - key: 'x' - } - } + key: 'x', + }, + }, }) } } catch (err) { @@ -150,7 +147,7 @@ function checkForUnused (fileContents, pluginName, localePack) { } function sortObjectAlphabetically (obj, sortFunc) { - return Object.keys(obj).sort(sortFunc).reduce(function (result, key) { + return Object.keys(obj).sort(sortFunc).reduce((result, key) => { result[key] = obj[key] return result }, {}) @@ -158,20 +155,19 @@ function sortObjectAlphabetically (obj, sortFunc) { function createTypeScriptLocale (plugin, pluginName) { const allowedStringTypes = Object.keys(plugin.defaultLocale.strings) - .map(key => ` | '${key}'`) + .map((key) => ` | '${key}'`) .join('\n') const pluginClassName = pluginName === 'core' ? 'Core' : plugin.id const localePath = path.join(__dirname, '..', 'packages', '@uppy', pluginName, 'types', 'generatedLocale.d.ts') - const localeTypes = - 'import Uppy = require(\'@uppy/core\')\n' + - '\n' + - `type ${pluginClassName}Locale = Uppy.Locale` + '<\n' + - allowedStringTypes + '\n' + - '>\n' + - '\n' + - `export = ${pluginClassName}Locale\n` + const localeTypes = `${'import Uppy = require(\'@uppy/core\')\n' + + '\n' + + `type ${pluginClassName}Locale = Uppy.Locale` + '<\n'}${ + allowedStringTypes}\n` + + '>\n' + + '\n' + + `export = ${pluginClassName}Locale\n` fs.writeFileSync(localePath, localeTypes) } @@ -194,15 +190,15 @@ function build () { } const prettyLocale = stringifyObject(localePack, { - indent: ' ', - singleQuotes: true, - inlineCharacterLimit: 12 + indent : ' ', + singleQuotes : true, + inlineCharacterLimit: 12, }) const localeTemplatePath = path.join(__dirname, '..', 'packages', '@uppy', 'locales', 'template.js') const template = fs.readFileSync(localeTemplatePath, 'utf-8') - const finalLocale = template.replace('en_US.strings = {}', 'en_US.strings = ' + prettyLocale) + const finalLocale = template.replace('en_US.strings = {}', `en_US.strings = ${prettyLocale}`) const localePackagePath = path.join(__dirname, '..', 'packages', '@uppy', 'locales', 'src', 'en_US.js') fs.writeFileSync(localePackagePath, finalLocale, 'utf-8') diff --git a/bin/run-example.js b/bin/run-example.js index 32baa1390..7da917f2a 100644 --- a/bin/run-example.js +++ b/bin/run-example.js @@ -13,6 +13,7 @@ const path = require('path') const { execSync } = require('child_process') + const exampleName = process.argv[2] if (!exampleName) { diff --git a/bin/update-contributors.js b/bin/update-contributors.js index 31dc68564..ff4fa86ef 100644 --- a/bin/update-contributors.js +++ b/bin/update-contributors.js @@ -11,7 +11,7 @@ async function updateContributorsListInReadme () { '--cols', '6', '--format', 'md', '--showlogin', 'true', - '--sortOrder', 'desc' + '--sortOrder', 'desc', ] if (process.env.GITHUB_TOKEN) { @@ -27,7 +27,7 @@ async function updateContributorsListInReadme () { const readmeWithUpdatedContributors = readme.replace( /[\s\S]+/, - `\n${stdout}\n` + `\n${stdout}\n`, ) fs.writeFileSync(README_FILE_NAME, readmeWithUpdatedContributors) } diff --git a/bin/upload-to-cdn.js b/bin/upload-to-cdn.js index 87a71e380..f9123ac4b 100644 --- a/bin/upload-to-cdn.js +++ b/bin/upload-to-cdn.js @@ -33,7 +33,7 @@ const finished = promisify(require('stream').finished) const AdmZip = require('adm-zip') function delay (ms) { - return new Promise(resolve => setTimeout(resolve, ms)) + return new Promise((resolve) => setTimeout(resolve, ms)) } const AWS_REGION = 'us-east-1' @@ -79,14 +79,14 @@ async function getRemoteDistFiles (packageName, version) { */ async function getLocalDistFiles (packagePath) { const files = (await packlist({ path: packagePath })) - .filter(f => f.startsWith('dist/')) - .map(f => f.replace(/^dist\//, '')) + .filter((f) => f.startsWith('dist/')) + .map((f) => f.replace(/^dist\//, '')) const entries = await Promise.all( files.map(async (f) => [ f, - await readFile(path.join(packagePath, 'dist', f)) - ]) + await readFile(path.join(packagePath, 'dist', f)), + ]), ) return new Map(entries) @@ -111,10 +111,10 @@ async function main (packageName, version) { const s3 = new AWS.S3({ credentials: new AWS.Credentials({ - accessKeyId: process.env.EDGLY_KEY, - secretAccessKey: process.env.EDGLY_SECRET + accessKeyId : process.env.EDGLY_KEY, + secretAccessKey: process.env.EDGLY_SECRET, }), - region: AWS_REGION + region: AWS_REGION, }) const remote = !!version @@ -145,7 +145,7 @@ async function main (packageName, version) { const { Contents: existing } = await s3.listObjects({ Bucket: AWS_BUCKET, - Prefix: outputPath + Prefix: outputPath, }).promise() if (existing.length > 0) { if (process.argv.includes('--force')) { @@ -174,10 +174,10 @@ async function main (packageName, version) { const key = path.posix.join(outputPath, filename) console.log(`pushing s3://${AWS_BUCKET}/${key}`) await s3.putObject({ - Bucket: AWS_BUCKET, - Key: key, + Bucket : AWS_BUCKET, + Key : key, ContentType: mime.lookup(filename), - Body: buffer + Body : buffer, }).promise() } } diff --git a/examples/aws-companion/main.js b/examples/aws-companion/main.js index ba3586ac2..d16bab58e 100644 --- a/examples/aws-companion/main.js +++ b/examples/aws-companion/main.js @@ -5,19 +5,19 @@ const Dashboard = require('@uppy/dashboard') const AwsS3 = require('@uppy/aws-s3') const uppy = new Uppy({ - debug: true, - autoProceed: false + debug : true, + autoProceed: false, }) uppy.use(GoogleDrive, { - companionUrl: 'http://localhost:3020' + companionUrl: 'http://localhost:3020', }) uppy.use(Webcam) uppy.use(Dashboard, { - inline: true, - target: 'body', - plugins: ['GoogleDrive', 'Webcam'] + inline : true, + target : 'body', + plugins: ['GoogleDrive', 'Webcam'], }) uppy.use(AwsS3, { - companionUrl: 'http://localhost:3020' + companionUrl: 'http://localhost:3020', }) diff --git a/examples/aws-companion/server.js b/examples/aws-companion/server.js index 6620e31f5..cdff40692 100644 --- a/examples/aws-companion/server.js +++ b/examples/aws-companion/server.js @@ -7,35 +7,35 @@ const app = require('express')() const DATA_DIR = path.join(__dirname, 'tmp') app.use(require('cors')({ - origin: true, - credentials: true + origin : true, + credentials: true, })) app.use(require('cookie-parser')()) app.use(require('body-parser').json()) app.use(require('express-session')({ - secret: 'hello planet' + secret: 'hello planet', })) const options = { providerOptions: { drive: { - key: process.env.COMPANION_GOOGLE_KEY, - secret: process.env.COMPANION_GOOGLE_SECRET + key : process.env.COMPANION_GOOGLE_KEY, + secret: process.env.COMPANION_GOOGLE_SECRET, }, s3: { 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, - region: process.env.COMPANION_AWS_REGION, - endpoint: process.env.COMPANION_AWS_ENDPOINT - } + key : process.env.COMPANION_AWS_KEY, + secret : process.env.COMPANION_AWS_SECRET, + bucket : process.env.COMPANION_AWS_BUCKET, + region : process.env.COMPANION_AWS_REGION, + endpoint: process.env.COMPANION_AWS_ENDPOINT, + }, }, - server: { host: 'localhost:3020' }, + server : { host: 'localhost:3020' }, filePath: DATA_DIR, - secret: 'blah blah', - debug: true + secret : 'blah blah', + debug : true, } // Create the data directory here for the sake of the example. @@ -44,7 +44,7 @@ try { } catch (err) { fs.mkdirSync(DATA_DIR) } -process.on('exit', function () { +process.on('exit', () => { rimraf.sync(DATA_DIR) }) diff --git a/examples/aws-presigned-url/main.js b/examples/aws-presigned-url/main.js index 406dec4af..664afdb04 100644 --- a/examples/aws-presigned-url/main.js +++ b/examples/aws-presigned-url/main.js @@ -3,38 +3,36 @@ const Dashboard = require('@uppy/dashboard') const AwsS3 = require('@uppy/aws-s3') const uppy = new Uppy({ - debug: true + debug: true, }) uppy.use(Dashboard, { inline: true, - target: 'body' + target: 'body', }) uppy.use(AwsS3, { getUploadParameters (file) { // Send a request to our PHP signing endpoint. return fetch('/s3-sign.php', { - method: 'post', + method : 'post', // Send and receive JSON. headers: { - accept: 'application/json', - 'content-type': 'application/json' + accept : 'application/json', + 'content-type': 'application/json', }, body: JSON.stringify({ - filename: file.name, - contentType: file.type - }) - }).then((response) => { + filename : file.name, + contentType: file.type, + }), + }).then((response) => // Parse the JSON response. - return response.json() - }).then((data) => { + response.json()).then((data) => // Return an object in the correct shape. - return { - method: data.method, - url: data.url, - fields: data.fields, - headers: data.headers - } - }) - } + ({ + method : data.method, + url : data.url, + fields : data.fields, + headers: data.headers, + })) + }, }) diff --git a/examples/aws-presigned-url/serve.js b/examples/aws-presigned-url/serve.js index d0fc76ee7..e885f5a5b 100644 --- a/examples/aws-presigned-url/serve.js +++ b/examples/aws-presigned-url/serve.js @@ -10,10 +10,10 @@ const babelify = require('babelify') const port = process.env.PORT || 8080 const b = browserify({ - cache: {}, + cache : {}, packageCache: {}, - debug: true, - entries: path.join(__dirname, './main.js') + debug : true, + entries : path.join(__dirname, './main.js'), }) b.plugin(watchify) @@ -21,8 +21,8 @@ b.plugin(watchify) b.transform(babelify) b.transform(aliasify, { aliases: { - '@uppy': path.join(__dirname, '../../packages/@uppy') - } + '@uppy': path.join(__dirname, '../../packages/@uppy'), + }, }) function bundle () { @@ -43,6 +43,6 @@ console.log('bundling...') bundle().on('finish', () => { // Start the PHP delevopment server. spawn('php', ['-S', `localhost:${port}`], { - stdio: 'inherit' + stdio: 'inherit', }) }) diff --git a/examples/bundled/index.js b/examples/bundled/index.js index 294e42914..3ef9c7095 100644 --- a/examples/bundled/index.js +++ b/examples/bundled/index.js @@ -15,23 +15,23 @@ const TUS_ENDPOINT = 'https://tusd.tusdemo.net/files/' const uppy = new Uppy({ debug: true, - meta: { + meta : { username: 'John', - license: 'Creative Commons' - } + license : 'Creative Commons', + }, }) .use(Dashboard, { - trigger: '#pick-files', - target: '#upload-form', - inline: true, + trigger : '#pick-files', + target : '#upload-form', + inline : true, replaceTargetContent: true, - metaFields: [ + metaFields : [ { id: 'license', name: 'License', placeholder: 'specify license' }, - { id: 'caption', name: 'Caption', placeholder: 'add caption' } + { id: 'caption', name: 'Caption', placeholder: 'add caption' }, ], - showProgressDetails: true, + showProgressDetails : true, proudlyDisplayPoweredByUppy: true, - note: '2 files, images and video only' + note : '2 files, images and video only', }) .use(GoogleDrive, { target: Dashboard, companionUrl: 'http://localhost:3020' }) .use(Instagram, { target: Dashboard, companionUrl: 'http://localhost:3020' }) diff --git a/examples/bundled/sw.js b/examples/bundled/sw.js index e7d9d13b2..916592422 100644 --- a/examples/bundled/sw.js +++ b/examples/bundled/sw.js @@ -44,9 +44,9 @@ function removeFile (store, fileID) { function getFiles (store) { sendMessageToAllClients({ - type: 'uppy/ALL_FILES', - store: store, - files: getCache(store) + type : 'uppy/ALL_FILES', + store, + files: getCache(store), }) } diff --git a/examples/custom-provider/babel.config.js b/examples/custom-provider/babel.config.js index 58a80f20c..8c72df160 100644 --- a/examples/custom-provider/babel.config.js +++ b/examples/custom-provider/babel.config.js @@ -4,11 +4,11 @@ module.exports = (api) => { presets: [ ['@babel/preset-env', { modules: false, - loose: true - }] + loose : true, + }], ], plugins: [ - ['@babel/plugin-transform-react-jsx', { pragma: 'h' }] - ].filter(Boolean) + ['@babel/plugin-transform-react-jsx', { pragma: 'h' }], + ].filter(Boolean), } } diff --git a/examples/custom-provider/client/MyCustomProvider.js b/examples/custom-provider/client/MyCustomProvider.js index d92412355..b0cf776c9 100644 --- a/examples/custom-provider/client/MyCustomProvider.js +++ b/examples/custom-provider/client/MyCustomProvider.js @@ -18,10 +18,10 @@ module.exports = class MyCustomProvider extends Plugin { ) this.provider = new Provider(uppy, { - companionUrl: this.opts.companionUrl, + companionUrl : this.opts.companionUrl, companionHeaders: this.opts.companionHeaders || this.opts.serverHeaders, - provider: 'myunsplash', - pluginId: this.id + provider : 'myunsplash', + pluginId : this.id, }) this.files = [] @@ -29,12 +29,12 @@ module.exports = class MyCustomProvider extends Plugin { this.render = this.render.bind(this) // merge default options with the ones set by user - this.opts = Object.assign({}, opts) + this.opts = { ...opts } } install () { this.view = new ProviderViews(this, { - provider: this.provider + provider: this.provider, }) const target = this.opts.target diff --git a/examples/custom-provider/client/main.js b/examples/custom-provider/client/main.js index 6f553b222..1fc91a5b4 100644 --- a/examples/custom-provider/client/main.js +++ b/examples/custom-provider/client/main.js @@ -5,21 +5,21 @@ const MyCustomProvider = require('./MyCustomProvider') const Dashboard = require('@uppy/dashboard') const uppy = new Uppy({ - debug: true + debug: true, }) uppy.use(GoogleDrive, { - companionUrl: 'http://localhost:3020' + companionUrl: 'http://localhost:3020', }) uppy.use(MyCustomProvider, { - companionUrl: 'http://localhost:3020' + companionUrl: 'http://localhost:3020', }) uppy.use(Dashboard, { - inline: true, - target: 'body', - plugins: ['GoogleDrive', 'MyCustomProvider'] + inline : true, + target : 'body', + plugins: ['GoogleDrive', 'MyCustomProvider'], }) uppy.use(Tus, { endpoint: 'https://tusd.tusdemo.net/files/' }) diff --git a/examples/custom-provider/server/customprovider.js b/examples/custom-provider/server/customprovider.js index 04c9e3e12..73f4a3cdd 100644 --- a/examples/custom-provider/server/customprovider.js +++ b/examples/custom-provider/server/customprovider.js @@ -1,4 +1,5 @@ const request = require('request') + const BASE_URL = 'https://api.unsplash.com' /** @@ -12,12 +13,12 @@ class MyCustomProvider { list ({ token, directory }, done) { const path = directory ? `/${directory}/photos` : '' const options = { - url: `${BASE_URL}/collections${path}`, - method: 'GET', - json: true, + url : `${BASE_URL}/collections${path}`, + method : 'GET', + json : true, headers: { - Authorization: `Bearer ${token}` - } + Authorization: `Bearer ${token}`, + }, } request(options, (err, resp, body) => { @@ -33,12 +34,12 @@ class MyCustomProvider { download ({ id, token }, onData) { const options = { - url: `${BASE_URL}/photos/${id}`, - method: 'GET', - json: true, + url : `${BASE_URL}/photos/${id}`, + method : 'GET', + json : true, headers: { - Authorization: `Bearer ${token}` - } + Authorization: `Bearer ${token}`, + }, } request(options, (err, resp, body) => { @@ -57,12 +58,12 @@ class MyCustomProvider { size ({ id, token }, done) { const options = { - url: `${BASE_URL}/photos/${id}`, - method: 'GET', - json: true, + url : `${BASE_URL}/photos/${id}`, + method : 'GET', + json : true, headers: { - Authorization: `Bearer ${token}` - } + Authorization: `Bearer ${token}`, + }, } request(options, (err, resp, body) => { @@ -78,24 +79,24 @@ class MyCustomProvider { _adaptData (res) { const data = { - username: null, - items: [], - nextPagePath: null + username : null, + items : [], + nextPagePath: null, } const items = res items.forEach((item) => { const isFolder = !!item.published_at data.items.push({ - isFolder: isFolder, - icon: isFolder ? item.cover_photo.urls.thumb : item.urls.thumb, - name: item.title || item.description, - mimeType: isFolder ? null : 'image/jpeg', - id: item.id, - thumbnail: isFolder ? item.cover_photo.urls.thumb : item.urls.thumb, - requestPath: item.id, + isFolder, + icon : isFolder ? item.cover_photo.urls.thumb : item.urls.thumb, + name : item.title || item.description, + mimeType : isFolder ? null : 'image/jpeg', + id : item.id, + thumbnail : isFolder ? item.cover_photo.urls.thumb : item.urls.thumb, + requestPath : item.id, modifiedDate: item.updated_at, - size: null + size : null, }) }) diff --git a/examples/custom-provider/server/index.js b/examples/custom-provider/server/index.js index ff5571cc8..87a49653d 100644 --- a/examples/custom-provider/server/index.js +++ b/examples/custom-provider/server/index.js @@ -9,20 +9,20 @@ const app = express() app.use(bodyParser.json()) app.use(session({ - secret: 'some-secret', - resave: true, - saveUninitialized: true + secret : 'some-secret', + resave : true, + saveUninitialized: true, })) app.use((req, res, next) => { res.setHeader('Access-Control-Allow-Origin', req.headers.origin || '*') res.setHeader( 'Access-Control-Allow-Methods', - 'GET, POST, OPTIONS, PUT, PATCH, DELETE' + 'GET, POST, OPTIONS, PUT, PATCH, DELETE', ) res.setHeader( 'Access-Control-Allow-Headers', - 'Authorization, Origin, Content-Type, Accept' + 'Authorization, Origin, Content-Type, Accept', ) next() }) @@ -41,39 +41,37 @@ const ACCESS_URL = 'https://unsplash.com/oauth/token' const uppyOptions = { providerOptions: { drive: { - key: 'your google drive key', - secret: 'your google drive secret' - } + key : 'your google drive key', + secret: 'your google drive secret', + }, }, customProviders: { myunsplash: { config: { // your oauth handlers authorize_url: AUTHORIZE_URL, - access_url: ACCESS_URL, - oauth: 2, - key: 'your unsplash key here', - secret: 'your unsplash secret here' + access_url : ACCESS_URL, + oauth : 2, + key : 'your unsplash key here', + secret : 'your unsplash secret here', }, // you provider module - module: require('./customprovider') - } + module: require('./customprovider'), + }, }, server: { - host: 'localhost:3020', - protocol: 'http' + host : 'localhost:3020', + protocol: 'http', }, filePath: './output', - secret: 'some-secret', - debug: true + secret : 'some-secret', + debug : true, } app.use(uppy.app(uppyOptions)) // handle 404 -app.use((req, res, next) => { - return res.status(404).json({ message: 'Not Found' }) -}) +app.use((req, res, next) => res.status(404).json({ message: 'Not Found' })) // handle server errors app.use((err, req, res, next) => { diff --git a/examples/dev/Dashboard.js b/examples/dev/Dashboard.js index e0feaa36c..b2cac2a97 100644 --- a/examples/dev/Dashboard.js +++ b/examples/dev/Dashboard.js @@ -50,22 +50,22 @@ const RESTORE = false module.exports = () => { const uppyDashboard = new Uppy({ logger: Uppy.debugLogger, - meta: { + meta : { username: 'John', - license: 'Creative Commons' - } + license : 'Creative Commons', + }, }) .use(Dashboard, { - trigger: '#pick-files', + trigger : '#pick-files', // inline: true, - target: '.foo', + target : '.foo', metaFields: [ { id: 'license', name: 'License', placeholder: 'specify license' }, - { id: 'caption', name: 'Caption', placeholder: 'add caption' } + { id: 'caption', name: 'Caption', placeholder: 'add caption' }, ], - showProgressDetails: true, + showProgressDetails : true, proudlyDisplayPoweredByUppy: true, - note: '2 files, images and video only' + note : '2 files, images and video only', }) .use(GoogleDrive, { target: Dashboard, companionUrl: COMPANION_URL }) .use(Instagram, { target: Dashboard, companionUrl: COMPANION_URL }) @@ -77,9 +77,9 @@ module.exports = () => { .use(Url, { target: Dashboard, companionUrl: COMPANION_URL }) .use(Unsplash, { target: Dashboard, companionUrl: COMPANION_URL }) .use(Webcam, { - target: Dashboard, + target : Dashboard, showVideoSourceDropdown: true, - showRecordingLength: true + showRecordingLength : true, }) .use(ScreenCapture, { target: Dashboard }) .use(Form, { target: '#upload-form' }) @@ -101,35 +101,35 @@ module.exports = () => { case 'transloadit': uppyDashboard.use(Transloadit, { waitForEncoding: true, - params: { - auth: { key: TRANSLOADIT_KEY }, - template_id: TRANSLOADIT_TEMPLATE - } + params : { + auth : { key: TRANSLOADIT_KEY }, + template_id: TRANSLOADIT_TEMPLATE, + }, }) break case 'transloadit-s3': uppyDashboard.use(AwsS3, { companionUrl: COMPANION_URL }) uppyDashboard.use(Transloadit, { - waitForEncoding: true, + waitForEncoding : true, importFromUploadURLs: true, - params: { - auth: { key: TRANSLOADIT_KEY }, - template_id: TRANSLOADIT_TEMPLATE - } + params : { + auth : { key: TRANSLOADIT_KEY }, + template_id: TRANSLOADIT_TEMPLATE, + }, }) break case 'transloadit-xhr': uppyDashboard.setMeta({ params: JSON.stringify({ - auth: { key: TRANSLOADIT_KEY }, - template_id: TRANSLOADIT_TEMPLATE - }) + auth : { key: TRANSLOADIT_KEY }, + template_id: TRANSLOADIT_TEMPLATE, + }), }) uppyDashboard.use(XHRUpload, { - method: 'POST', - endpoint: 'https://api2.transloadit.com/assemblies', + method : 'POST', + endpoint : 'https://api2.transloadit.com/assemblies', metaFields: ['params'], - bundle: true + bundle : true, }) break } diff --git a/examples/dev/DragDrop.js b/examples/dev/DragDrop.js index 5f60b323e..e4c370522 100644 --- a/examples/dev/DragDrop.js +++ b/examples/dev/DragDrop.js @@ -6,11 +6,11 @@ const ProgressBar = require('@uppy/progress-bar/src') module.exports = () => { const uppyDragDrop = new Uppy({ - debug: true, - autoProceed: true + debug : true, + autoProceed: true, }) .use(DragDrop, { - target: '#uppyDragDrop' + target: '#uppyDragDrop', }) .use(ProgressBar, { target: '#uppyDragDrop-progress', hideAfterFinish: false }) .use(Tus, { endpoint: 'https://tusd.tusdemo.net/files/' }) diff --git a/examples/dev/index.js b/examples/dev/index.js index 37e2abb9a..f04d3540c 100644 --- a/examples/dev/index.js +++ b/examples/dev/index.js @@ -19,6 +19,6 @@ if ('serviceWorker' in navigator) { console.log('ServiceWorker registration successful with scope: ', registration.scope) }) .catch((error) => { - console.log('Registration failed with ' + error) + console.log(`Registration failed with ${error}`) }) } diff --git a/examples/dev/sw.js b/examples/dev/sw.js index 975f0de01..4b276203b 100644 --- a/examples/dev/sw.js +++ b/examples/dev/sw.js @@ -40,9 +40,9 @@ function removeFile (store, fileID) { function getFiles (store) { sendMessageToAllClients({ - type: 'uppy/ALL_FILES', - store: store, - files: getCache(store) + type : 'uppy/ALL_FILES', + store, + files: getCache(store), }) } diff --git a/examples/digitalocean-spaces/main.js b/examples/digitalocean-spaces/main.js index ad3bb7747..0afed6fb3 100644 --- a/examples/digitalocean-spaces/main.js +++ b/examples/digitalocean-spaces/main.js @@ -3,12 +3,12 @@ const Dashboard = require('@uppy/dashboard') const AwsS3 = require('@uppy/aws-s3') const uppy = new Uppy({ - debug: true + debug: true, }) uppy.use(Dashboard, { inline: true, - target: 'body' + target: 'body', }) // No client side changes needed! diff --git a/examples/digitalocean-spaces/server.js b/examples/digitalocean-spaces/server.js index d8fd1bec7..dec65919c 100644 --- a/examples/digitalocean-spaces/server.js +++ b/examples/digitalocean-spaces/server.js @@ -26,20 +26,21 @@ const app = router() // Set up the /params endpoint that will create signed URLs for us. app.use(require('cors')()) app.use(require('body-parser').json()) + app.use('/companion', companion.app({ providerOptions: { s3: { // This is the crucial part; set an endpoint template for the service you want to use. endpoint: 'https://{region}.digitaloceanspaces.com', - getKey: (req, filename) => `uploads/${filename}`, + getKey : (req, filename) => `uploads/${filename}`, - key: process.env.COMPANION_AWS_KEY, + key : process.env.COMPANION_AWS_KEY, secret: process.env.COMPANION_AWS_SECRET, bucket: process.env.COMPANION_AWS_BUCKET, - region: process.env.COMPANION_AWS_REGION - } + region: process.env.COMPANION_AWS_REGION, + }, }, - server: { serverUrl: `localhost:${PORT}` } + server: { serverUrl: `localhost:${PORT}` }, })) // Serve the built CSS file. @@ -50,18 +51,18 @@ app.get('/uppy.min.css', (req, res) => { // Start the development server, budo. budo(path.join(__dirname, 'main.js'), { - live: true, - stream: process.stdout, - port: PORT, + live : true, + stream : process.stdout, + port : PORT, middleware: app, browserify: { transform: [ 'babelify', ['aliasify', { aliases: { - '@uppy': path.join(__dirname, '../../packages/@uppy') - } - }] - ] - } + '@uppy': path.join(__dirname, '../../packages/@uppy'), + }, + }], + ], + }, }) diff --git a/examples/multiple-instances/main.js b/examples/multiple-instances/main.js index 07c3f61fb..9b78cd614 100644 --- a/examples/multiple-instances/main.js +++ b/examples/multiple-instances/main.js @@ -5,24 +5,24 @@ const GoldenRetriever = require('@uppy/golden-retriever') // Initialise two Uppy instances with the GoldenRetriever plugin, // but with different `id`s. const a = new Uppy({ - id: 'a', - debug: true + id : 'a', + debug: true, }) .use(Dashboard, { target: '#a', inline: true, - width: 400 + width : 400, }) .use(GoldenRetriever, { serviceWorker: false }) const b = new Uppy({ - id: 'b', - debug: true + id : 'b', + debug: true, }) .use(Dashboard, { target: '#b', inline: true, - width: 400 + width : 400, }) .use(GoldenRetriever, { serviceWorker: false }) diff --git a/examples/node-xhr/main.js b/examples/node-xhr/main.js index 8cec54702..6f392d6e8 100644 --- a/examples/node-xhr/main.js +++ b/examples/node-xhr/main.js @@ -4,16 +4,16 @@ const Dashboard = require('@uppy/dashboard') const xhr = require('@uppy/xhr-upload') const uppy = new Uppy({ - debug: true, - autoProceed: false + debug : true, + autoProceed: false, }) uppy.use(Webcam) uppy.use(Dashboard, { - inline: true, - target: 'body', - plugins: ['Webcam'] + inline : true, + target : 'body', + plugins: ['Webcam'], }) uppy.use(xhr, { - endpoint: 'http://localhost:3020/upload' + endpoint: 'http://localhost:3020/upload', }) diff --git a/examples/node-xhr/server.js b/examples/node-xhr/server.js index 5b0c4bfb1..2726590ae 100644 --- a/examples/node-xhr/server.js +++ b/examples/node-xhr/server.js @@ -1,12 +1,12 @@ var formidable = require('formidable') var http = require('http') -http.createServer(function (req, res) { +http.createServer((req, res) => { const headers = { - 'Content-Type': 'application/json', - 'Access-Control-Allow-Origin': '*', + 'Content-Type' : 'application/json', + 'Access-Control-Allow-Origin' : '*', 'Access-Control-Allow-Methods': 'OPTIONS, POST, GET', - 'Access-Control-Max-Age': 2592000 // 30 days + 'Access-Control-Max-Age' : 2592000, // 30 days /** add other headers as per requirement */ } @@ -21,7 +21,7 @@ http.createServer(function (req, res) { form.uploadDir = './uploads' form.keepExtensions = true - form.parse(req, function (err, fields, files) { + form.parse(req, (err, fields, files) => { if (err) { console.log('some error', err) res.writeHead(200, headers) diff --git a/examples/php-xhr/main.js b/examples/php-xhr/main.js index a1a7b01e9..eb34bc81a 100644 --- a/examples/php-xhr/main.js +++ b/examples/php-xhr/main.js @@ -4,16 +4,16 @@ const Dashboard = require('@uppy/dashboard') const XHRUpload = require('@uppy/xhr-upload') const uppy = new Uppy({ - debug: true, - autoProceed: false + debug : true, + autoProceed: false, }) uppy.use(Webcam) uppy.use(Dashboard, { - inline: true, - target: 'body', - plugins: ['Webcam'] + inline : true, + target : 'body', + plugins: ['Webcam'], }) uppy.use(XHRUpload, { - endpoint: 'http://localhost:3020/upload.php' + endpoint: 'http://localhost:3020/upload.php', }) diff --git a/examples/python-xhr/main.js b/examples/python-xhr/main.js index cdb0da714..402c183b5 100644 --- a/examples/python-xhr/main.js +++ b/examples/python-xhr/main.js @@ -4,16 +4,16 @@ const Dashboard = require('@uppy/dashboard') const XHRUpload = require('@uppy/xhr-upload') const uppy = new Uppy({ - debug: true, - autoProceed: false + debug : true, + autoProceed: false, }) uppy.use(Webcam) uppy.use(Dashboard, { - inline: true, - target: 'body', - plugins: ['Webcam'] + inline : true, + target : 'body', + plugins: ['Webcam'], }) uppy.use(XHRUpload, { - endpoint: 'http://localhost:3020/upload' + endpoint: 'http://localhost:3020/upload', }) diff --git a/examples/react-native-expo/App.js b/examples/react-native-expo/App.js index 6d483a77e..554a7e128 100644 --- a/examples/react-native-expo/App.js +++ b/examples/react-native-expo/App.js @@ -4,7 +4,7 @@ import { Text, View, AsyncStorage, - Image + Image, } from 'react-native' import Uppy from '@uppy/core' import Tus from '@uppy/tus' @@ -20,21 +20,21 @@ export default class App extends React.Component { super() this.state = { - progress: 0, - total: 0, - file: null, - uploadURL: null, + progress : 0, + total : 0, + file : null, + uploadURL : null, isFilePickerVisible: false, - isPaused: false, - uploadStarted: false, - uploadComplete: false, - info: null, - totalProgress: 0 + isPaused : false, + uploadStarted : false, + uploadComplete : false, + info : null, + totalProgress : 0, } - this.isReactNative = (typeof navigator !== 'undefined' && - typeof navigator.product === 'string' && - navigator.product.toLowerCase() === 'reactnative') + this.isReactNative = (typeof navigator !== 'undefined' + && typeof navigator.product === 'string' + && navigator.product.toLowerCase() === 'reactnative') this.showFilePicker = this.showFilePicker.bind(this) this.hideFilePicker = this.hideFilePicker.bind(this) @@ -43,17 +43,17 @@ export default class App extends React.Component { console.log('Is this React Native?', this.isReactNative) this.uppy = new Uppy({ autoProceed: true, debug: true }) this.uppy.use(Tus, { - endpoint: 'https://tusd.tusdemo.net/files/', + endpoint : 'https://tusd.tusdemo.net/files/', urlStorage: AsyncStorage, fileReader: getTusFileReader, - chunkSize: 10 * 1024 * 1024 // keep the chunk size small to avoid memory exhaustion + chunkSize : 10 * 1024 * 1024, // keep the chunk size small to avoid memory exhaustion }) this.uppy.on('upload-progress', (file, progress) => { this.setState({ - progress: progress.bytesUploaded, - total: progress.bytesTotal, + progress : progress.bytesUploaded, + total : progress.bytesTotal, totalProgress: this.uppy.state.totalProgress, - uploadStarted: true + uploadStarted: true, }) }) this.uppy.on('upload-success', (file, response) => { @@ -61,10 +61,10 @@ export default class App extends React.Component { }) this.uppy.on('complete', (result) => { this.setState({ - status: 'Upload complete ✅', - uploadURL: result.successful[0] ? result.successful[0].uploadURL : null, + status : 'Upload complete ✅', + uploadURL : result.successful[0] ? result.successful[0].uploadURL : null, uploadComplete: true, - uploadStarted: false + uploadStarted : false, }) console.log('Upload complete:', result) }) @@ -72,14 +72,14 @@ export default class App extends React.Component { this.uppy.on('info-visible', () => { const info = this.uppy.getState().info this.setState({ - info: info + info, }) console.log('uppy-info:', info) }) this.uppy.on('info-hidden', () => { this.setState({ - info: null + info: null, }) }) } @@ -87,14 +87,14 @@ export default class App extends React.Component { showFilePicker () { this.setState({ isFilePickerVisible: true, - uploadStarted: false, - uploadComplete: false + uploadStarted : false, + uploadComplete : false, }) } hideFilePicker () { this.setState({ - isFilePickerVisible: false + isFilePickerVisible: false, }) } @@ -102,12 +102,12 @@ export default class App extends React.Component { if (this.state.isPaused) { this.uppy.resumeAll() this.setState({ - isPaused: false + isPaused: false, }) } else { this.uppy.pauseAll() this.setState({ - isPaused: true + isPaused: true, }) } } @@ -115,16 +115,16 @@ export default class App extends React.Component { render () { return ( Uppy in React Native @@ -140,8 +140,8 @@ export default class App extends React.Component { {this.state.info.message} diff --git a/examples/react-native-expo/FileList.js b/examples/react-native-expo/FileList.js index 131fa6038..f44cae3b3 100644 --- a/examples/react-native-expo/FileList.js +++ b/examples/react-native-expo/FileList.js @@ -36,7 +36,7 @@ function UppyDashboardFileIcon (props) { item.id} numColumns={2} - renderItem={({ item }) => { - return ( + renderItem={({ item }) => ( {item.type === 'image' ? ( {truncateString(item.name, 20)} {item.type} - ) - }} + )} /> ) @@ -84,48 +82,48 @@ export default function FileList (props) { const styles = StyleSheet.create({ container: { - marginTop: 20, - marginBottom: 20, - flex: 1, - justifyContent: 'center' + marginTop : 20, + marginBottom : 20, + flex : 1, + justifyContent: 'center', }, item: { - width: 100, - marginTop: 5, + width : 100, + marginTop : 5, marginBottom: 15, - marginRight: 25 + marginRight : 25, }, itemImage: { - width: 100, - height: 100, - borderRadius: 5, - marginBottom: 5 - }, - itemIconContainer: { - width: 100, - height: 100, + width : 100, + height : 100, borderRadius: 5, marginBottom: 5, + }, + itemIconContainer: { + width : 100, + height : 100, + borderRadius : 5, + marginBottom : 5, backgroundColor: '#cfd3d6', - alignItems: 'center', - justifyContent: 'center' + alignItems : 'center', + justifyContent : 'center', }, itemIcon: { - width: 42, - height: 56 + width : 42, + height: 56, }, itemIconSVG: { - width: 50, - height: 50 + width : 50, + height: 50, }, itemName: { - fontSize: 13, - color: '#2c3e50', - fontWeight: '600' + fontSize : 13, + color : '#2c3e50', + fontWeight: '600', }, itemType: { fontWeight: '600', - fontSize: 12, - color: '#95a5a6' - } + fontSize : 12, + color : '#95a5a6', + }, }) diff --git a/examples/react-native-expo/PauseResumeButton.js b/examples/react-native-expo/PauseResumeButton.js index d8dc23a98..719e328ea 100644 --- a/examples/react-native-expo/PauseResumeButton.js +++ b/examples/react-native-expo/PauseResumeButton.js @@ -22,11 +22,11 @@ export default function PauseResumeButton (props) { const styles = StyleSheet.create({ button: { backgroundColor: '#cc0077', - padding: 10 + padding : 10, }, text: { - color: '#fff', + color : '#fff', textAlign: 'center', - fontSize: 17 - } + fontSize : 17, + }, }) diff --git a/examples/react-native-expo/ProgressBar.js b/examples/react-native-expo/ProgressBar.js index e1a1521d1..c4dc3f1cc 100644 --- a/examples/react-native-expo/ProgressBar.js +++ b/examples/react-native-expo/ProgressBar.js @@ -9,25 +9,25 @@ export default function ProgressBar (props) { return ( - {progress ? progress + '%' : null} + {progress ? `${progress}%` : null} ) } diff --git a/examples/react-native-expo/SelectFilesButton.js b/examples/react-native-expo/SelectFilesButton.js index af0db97cd..4b2038695 100644 --- a/examples/react-native-expo/SelectFilesButton.js +++ b/examples/react-native-expo/SelectFilesButton.js @@ -15,11 +15,11 @@ export default function SelectFiles (props) { const styles = StyleSheet.create({ button: { backgroundColor: '#cc0077', - padding: 15 + padding : 15, }, text: { - color: '#fff', + color : '#fff', textAlign: 'center', - fontSize: 17 - } + fontSize : 17, + }, }) diff --git a/examples/react-native-expo/babel.config.js b/examples/react-native-expo/babel.config.js index d799d652a..e1e3637af 100644 --- a/examples/react-native-expo/babel.config.js +++ b/examples/react-native-expo/babel.config.js @@ -1,6 +1,6 @@ module.exports = function (api) { api.cache(true) return { - presets: ['babel-preset-expo'] + presets: ['babel-preset-expo'], } } diff --git a/examples/react-native-expo/tusFileReader.js b/examples/react-native-expo/tusFileReader.js index 3b36b1c43..1399a6107 100644 --- a/examples/react-native-expo/tusFileReader.js +++ b/examples/react-native-expo/tusFileReader.js @@ -17,8 +17,8 @@ class TusFileReader { end = Math.min(end, this.size) const options = { encoding: Expo.FileSystem.EncodingTypes.Base64, - length: end - start, - position: start + length : end - start, + position: start, } Expo.FileSystem.readAsStringAsync(this.file.uri, options).then((data) => { cb(null, base64.toByteArray(data)) diff --git a/examples/redux/main.js b/examples/redux/main.js index 6362757e0..f983820f3 100644 --- a/examples/redux/main.js +++ b/examples/redux/main.js @@ -17,15 +17,15 @@ function counter (state = 0, action) { } const reducer = combineReducers({ - counter: counter, + counter, // You don't have to use the `uppy` key. But if you don't, // you need to provide a custom `selector` to the `uppyReduxStore` call below. - uppy: uppyReduxStore.reducer + uppy: uppyReduxStore.reducer, }) let enhancer = applyMiddleware( uppyReduxStore.middleware(), - logger + logger, ) if (window.__REDUX_DEVTOOLS_EXTENSION__) { enhancer = compose(enhancer, window.__REDUX_DEVTOOLS_EXTENSION__()) @@ -60,8 +60,8 @@ document.querySelector('#incrementAsync').onclick = () => { // Uppy using the same store const uppy = new Uppy({ - id: 'redux', - store: uppyReduxStore({ store: store }), + id : 'redux', + store: uppyReduxStore({ store }), // If we had placed our `reducer` elsewhere in Redux, eg. under an `uppy` key in the state for a profile page, // we'd do something like: // @@ -70,12 +70,12 @@ const uppy = new Uppy({ // id: 'avatar', // selector: state => state.pages.profile.uppy // }), - debug: true + debug: true, }) uppy.use(Dashboard, { target: '#app', inline: true, - width: 400 + width : 400, }) uppy.use(Tus, { endpoint: 'https://tusd.tusdemo.net/' }) diff --git a/examples/svelte-example/postcss.config.js b/examples/svelte-example/postcss.config.js index c600f4b5d..8f15746a1 100644 --- a/examples/svelte-example/postcss.config.js +++ b/examples/svelte-example/postcss.config.js @@ -1,5 +1,5 @@ module.exports = { plugins: [ - require('postcss-import')() - ] + require('postcss-import')(), + ], } diff --git a/examples/svelte-example/rollup.config.js b/examples/svelte-example/rollup.config.js index a4dd165ab..4f54f6884 100644 --- a/examples/svelte-example/rollup.config.js +++ b/examples/svelte-example/rollup.config.js @@ -21,32 +21,32 @@ function serve () { if (server) return server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], { stdio: ['ignore', 'inherit', 'inherit'], - shell: true + shell: true, }) process.on('SIGTERM', toExit) process.on('exit', toExit) - } + }, } } export default { - input: 'src/main.ts', + input : 'src/main.ts', output: { sourcemap: true, - format: 'iife', - name: 'app', - file: 'public/build/bundle.js' + format : 'iife', + name : 'app', + file : 'public/build/bundle.js', }, plugins: [ svelte({ preprocess: sveltePreprocess({ - postcss: true + postcss: true, }), compilerOptions: { // enable run-time checks when not in production - dev: !production - } + dev: !production, + }, }), // we'll extract any component CSS out into // a separate file - better for performance @@ -59,12 +59,12 @@ export default { // https://github.com/rollup/plugins/tree/master/packages/commonjs resolve({ browser: true, - dedupe: ['svelte', '@uppy/core'] + dedupe : ['svelte', '@uppy/core'], }), commonjs(), typescript({ - sourceMap: !production, - inlineSources: !production + sourceMap : !production, + inlineSources: !production, }), // In dev mode, call `npm run start` once @@ -77,9 +77,9 @@ export default { // If we're building for production (npm run build // instead of npm run dev), minify - production && terser() + production && terser(), ], watch: { - clearScreen: false - } + clearScreen: false, + }, } diff --git a/examples/transloadit-textarea/main.js b/examples/transloadit-textarea/main.js index 6adf7e6cc..57e365dcd 100644 --- a/examples/transloadit-textarea/main.js +++ b/examples/transloadit-textarea/main.js @@ -26,7 +26,8 @@ class MarkdownTextarea { this.uploadLine.classList.add('mdtxt-upload') this.uploadLine.appendChild( - document.createTextNode('Upload an attachment')) + document.createTextNode('Upload an attachment'), + ) } install () { @@ -104,15 +105,15 @@ class MarkdownTextarea { uploadFiles (files) { robodog.upload({ waitForEncoding: true, - params: { - auth: { key: TRANSLOADIT_EXAMPLE_KEY }, - template_id: TRANSLOADIT_EXAMPLE_TEMPLATE - } + params : { + auth : { key: TRANSLOADIT_EXAMPLE_KEY }, + template_id: TRANSLOADIT_EXAMPLE_TEMPLATE, + }, }).then((result) => { // Was cancelled if (result == null) return this.insertAttachments( - this.matchFilesAndThumbs(result.results) + this.matchFilesAndThumbs(result.results), ) }).catch((err) => { console.error(err) @@ -123,15 +124,15 @@ class MarkdownTextarea { pickFiles () { robodog.pick({ waitForEncoding: true, - params: { - auth: { key: TRANSLOADIT_EXAMPLE_KEY }, - template_id: TRANSLOADIT_EXAMPLE_TEMPLATE - } + params : { + auth : { key: TRANSLOADIT_EXAMPLE_KEY }, + template_id: TRANSLOADIT_EXAMPLE_TEMPLATE, + }, }).then((result) => { // Was cancelled if (result == null) return this.insertAttachments( - this.matchFilesAndThumbs(result.results) + this.matchFilesAndThumbs(result.results), ) }).catch((err) => { console.error(err) @@ -141,7 +142,8 @@ class MarkdownTextarea { } const textarea = new MarkdownTextarea( - document.querySelector('#new textarea')) + document.querySelector('#new textarea'), +) textarea.install() function renderSnippet (title, text) { @@ -173,8 +175,8 @@ function loadSnippets () { document.querySelector('#new').addEventListener('submit', (event) => { event.preventDefault() - const title = event.target.querySelector('input[name="title"]').value || - 'Unnamed Snippet' + const title = event.target.querySelector('input[name="title"]').value + || 'Unnamed Snippet' const text = textarea.element.value saveSnippet(title, text) diff --git a/examples/transloadit/main.js b/examples/transloadit/main.js index c9096a09e..2a6c427d5 100644 --- a/examples/transloadit/main.js +++ b/examples/transloadit/main.js @@ -21,18 +21,18 @@ const TEMPLATE_ID = 'bbc273f69e0c4694a5a9d1b587abc1bc' */ const formUppy = robodog.form('#test-form', { - debug: true, - fields: ['message'], + debug : true, + fields : ['message'], restrictions: { - allowedFileTypes: ['.png'] + allowedFileTypes: ['.png'], }, waitForEncoding: true, - params: { - auth: { key: TRANSLOADIT_KEY }, - template_id: TEMPLATE_ID + params : { + auth : { key: TRANSLOADIT_KEY }, + template_id: TEMPLATE_ID, }, - modal: true, - progressBar: '#test-form .progress' + modal : true, + progressBar: '#test-form .progress', }) formUppy.on('error', (err) => { @@ -48,30 +48,30 @@ formUppy.on('upload-error', (file, err) => { window.formUppy = formUppy const formUppyWithDashboard = robodog.form('#dashboard-form', { - debug: true, - fields: ['message'], + debug : true, + fields : ['message'], restrictions: { - allowedFileTypes: ['.png'] + allowedFileTypes: ['.png'], }, waitForEncoding: true, - note: 'Only PNG files please!', - params: { - auth: { key: TRANSLOADIT_KEY }, - template_id: TEMPLATE_ID + note : 'Only PNG files please!', + params : { + auth : { key: TRANSLOADIT_KEY }, + template_id: TEMPLATE_ID, }, - dashboard: '#dashboard-form .dashboard' + dashboard: '#dashboard-form .dashboard', }) window.formUppyWithDashboard = formUppyWithDashboard const dashboard = robodog.dashboard('#dashboard', { - debug: true, + debug : true, waitForEncoding: true, - note: 'Images will be resized with Transloadit', - params: { - auth: { key: TRANSLOADIT_KEY }, - template_id: TEMPLATE_ID - } + note : 'Images will be resized with Transloadit', + params : { + auth : { key: TRANSLOADIT_KEY }, + template_id: TEMPLATE_ID, + }, }) window.dashboard = dashboard @@ -83,16 +83,16 @@ window.dashboard = dashboard function openModal () { robodog.pick({ restrictions: { - allowedFileTypes: ['.png'] + allowedFileTypes: ['.png'], }, waitForEncoding: true, - params: { - auth: { key: TRANSLOADIT_KEY }, - template_id: TEMPLATE_ID + params : { + auth : { key: TRANSLOADIT_KEY }, + template_id: TEMPLATE_ID, }, providers: [ - 'webcam' - ] + 'webcam', + ], // if providers need custom config // webcam: { // option: 'whatever' @@ -111,10 +111,10 @@ window.doUpload = (event) => { const errorEl = document.querySelector('#upload-error') robodog.upload(event.target.files, { waitForEncoding: true, - params: { - auth: { key: TRANSLOADIT_KEY }, - template_id: TEMPLATE_ID - } + params : { + auth : { key: TRANSLOADIT_KEY }, + template_id: TEMPLATE_ID, + }, }).then((result) => { resultEl.classList.remove('hidden') errorEl.classList.add('hidden') diff --git a/examples/uppy-with-companion/server/index.js b/examples/uppy-with-companion/server/index.js index 92d789321..1da87aa21 100644 --- a/examples/uppy-with-companion/server/index.js +++ b/examples/uppy-with-companion/server/index.js @@ -7,20 +7,20 @@ const app = express() app.use(bodyParser.json()) app.use(session({ - secret: 'some-secret', - resave: true, - saveUninitialized: true + secret : 'some-secret', + resave : true, + saveUninitialized: true, })) app.use((req, res, next) => { res.setHeader('Access-Control-Allow-Origin', req.headers.origin || '*') res.setHeader( 'Access-Control-Allow-Methods', - 'GET, POST, OPTIONS, PUT, PATCH, DELETE' + 'GET, POST, OPTIONS, PUT, PATCH, DELETE', ) res.setHeader( 'Access-Control-Allow-Headers', - 'Authorization, Origin, Content-Type, Accept' + 'Authorization, Origin, Content-Type, Accept', ) next() }) @@ -35,38 +35,36 @@ app.get('/', (req, res) => { const uppyOptions = { providerOptions: { drive: { - key: 'your google key', - secret: 'your google secret' + key : 'your google key', + secret: 'your google secret', }, instagram: { - key: 'your instagram key', - secret: 'your instagram secret' + key : 'your instagram key', + secret: 'your instagram secret', }, dropbox: { - key: 'your dropbox key', - secret: 'your dropbox secret' + key : 'your dropbox key', + secret: 'your dropbox secret', }, box: { - key: 'your box key', - secret: 'your box secret' - } + key : 'your box key', + secret: 'your box secret', + }, // you can also add options for additional providers here }, server: { - host: 'localhost:3020', - protocol: 'http' + host : 'localhost:3020', + protocol: 'http', }, filePath: './output', - secret: 'some-secret', - debug: true + secret : 'some-secret', + debug : true, } app.use(companion.app(uppyOptions)) // handle 404 -app.use((req, res, next) => { - return res.status(404).json({ message: 'Not Found' }) -}) +app.use((req, res, next) => res.status(404).json({ message: 'Not Found' })) // handle server errors app.use((err, req, res, next) => { diff --git a/examples/vue/babel.config.js b/examples/vue/babel.config.js index e9558405f..df195386e 100644 --- a/examples/vue/babel.config.js +++ b/examples/vue/babel.config.js @@ -1,5 +1,5 @@ module.exports = { presets: [ - '@vue/cli-plugin-babel/preset' - ] + '@vue/cli-plugin-babel/preset', + ], } diff --git a/examples/vue/src/main.js b/examples/vue/src/main.js index fca74cfc9..dd079f8d5 100644 --- a/examples/vue/src/main.js +++ b/examples/vue/src/main.js @@ -4,5 +4,5 @@ import App from './App.vue' Vue.config.productionTip = false new Vue({ - render: h => h(App) + render: (h) => h(App), }).$mount('#app') diff --git a/examples/xhr-bundle/main.js b/examples/xhr-bundle/main.js index 54425a199..de5a982b9 100644 --- a/examples/xhr-bundle/main.js +++ b/examples/xhr-bundle/main.js @@ -4,19 +4,19 @@ const XHRUpload = require('@uppy/xhr-upload') const uppy = new Uppy({ debug: true, - meta: { something: 'xyz' } + meta : { something: 'xyz' }, }) uppy.use(Dashboard, { - target: '#app', - inline: true, - hideRetryButton: true, - hideCancelButton: true + target : '#app', + inline : true, + hideRetryButton : true, + hideCancelButton: true, }) uppy.use(XHRUpload, { - bundle: true, - endpoint: 'http://localhost:9967/upload', + bundle : true, + endpoint : 'http://localhost:9967/upload', metaFields: ['something'], - fieldName: 'files' + fieldName : 'files', }) diff --git a/examples/xhr-bundle/serve.js b/examples/xhr-bundle/serve.js index 4d8aa6af7..6fcc62545 100644 --- a/examples/xhr-bundle/serve.js +++ b/examples/xhr-bundle/serve.js @@ -3,7 +3,7 @@ var cors = require('cors') var multer = require('multer') var upload = multer({ - storage: multer.memoryStorage() + storage: multer.memoryStorage(), }) app.use(cors()) @@ -13,9 +13,9 @@ app.listen(9967) function uploadRoute (req, res) { res.json({ - files: req.files.map(function (file) { + files: req.files.map((file) => { delete file.buffer return file - }) + }), }) } diff --git a/packages/@uppy/aws-s3-multipart/src/MultipartUploader.js b/packages/@uppy/aws-s3-multipart/src/MultipartUploader.js index aecef2717..ff5d6ff4f 100644 --- a/packages/@uppy/aws-s3-multipart/src/MultipartUploader.js +++ b/packages/@uppy/aws-s3-multipart/src/MultipartUploader.js @@ -4,7 +4,7 @@ const delay = require('@uppy/utils/lib/delay') const MB = 1024 * 1024 const defaultOptions = { - limit: 1, + limit : 1, retryDelays: [0, 1000, 3000, 5000], getChunkSize (file) { return Math.ceil(file.size / 10000) @@ -15,7 +15,7 @@ const defaultOptions = { onSuccess () {}, onError (err) { throw err - } + }, } function ensureInt (value) { @@ -32,7 +32,7 @@ class MultipartUploader { constructor (file, options) { this.options = { ...defaultOptions, - ...options + ...options, } // Use default `getChunkSize` if it was null or something if (!this.options.getChunkSize) { @@ -95,21 +95,20 @@ class MultipartUploader { this.chunks = chunks this.chunkState = chunks.map(() => ({ uploaded: 0, - busy: false, - done: false + busy : false, + done : false, })) } _createUpload () { this.createdPromise = Promise.resolve().then(() => - this.options.createMultipartUpload() - ) + this.options.createMultipartUpload()) return this.createdPromise.then((result) => { if (this._aborted()) throw createAbortError() - const valid = typeof result === 'object' && result && - typeof result.uploadId === 'string' && - typeof result.key === 'string' + const valid = typeof result === 'object' && result + && typeof result.uploadId === 'string' + && typeof result.key === 'string' if (!valid) { throw new TypeError('AwsS3/Multipart: Got incorrect result from `createMultipartUpload()`, expected an object `{ uploadId, key }`.') } @@ -128,9 +127,8 @@ class MultipartUploader { return Promise.resolve().then(() => this.options.listParts({ uploadId: this.uploadId, - key: this.key - }) - ).then((parts) => { + key : this.key, + })).then((parts) => { if (this._aborted()) throw createAbortError() parts.forEach((part) => { @@ -138,15 +136,15 @@ class MultipartUploader { this.chunkState[i] = { uploaded: ensureInt(part.Size), - etag: part.ETag, - done: true + etag : part.ETag, + done : true, } // Only add if we did not yet know about this part. if (!this.parts.some((p) => p.PartNumber === part.PartNumber)) { this.parts.push({ PartNumber: part.PartNumber, - ETag: part.ETag + ETag : part.ETag, }) } }) @@ -211,9 +209,8 @@ class MultipartUploader { if (shouldRetry(err) && retryAttempt < retryDelays.length) { return delay(retryDelays[retryAttempt], { signal }) .then(() => doAttempt(retryAttempt + 1)) - } else { - throw err } + throw err }) return doAttempt(0).then((result) => { @@ -231,9 +228,9 @@ class MultipartUploader { this.partsInProgress += 1 }, attempt: () => this._uploadPart(index), - after: () => { + after : () => { this.partsInProgress -= 1 - } + }, }) } @@ -243,14 +240,13 @@ class MultipartUploader { return Promise.resolve().then(() => this.options.prepareUploadPart({ - key: this.key, + key : this.key, uploadId: this.uploadId, body, - number: index + 1 - }) - ).then((result) => { - const valid = typeof result === 'object' && result && - typeof result.url === 'string' + number : index + 1, + })).then((result) => { + const valid = typeof result === 'object' && result + && typeof result.url === 'string' if (!valid) { throw new TypeError('AwsS3/Multipart: Got incorrect result from `prepareUploadPart()`, expected an object `{ url }`.') } @@ -279,7 +275,7 @@ class MultipartUploader { const part = { PartNumber: index + 1, - ETag: etag + ETag : etag, } this.parts.push(part) @@ -369,11 +365,10 @@ class MultipartUploader { return Promise.resolve().then(() => this.options.completeMultipartUpload({ - key: this.key, + key : this.key, uploadId: this.uploadId, - parts: this.parts - }) - ).then((result) => { + parts : this.parts, + })).then((result) => { this.options.onSuccess(result) }, (err) => { this._onError(err) @@ -385,8 +380,8 @@ class MultipartUploader { this.createdPromise.then(() => { this.options.abortMultipartUpload({ - key: this.key, - uploadId: this.uploadId + key : this.key, + uploadId: this.uploadId, }) }, () => { // if the creation failed we do not need to abort diff --git a/packages/@uppy/aws-s3-multipart/src/index.js b/packages/@uppy/aws-s3-multipart/src/index.js index fe5d9fca4..d68e54e2d 100644 --- a/packages/@uppy/aws-s3-multipart/src/index.js +++ b/packages/@uppy/aws-s3-multipart/src/index.js @@ -26,14 +26,14 @@ module.exports = class AwsS3Multipart extends Plugin { this.client = new RequestClient(uppy, opts) const defaultOptions = { - timeout: 30 * 1000, - limit: 0, - retryDelays: [0, 1000, 3000, 5000], - createMultipartUpload: this.createMultipartUpload.bind(this), - listParts: this.listParts.bind(this), - prepareUploadPart: this.prepareUploadPart.bind(this), - abortMultipartUpload: this.abortMultipartUpload.bind(this), - completeMultipartUpload: this.completeMultipartUpload.bind(this) + timeout : 30 * 1000, + limit : 0, + retryDelays : [0, 1000, 3000, 5000], + createMultipartUpload : this.createMultipartUpload.bind(this), + listParts : this.listParts.bind(this), + prepareUploadPart : this.prepareUploadPart.bind(this), + abortMultipartUpload : this.abortMultipartUpload.bind(this), + completeMultipartUpload: this.completeMultipartUpload.bind(this), } this.opts = { ...defaultOptions, ...opts } @@ -80,7 +80,7 @@ module.exports = class AwsS3Multipart extends Plugin { const metadata = {} - Object.keys(file.meta).map(key => { + Object.keys(file.meta).map((key) => { if (file.meta[key] != null) { metadata[key] = file.meta[key].toString() } @@ -88,8 +88,8 @@ module.exports = class AwsS3Multipart extends Plugin { return this.client.post('s3/multipart', { filename: file.name, - type: file.type, - metadata + type : file.type, + metadata, }).then(assertServerError) } @@ -134,17 +134,17 @@ module.exports = class AwsS3Multipart extends Plugin { this.uppy.setFileState(file.id, { s3Multipart: { ...cFile.s3Multipart, - key: data.key, - uploadId: data.uploadId - } + key : data.key, + uploadId: data.uploadId, + }, }) } const onProgress = (bytesUploaded, bytesTotal) => { this.uppy.emit('upload-progress', file, { uploader: this, - bytesUploaded: bytesUploaded, - bytesTotal: bytesTotal + bytesUploaded, + bytesTotal, }) } @@ -160,9 +160,9 @@ module.exports = class AwsS3Multipart extends Plugin { const onSuccess = (result) => { const uploadResp = { body: { - ...result + ...result, }, - uploadURL: result.location + uploadURL: result.location, } queuedRequest.done() @@ -171,7 +171,7 @@ module.exports = class AwsS3Multipart extends Plugin { this.uppy.emit('upload-success', file, uploadResp) if (result.location) { - this.uppy.log('Download ' + upload.file.name + ' from ' + result.location) + this.uppy.log(`Download ${upload.file.name} from ${result.location}`) } resolve(upload) @@ -188,12 +188,12 @@ module.exports = class AwsS3Multipart extends Plugin { const upload = new Uploader(file.data, { // .bind to pass the file object to each handler. - createMultipartUpload: this.opts.createMultipartUpload.bind(this, file), - listParts: this.opts.listParts.bind(this, file), - prepareUploadPart: this.opts.prepareUploadPart.bind(this, file), + createMultipartUpload : this.opts.createMultipartUpload.bind(this, file), + listParts : this.opts.listParts.bind(this, file), + prepareUploadPart : this.opts.prepareUploadPart.bind(this, file), completeMultipartUpload: this.opts.completeMultipartUpload.bind(this, file), - abortMultipartUpload: this.opts.abortMultipartUpload.bind(this, file), - getChunkSize: this.opts.getChunkSize ? this.opts.getChunkSize.bind(this) : null, + abortMultipartUpload : this.opts.abortMultipartUpload.bind(this, file), + getChunkSize : this.opts.getChunkSize ? this.opts.getChunkSize.bind(this) : null, onStart, onProgress, @@ -201,9 +201,9 @@ module.exports = class AwsS3Multipart extends Plugin { onSuccess, onPartComplete, - limit: this.opts.limit || 5, + limit : this.opts.limit || 5, retryDelays: this.opts.retryDelays || [], - ...file.s3Multipart + ...file.s3Multipart, }) this.uploaders[file.id] = upload @@ -285,21 +285,20 @@ module.exports = class AwsS3Multipart extends Plugin { { ...file.remote.body, protocol: 's3-multipart', - size: file.data.size, - metadata: file.meta - } + size : file.data.size, + metadata: file.meta, + }, ).then((res) => { this.uppy.setFileState(file.id, { serverToken: res.token }) file = this.uppy.getFile(file.id) return file - }).then((file) => { - return this.connectToServerSocket(file) - }).then(() => { + }).then((file) => this.connectToServerSocket(file)).then(() => { resolve() - }).catch((err) => { - this.uppy.emit('upload-error', file, err) - reject(err) }) + .catch((err) => { + this.uppy.emit('upload-error', file, err) + reject(err) + }) }) } @@ -384,7 +383,7 @@ module.exports = class AwsS3Multipart extends Plugin { socket.on('success', (data) => { const uploadResp = { - uploadURL: data.url + uploadURL: data.url, } this.uppy.emit('upload-success', file, uploadResp) @@ -474,8 +473,8 @@ module.exports = class AwsS3Multipart extends Plugin { this.uppy.setState({ capabilities: { ...capabilities, - resumableUploads: true - } + resumableUploads: true, + }, }) this.uppy.addUploader(this.upload) } @@ -485,8 +484,8 @@ module.exports = class AwsS3Multipart extends Plugin { this.uppy.setState({ capabilities: { ...capabilities, - resumableUploads: false - } + resumableUploads: false, + }, }) this.uppy.removeUploader(this.upload) } diff --git a/packages/@uppy/aws-s3/src/MiniXHRUpload.js b/packages/@uppy/aws-s3/src/MiniXHRUpload.js index 7cb53f836..fadb5574b 100644 --- a/packages/@uppy/aws-s3/src/MiniXHRUpload.js +++ b/packages/@uppy/aws-s3/src/MiniXHRUpload.js @@ -40,7 +40,7 @@ module.exports = class MiniXHRUpload { validateStatus (status, responseText, response) { return status >= 200 && status < 300 }, - ...opts + ...opts, } this.requests = opts.__queue @@ -56,7 +56,7 @@ module.exports = class MiniXHRUpload { ...this.opts, ...(overrides || {}), ...(file.xhrUpload || {}), - headers: {} + headers: {}, } Object.assign(opts.headers, this.opts.headers) if (overrides) { @@ -174,9 +174,9 @@ module.exports = class MiniXHRUpload { if (ev.lengthComputable) { this.uppy.emit('upload-progress', file, { - uploader: this, + uploader : this, bytesUploaded: ev.loaded, - bytesTotal: ev.total + bytesTotal : ev.total, }) } }) @@ -197,7 +197,7 @@ module.exports = class MiniXHRUpload { const uploadResp = { status: ev.target.status, body, - uploadURL + uploadURL, } this.uppy.emit('upload-success', file, uploadResp) @@ -207,18 +207,17 @@ module.exports = class MiniXHRUpload { } return resolve(file) - } else { - const body = opts.getResponseData(xhr.responseText, xhr) - const error = buildResponseError(xhr, opts.getResponseError(xhr.responseText, xhr)) - - const response = { - status: ev.target.status, - body - } - - this.uppy.emit('upload-error', file, error, response) - return reject(error) } + const body = opts.getResponseData(xhr.responseText, xhr) + const error = buildResponseError(xhr, opts.getResponseError(xhr.responseText, xhr)) + + const response = { + status: ev.target.status, + body, + } + + this.uppy.emit('upload-error', file, error, response) + return reject(error) }) xhr.addEventListener('error', (ev) => { @@ -287,13 +286,13 @@ module.exports = class MiniXHRUpload { const client = new Client(this.uppy, file.remote.providerOptions) client.post(file.remote.url, { ...file.remote.body, - endpoint: opts.endpoint, - size: file.data.size, - fieldname: opts.fieldName, - metadata: fields, - httpMethod: opts.method, + endpoint : opts.endpoint, + size : file.data.size, + fieldname : opts.fieldName, + metadata : fields, + httpMethod : opts.method, useFormData: opts.formData, - headers: opts.headers + headers : opts.headers, }).then((res) => { const token = res.token const host = getSocketHost(file.remote.companionUrl) @@ -331,7 +330,7 @@ module.exports = class MiniXHRUpload { const uploadResp = { status: data.response.status, body, - uploadURL + uploadURL, } this.uppy.emit('upload-success', file, uploadResp) diff --git a/packages/@uppy/aws-s3/src/index.js b/packages/@uppy/aws-s3/src/index.js index 5685d1eca..dec78b588 100644 --- a/packages/@uppy/aws-s3/src/index.js +++ b/packages/@uppy/aws-s3/src/index.js @@ -81,15 +81,15 @@ module.exports = class AwsS3 extends Plugin { this.defaultLocale = { strings: { - timedOut: 'Upload stalled for %{seconds} seconds, aborting.' - } + timedOut: 'Upload stalled for %{seconds} seconds, aborting.', + }, } const defaultOptions = { - timeout: 30 * 1000, - limit: 0, - metaFields: [], // have to opt in - getUploadParameters: this.getUploadParameters.bind(this) + timeout : 30 * 1000, + limit : 0, + metaFields : [], // have to opt in + getUploadParameters: this.getUploadParameters.bind(this), } this.opts = { ...defaultOptions, ...opts } @@ -132,9 +132,9 @@ module.exports = class AwsS3 extends Plugin { } validateParameters (file, params) { - const valid = typeof params === 'object' && params && - typeof params.url === 'string' && - (typeof params.fields === 'object' || params.fields == null) + const valid = typeof params === 'object' && params + && typeof params.url === 'string' + && (typeof params.fields === 'object' || params.fields == null) if (!valid) { const err = new TypeError(`AwsS3: got incorrect result from 'getUploadParameters()' for file '${file.name}', expected an object '{ url, method, fields, headers }' but got '${JSON.stringify(params)}' instead.\nSee https://uppy.io/docs/aws-s3/#getUploadParameters-file for more on the expected format.`) @@ -173,9 +173,7 @@ module.exports = class AwsS3 extends Plugin { this.uppy.emit('upload-started', file) }) - const getUploadParameters = this.requests.wrapPromiseFunction((file) => { - return this.opts.getUploadParameters(file) - }) + const getUploadParameters = this.requests.wrapPromiseFunction((file) => this.opts.getUploadParameters(file)) const numberOfFiles = fileIDs.length @@ -191,13 +189,13 @@ module.exports = class AwsS3 extends Plugin { method = 'post', url, fields, - headers + headers, } = params const xhrOpts = { method, - formData: method.toLowerCase() === 'post', - endpoint: url, - metaFields: fields ? Object.keys(fields) : [] + formData : method.toLowerCase() === 'post', + endpoint : url, + metaFields: fields ? Object.keys(fields) : [], } if (headers) { @@ -205,8 +203,8 @@ module.exports = class AwsS3 extends Plugin { } this.uppy.setFileState(file.id, { - meta: { ...file.meta, ...fields }, - xhrUpload: xhrOpts + meta : { ...file.meta, ...fields }, + xhrUpload: xhrOpts, }) return this._uploader.uploadFile(file.id, index, numberOfFiles) @@ -260,9 +258,9 @@ module.exports = class AwsS3 extends Plugin { // Some S3 alternatives do not reply with an absolute URL. // Eg DigitalOcean Spaces uses /$bucketName/xyz location: resolveUrl(xhr.responseURL, getXmlValue(content, 'Location')), - bucket: getXmlValue(content, 'Bucket'), - key: getXmlValue(content, 'Key'), - etag: getXmlValue(content, 'ETag') + bucket : getXmlValue(content, 'Bucket'), + key : getXmlValue(content, 'Key'), + etag : getXmlValue(content, 'ETag'), } } @@ -279,14 +277,14 @@ module.exports = class AwsS3 extends Plugin { } const xhrOptions = { - fieldName: 'file', + fieldName : 'file', responseUrlFieldName: 'location', - timeout: this.opts.timeout, + timeout : this.opts.timeout, // Share the rate limiting queue with XHRUpload. - __queue: this.requests, - responseType: 'text', - getResponseData: this.opts.getResponseData || defaultGetResponseData, - getResponseError: defaultGetResponseError + __queue : this.requests, + responseType : 'text', + getResponseData : this.opts.getResponseData || defaultGetResponseData, + getResponseError : defaultGetResponseError, } // Only for MiniXHRUpload, remove once we can depend on XHRUpload directly again diff --git a/packages/@uppy/aws-s3/src/index.test.js b/packages/@uppy/aws-s3/src/index.test.js index 22f2094a1..15e260b7f 100644 --- a/packages/@uppy/aws-s3/src/index.test.js +++ b/packages/@uppy/aws-s3/src/index.test.js @@ -1,6 +1,6 @@ require('whatwg-fetch') const Core = require('@uppy/core') -const AwsS3 = require('./') +const AwsS3 = require('.') describe('AwsS3', () => { it('Registers AwsS3 upload plugin', () => { @@ -27,8 +27,8 @@ describe('AwsS3', () => { const file = { meta: { name: 'foo.jpg', - type: 'image/jpg' - } + type: 'image/jpg', + }, } expect(() => awsS3.opts.getUploadParameters(file)).not.toThrow() diff --git a/packages/@uppy/aws-s3/src/isXml.test.js b/packages/@uppy/aws-s3/src/isXml.test.js index 49234c525..262049bae 100644 --- a/packages/@uppy/aws-s3/src/isXml.test.js +++ b/packages/@uppy/aws-s3/src/isXml.test.js @@ -5,59 +5,59 @@ describe('AwsS3', () => { it('returns true for XML documents', () => { const content = 'image.jpg' expect(isXml(content, { - getResponseHeader: () => 'application/xml' + getResponseHeader: () => 'application/xml', })).toEqual(true) expect(isXml(content, { - getResponseHeader: () => 'text/xml' + getResponseHeader: () => 'text/xml', })).toEqual(true) expect(isXml(content, { - getResponseHeader: () => 'text/xml; charset=utf-8' + getResponseHeader: () => 'text/xml; charset=utf-8', })).toEqual(true) expect(isXml(content, { - getResponseHeader: () => 'application/xml; charset=iso-8859-1' + getResponseHeader: () => 'application/xml; charset=iso-8859-1', })).toEqual(true) }) it('returns true for GCS XML documents', () => { const content = 'image.jpg' expect(isXml(content, { - getResponseHeader: () => 'text/html' + getResponseHeader: () => 'text/html', })).toEqual(true) expect(isXml(content, { - getResponseHeader: () => 'text/html; charset=utf8' + getResponseHeader: () => 'text/html; charset=utf8', })).toEqual(true) }) it('returns true for remote response objects', () => { const content = 'image.jpg' expect(isXml(content, { - headers: { 'content-type': 'application/xml' } + headers: { 'content-type': 'application/xml' }, })).toEqual(true) expect(isXml(content, { - headers: { 'content-type': 'application/xml' } + headers: { 'content-type': 'application/xml' }, })).toEqual(true) expect(isXml(content, { - headers: { 'content-type': 'text/html' } + headers: { 'content-type': 'text/html' }, })).toEqual(true) }) it('returns false when content-type is missing', () => { const content = 'image.jpg' expect(isXml(content, { - getResponseHeader: () => null + getResponseHeader: () => null, })).toEqual(false) expect(isXml(content, { - headers: { 'content-type': null } + headers: { 'content-type': null }, })).toEqual(false) expect(isXml(content, { - headers: {} + headers: {}, })).toEqual(false) }) it('returns false for HTML documents', () => { const content = '' expect(isXml(content, { - getResponseHeader: () => 'text/html' + getResponseHeader: () => 'text/html', })).toEqual(false) }) }) diff --git a/packages/@uppy/box/src/index.js b/packages/@uppy/box/src/index.js index 2ebfa7508..fd5a10906 100644 --- a/packages/@uppy/box/src/index.js +++ b/packages/@uppy/box/src/index.js @@ -24,10 +24,10 @@ module.exports = class Box extends Plugin { ) this.provider = new Provider(uppy, { - companionUrl: this.opts.companionUrl, + companionUrl : this.opts.companionUrl, companionHeaders: this.opts.companionHeaders || this.opts.serverHeaders, - provider: 'box', - pluginId: this.id + provider : 'box', + pluginId : this.id, }) this.onFirstRender = this.onFirstRender.bind(this) @@ -36,7 +36,7 @@ module.exports = class Box extends Plugin { install () { this.view = new ProviderViews(this, { - provider: this.provider + provider: this.provider, }) const target = this.opts.target diff --git a/packages/@uppy/companion-client/src/AuthError.js b/packages/@uppy/companion-client/src/AuthError.js index e0c02e230..84ae368c8 100644 --- a/packages/@uppy/companion-client/src/AuthError.js +++ b/packages/@uppy/companion-client/src/AuthError.js @@ -1,5 +1,3 @@ -'use strict' - class AuthError extends Error { constructor () { super('Authorization required') diff --git a/packages/@uppy/companion-client/src/Provider.js b/packages/@uppy/companion-client/src/Provider.js index 761c172fb..6aabdd997 100644 --- a/packages/@uppy/companion-client/src/Provider.js +++ b/packages/@uppy/companion-client/src/Provider.js @@ -1,12 +1,8 @@ -'use strict' - const qsStringify = require('qs-stringify') const RequestClient = require('./RequestClient') const tokenStorage = require('./tokenStorage') -const _getName = (id) => { - return id.split('-').map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(' ') -} +const _getName = (id) => id.split('-').map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(' ') module.exports = class Provider extends RequestClient { constructor (uppy, opts) { @@ -30,10 +26,10 @@ module.exports = class Provider extends RequestClient { if (this.companionKeysParams) { authHeaders['uppy-credentials-params'] = btoa( - JSON.stringify({ params: this.companionKeysParams }) + JSON.stringify({ params: this.companionKeysParams }), ) } - return Object.assign({}, headers, authHeaders) + return { ...headers, ...authHeaders } }) } @@ -90,7 +86,7 @@ module.exports = class Provider extends RequestClient { return this.get(`${this.id}/logout`) .then((response) => Promise.all([ response, - this.uppy.getPlugin(this.pluginId).storage.removeItem(this.tokenKey) + this.uppy.getPlugin(this.pluginId).storage.removeItem(this.tokenKey), ])).then(([response]) => response) } @@ -98,7 +94,7 @@ module.exports = class Provider extends RequestClient { plugin.type = 'acquirer' plugin.files = [] if (defaultOpts) { - plugin.opts = Object.assign({}, defaultOpts, opts) + plugin.opts = { ...defaultOpts, ...opts } } if (opts.serverUrl || opts.serverPattern) { diff --git a/packages/@uppy/companion-client/src/RequestClient.js b/packages/@uppy/companion-client/src/RequestClient.js index b70a5ac81..32973cd04 100644 --- a/packages/@uppy/companion-client/src/RequestClient.js +++ b/packages/@uppy/companion-client/src/RequestClient.js @@ -1,5 +1,3 @@ -'use strict' - const AuthError = require('./AuthError') const fetchWithNetworkError = require('@uppy/utils/lib/fetchWithNetworkError') @@ -27,9 +25,9 @@ module.exports = class RequestClient { get defaultHeaders () { return { - Accept: 'application/json', - 'Content-Type': 'application/json', - 'Uppy-Versions': `@uppy/companion-client=${RequestClient.VERSION}` + Accept : 'application/json', + 'Content-Type' : 'application/json', + 'Uppy-Versions': `@uppy/companion-client=${RequestClient.VERSION}`, } } @@ -37,7 +35,7 @@ module.exports = class RequestClient { const userHeaders = this.opts.companionHeaders || this.opts.serverHeaders || {} return Promise.resolve({ ...this.defaultHeaders, - ...userHeaders + ...userHeaders, }) } @@ -59,9 +57,7 @@ module.exports = class RequestClient { // 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({ - companion: Object.assign({}, companion, { - [host]: headers.get('i-am') - }) + companion: { ...companion, [host]: headers.get('i-am') }, }) } return response @@ -97,7 +93,7 @@ module.exports = class RequestClient { } return fetch(this._getUrl(path), { - method: 'OPTIONS' + method: 'OPTIONS', }) .then((response) => { if (response.headers.has('access-control-allow-headers')) { @@ -133,9 +129,9 @@ module.exports = class RequestClient { return this.preflightAndHeaders(path) .then((headers) => fetchWithNetworkError(this._getUrl(path), { - method: 'get', - headers: headers, - credentials: this.opts.companionCookiesRule || 'same-origin' + method : 'get', + headers, + credentials: this.opts.companionCookiesRule || 'same-origin', })) .then(this._getPostResponseFunc(skipPostResponse)) .then((res) => this._json(res)) @@ -149,10 +145,10 @@ module.exports = class RequestClient { return this.preflightAndHeaders(path) .then((headers) => fetchWithNetworkError(this._getUrl(path), { - method: 'post', - headers: headers, + method : 'post', + headers, credentials: this.opts.companionCookiesRule || 'same-origin', - body: JSON.stringify(data) + body : JSON.stringify(data), })) .then(this._getPostResponseFunc(skipPostResponse)) .then((res) => this._json(res)) @@ -166,10 +162,10 @@ module.exports = class RequestClient { return this.preflightAndHeaders(path) .then((headers) => fetchWithNetworkError(`${this.hostname}/${path}`, { - method: 'delete', - headers: headers, + method : 'delete', + headers, credentials: this.opts.companionCookiesRule || 'same-origin', - body: data ? JSON.stringify(data) : null + body : data ? JSON.stringify(data) : null, })) .then(this._getPostResponseFunc(skipPostResponse)) .then((res) => this._json(res)) diff --git a/packages/@uppy/companion-client/src/SearchProvider.js b/packages/@uppy/companion-client/src/SearchProvider.js index 1b2b5704f..8b9bee682 100644 --- a/packages/@uppy/companion-client/src/SearchProvider.js +++ b/packages/@uppy/companion-client/src/SearchProvider.js @@ -1,10 +1,6 @@ -'use strict' - const RequestClient = require('./RequestClient') -const _getName = (id) => { - return id.split('-').map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(' ') -} +const _getName = (id) => id.split('-').map((s) => s.charAt(0).toUpperCase() + s.slice(1)).join(' ') module.exports = class SearchProvider extends RequestClient { constructor (uppy, opts) { diff --git a/packages/@uppy/companion-client/src/Socket.js b/packages/@uppy/companion-client/src/Socket.js index 435af084b..a289eb794 100644 --- a/packages/@uppy/companion-client/src/Socket.js +++ b/packages/@uppy/companion-client/src/Socket.js @@ -56,7 +56,7 @@ module.exports = class UppySocket { this.socket.send(JSON.stringify({ action, - payload + payload, })) } diff --git a/packages/@uppy/companion-client/src/Socket.test.js b/packages/@uppy/companion-client/src/Socket.test.js index 8fbda486d..c7527f6c5 100644 --- a/packages/@uppy/companion-client/src/Socket.test.js +++ b/packages/@uppy/companion-client/src/Socket.test.js @@ -40,8 +40,8 @@ describe('Socket', () => { expect(UppySocket.name).toEqual('UppySocket') expect( new UppySocket({ - target: 'foo' - }) instanceof UppySocket + target: 'foo', + }) instanceof UppySocket, ) }) @@ -58,7 +58,7 @@ describe('Socket', () => { uppySocket.send('bar', 'boo') expect(webSocketSendSpy.mock.calls.length).toEqual(1) expect(webSocketSendSpy.mock.calls[0]).toEqual([ - JSON.stringify({ action: 'bar', payload: 'boo' }) + JSON.stringify({ action: 'bar', payload: 'boo' }), ]) }) @@ -78,7 +78,7 @@ describe('Socket', () => { uppySocket.send('moo', 'baa') expect(uppySocket._queued).toEqual([ { action: 'bar', payload: 'boo' }, - { action: 'moo', payload: 'baa' } + { action: 'moo', payload: 'baa' }, ]) expect(webSocketSendSpy.mock.calls.length).toEqual(0) @@ -87,10 +87,10 @@ describe('Socket', () => { expect(uppySocket._queued).toEqual([]) expect(webSocketSendSpy.mock.calls.length).toEqual(2) expect(webSocketSendSpy.mock.calls[0]).toEqual([ - JSON.stringify({ action: 'bar', payload: 'boo' }) + JSON.stringify({ action: 'bar', payload: 'boo' }), ]) expect(webSocketSendSpy.mock.calls[1]).toEqual([ - JSON.stringify({ action: 'moo', payload: 'baa' }) + JSON.stringify({ action: 'moo', payload: 'baa' }), ]) }) @@ -124,10 +124,10 @@ describe('Socket', () => { webSocketInstance.triggerOpen() webSocketInstance.onmessage({ - data: JSON.stringify({ action: 'hi', payload: 'ho' }) + data: JSON.stringify({ action: 'hi', payload: 'ho' }), }) expect(emitterListenerMock.mock.calls).toEqual([ - ['ho', undefined, undefined, undefined, undefined, undefined] + ['ho', undefined, undefined, undefined, undefined, undefined], ]) }) @@ -150,8 +150,8 @@ describe('Socket', () => { undefined, undefined, undefined, - undefined - ] + undefined, + ], ]) }) @@ -167,7 +167,7 @@ describe('Socket', () => { expect(emitterListenerMock.mock.calls.length).toEqual(1) expect(emitterListenerMock.mock.calls).toEqual([ - ['ho', undefined, undefined, undefined, undefined, undefined] + ['ho', undefined, undefined, undefined, undefined, undefined], ]) }) }) diff --git a/packages/@uppy/companion-client/src/index.js b/packages/@uppy/companion-client/src/index.js index 5c12c3e5a..fde345837 100644 --- a/packages/@uppy/companion-client/src/index.js +++ b/packages/@uppy/companion-client/src/index.js @@ -1,5 +1,3 @@ -'use strict' - /** * Manages communications with Companion */ @@ -13,5 +11,5 @@ module.exports = { RequestClient, Provider, SearchProvider, - Socket + Socket, } diff --git a/packages/@uppy/companion-client/src/tokenStorage.js b/packages/@uppy/companion-client/src/tokenStorage.js index 6baebf6e6..a64d649f7 100644 --- a/packages/@uppy/companion-client/src/tokenStorage.js +++ b/packages/@uppy/companion-client/src/tokenStorage.js @@ -1,22 +1,14 @@ -'use strict' - /** * This module serves as an Async wrapper for LocalStorage */ -module.exports.setItem = (key, value) => { - return new Promise((resolve) => { - localStorage.setItem(key, value) - resolve() - }) -} +module.exports.setItem = (key, value) => new Promise((resolve) => { + localStorage.setItem(key, value) + resolve() +}) -module.exports.getItem = (key) => { - return Promise.resolve(localStorage.getItem(key)) -} +module.exports.getItem = (key) => Promise.resolve(localStorage.getItem(key)) -module.exports.removeItem = (key) => { - return new Promise((resolve) => { - localStorage.removeItem(key) - resolve() - }) -} +module.exports.removeItem = (key) => new Promise((resolve) => { + localStorage.removeItem(key) + resolve() +}) diff --git a/packages/@uppy/core/src/Plugin.js b/packages/@uppy/core/src/Plugin.js index 80ee97262..3dc077ae5 100644 --- a/packages/@uppy/core/src/Plugin.js +++ b/packages/@uppy/core/src/Plugin.js @@ -56,9 +56,9 @@ module.exports = class Plugin { ...plugins, [this.id]: { ...plugins[this.id], - ...update - } - } + ...update, + }, + }, }) } @@ -161,15 +161,15 @@ module.exports = class Plugin { let message = `Invalid target option given to ${callerPluginName}.` if (typeof target === 'function') { - message += ' The given target is not a Plugin class. ' + - 'Please check that you\'re not specifying a React Component instead of a plugin. ' + - 'If you are using @uppy/* packages directly, make sure you have only 1 version of @uppy/core installed: ' + - 'run `npm ls @uppy/core` on the command line and verify that all the versions match and are deduped correctly.' + message += ' The given target is not a Plugin class. ' + + 'Please check that you\'re not specifying a React Component instead of a plugin. ' + + 'If you are using @uppy/* packages directly, make sure you have only 1 version of @uppy/core installed: ' + + 'run `npm ls @uppy/core` on the command line and verify that all the versions match and are deduped correctly.' } else { - message += 'If you meant to target an HTML element, please make sure that the element exists. ' + - 'Check that the