Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meta: fix linter warnings #4039

Merged
merged 1 commit into from Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 0 additions & 31 deletions examples/angular-example/src/app/app.component.spec.ts

This file was deleted.

2 changes: 2 additions & 0 deletions examples/bundled/sw.js
Expand Up @@ -62,5 +62,7 @@ self.addEventListener('message', (event) => {
case 'uppy/GET_FILES':
getFiles(event.data.store)
break

default: throw new Error('unreachable')
}
})
1 change: 1 addition & 0 deletions examples/svelte-example/postcss.config.js
@@ -1,5 +1,6 @@
module.exports = {
plugins: [
// eslint-disable-next-line global-require
require('postcss-import')(),
],
}
1 change: 1 addition & 0 deletions examples/svelte-example/rollup.config.js
Expand Up @@ -19,6 +19,7 @@ function serve () {
return {
writeBundle () {
if (server) return
// eslint-disable-next-line global-require
server = require('node:child_process').spawn('npm', ['run', 'serve', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true,
Expand Down
41 changes: 21 additions & 20 deletions examples/transloadit-markdown-bin/main.js
Expand Up @@ -14,6 +14,27 @@ import '@uppy/image-editor/dist/style.css'
const TRANSLOADIT_EXAMPLE_KEY = '35c1aed03f5011e982b6afe82599b6a0'
const TRANSLOADIT_EXAMPLE_TEMPLATE = '0b2ee2bc25dc43619700c2ce0a75164a'

function matchFilesAndThumbs (results) {
const filesById = {}
const thumbsById = {}

for (const [stepName, result] of Object.entries(results)) {
// eslint-disable-next-line no-shadow
result.forEach(result => {
if (stepName === 'thumbnails') {
thumbsById[result.original_id] = result
} else {
filesById[result.original_id] = result
}
})
}

return Object.keys(filesById).map((key) => ({
file: filesById[key],
thumb: thumbsById[key],
}))
}

/**
* A textarea for markdown text, with support for file attachments.
*/
Expand Down Expand Up @@ -144,26 +165,6 @@ function loadSnippets () {
}
}

function matchFilesAndThumbs (results) {
const filesById = {}
const thumbsById = {}

for (const [stepName, result] of Object.entries(results)) {
result.forEach(result => {
if (stepName === 'thumbnails') {
thumbsById[result.original_id] = result
} else {
filesById[result.original_id] = result
}
})
}

return Object.keys(filesById).map((key) => ({
file: filesById[key],
thumb: thumbsById[key],
}))
}

document.querySelector('#new').addEventListener('submit', (event) => {
event.preventDefault()

Expand Down
126 changes: 63 additions & 63 deletions examples/transloadit/server.js
Expand Up @@ -7,43 +7,6 @@ import he from 'he'

const e = he.encode

/**
* A very haxxor server that outputs some of the data it receives in a POST form parameter.
*/

const server = http.createServer(onrequest)
server.listen(9967)

function onrequest (req, res) {
if (req.url !== '/test') {
res.writeHead(404, { 'content-type': 'text/html' })
res.end('404')
return
}

function onbody (body) {
const fields = qs.parse(body)
const result = JSON.parse(fields.uppyResult)
const assemblies = result[0].transloadit

res.setHeader('content-type', 'text/html')
res.write(Header())
res.write(FormFields(fields))
assemblies.forEach((assembly) => {
res.write(AssemblyResult(assembly))
})
res.end(Footer())
}

{
let body = ''
req.on('data', (chunk) => { body += chunk })
req.on('end', () => {
onbody(body)
})
}
}

function Header () {
return `
<!DOCTYPE html>
Expand Down Expand Up @@ -74,13 +37,6 @@ function Footer () {
}

function FormFields (fields) {
return `
<h1>Form Fields</h1>
<dl>
${Object.entries(fields).map(Field).join('\n')}
</dl>
`

function Field ([name, value]) {
if (name === 'transloadit') return ''
let isValueJSON = false
Expand Down Expand Up @@ -113,43 +69,87 @@ function FormFields (fields) {
</dd>
`
}
}

function AssemblyResult (assembly) {
return `
<h1>${e(assembly.assembly_id)} (${e(assembly.ok)})</h1>
${UploadsList(assembly.uploads)}
${ResultsList(assembly.results)}
`
<h1>Form Fields</h1>
<dl>
${Object.entries(fields).map(Field).join('\n')}
</dl>
`
}

function UploadsList (uploads) {
function Upload (upload) {
return `<li>${e(upload.name)}</li>`
}

return `
<ul>
${uploads.map(Upload).join('\n')}
</ul>
`

function Upload (upload) {
return `<li>${e(upload.name)}</li>`
}
}

function ResultsList (results) {
return Object.keys(results)
.map(ResultsSection)
.join('\n')
function Result (result) {
return `<li>${e(result.name)} <a href="${result.ssl_url}" target="_blank">View</a></li>`
}

function ResultsSection (stepName) {
return `
<h2>${e(stepName)}</h2>
<ul>
${results[stepName].map(Result).join('\n')}
</ul>
<h2>${e(stepName)}</h2>
<ul>
${results[stepName].map(Result).join('\n')}
</ul>
`
}

function Result (result) {
return `<li>${e(result.name)} <a href="${result.ssl_url}" target="_blank">View</a></li>`
return Object.keys(results)
.map(ResultsSection)
.join('\n')
}

function AssemblyResult (assembly) {
return `
<h1>${e(assembly.assembly_id)} (${e(assembly.ok)})</h1>
${UploadsList(assembly.uploads)}
${ResultsList(assembly.results)}
`
}

function onrequest (req, res) {
if (req.url !== '/test') {
res.writeHead(404, { 'content-type': 'text/html' })
res.end('404')
return
}

function onbody (body) {
const fields = qs.parse(body)
const result = JSON.parse(fields.uppyResult)
const assemblies = result[0].transloadit

res.setHeader('content-type', 'text/html')
res.write(Header())
res.write(FormFields(fields))
assemblies.forEach((assembly) => {
res.write(AssemblyResult(assembly))
})
res.end(Footer())
}

{
let body = ''
req.on('data', (chunk) => { body += chunk })
req.on('end', () => {
onbody(body)
})
}
}

/**
* A very haxxor server that outputs some of the data it receives in a POST form parameter.
*/

const server = http.createServer(onrequest)
server.listen(9967)
11 changes: 6 additions & 5 deletions examples/xhr-bundle/server.cjs
Expand Up @@ -6,16 +6,17 @@ const upload = multer({
storage: multer.memoryStorage(),
})

app.use(cors())
app.post('/upload', upload.array('files'), uploadRoute)

app.listen(9967)

function uploadRoute (req, res) {
res.json({
files: req.files.map((file) => {
// eslint-disable-next-line no-param-reassign
delete file.buffer
return file
}),
})
}

app.use(cors())
app.post('/upload', upload.array('files'), uploadRoute)

app.listen(9967)
2 changes: 1 addition & 1 deletion packages/@uppy/aws-s3-multipart/src/index.test.js
@@ -1,4 +1,4 @@
import { beforeEach, describe, expect, it, jest } from '@jest/globals'
import { afterEach, beforeEach, describe, expect, it, jest } from '@jest/globals'

import 'whatwg-fetch'
import nock from 'nock'
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/aws-s3/src/index.test.js
@@ -1,4 +1,4 @@
import { describe, expect, it } from '@jest/globals'
import { beforeEach, describe, expect, it } from '@jest/globals'
import 'whatwg-fetch'
import Core from '@uppy/core'
import AwsS3 from './index.js'
Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/core/src/Uppy.js
Expand Up @@ -438,6 +438,7 @@ class Uppy {
// If the actual File object is passed from input[type=file] or drag-drop,
// we normalize it to match Uppy file object
if (fileDescriptor instanceof File) {
// eslint-disable-next-line no-param-reassign
fileDescriptor = {
name: fileDescriptor.name,
type: fileDescriptor.type,
Expand Down
2 changes: 1 addition & 1 deletion packages/@uppy/remote-sources/src/index.test.js
@@ -1,4 +1,4 @@
import { describe, expect, it } from '@jest/globals'
import { afterAll, beforeAll, describe, expect, it } from '@jest/globals'
import resizeObserverPolyfill from 'resize-observer-polyfill'
import Core from '@uppy/core'
import Dashboard from '@uppy/dashboard'
Expand Down
3 changes: 1 addition & 2 deletions packages/@uppy/transloadit/src/Client.js
Expand Up @@ -21,8 +21,7 @@ export default class Client {
}

/**
* @param {RequestInfo | URL} input
* @param {RequestInit} init
* @param {[RequestInfo | URL, RequestInit]} args
* @returns {Promise<any>}
*/
#fetchJSON (...args) {
Expand Down
41 changes: 21 additions & 20 deletions website/src/examples/markdown-snippets/app.es6
Expand Up @@ -11,6 +11,27 @@ import ImageEditor from '@uppy/image-editor'
const TRANSLOADIT_EXAMPLE_KEY = '35c1aed03f5011e982b6afe82599b6a0'
const TRANSLOADIT_EXAMPLE_TEMPLATE = '0b2ee2bc25dc43619700c2ce0a75164a'

function matchFilesAndThumbs (results) {
const filesById = {}
const thumbsById = {}

for (const [stepName, result] of Object.entries(results)) {
// eslint-disable-next-line no-shadow
result.forEach(result => {
if (stepName === 'thumbnails') {
thumbsById[result.original_id] = result
} else {
filesById[result.original_id] = result
}
})
}

return Object.keys(filesById).map((key) => ({
file: filesById[key],
thumb: thumbsById[key],
}))
}

/**
* A textarea for markdown text, with support for file attachments.
*/
Expand Down Expand Up @@ -149,26 +170,6 @@ function loadSnippets () {
}
}

function matchFilesAndThumbs (results) {
const filesById = {}
const thumbsById = {}

for (const [stepName, result] of Object.entries(results)) {
result.forEach(result => {
if (stepName === 'thumbnails') {
thumbsById[result.original_id] = result
} else {
filesById[result.original_id] = result
}
})
}

return Object.keys(filesById).map((key) => ({
file: filesById[key],
thumb: thumbsById[key],
}))
}

document.querySelector('#new').addEventListener('submit', (event) => {
event.preventDefault()

Expand Down