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: enable linter on website examples #3366

Merged
merged 1 commit into from Dec 13, 2021
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
9 changes: 9 additions & 0 deletions .eslintrc.js
Expand Up @@ -152,6 +152,15 @@ module.exports = {
'no-underscore-dangle': 'off',
},
},
{
files: [
'website/src/examples/*/*.es6',
],
rules: {
'import/no-extraneous-dependencies': 'off',
'no-console': 'off',
},
},
{
files: [
'*.test.js',
Expand Down
25 changes: 12 additions & 13 deletions website/src/examples/dragdrop/app.es6
Expand Up @@ -4,20 +4,19 @@ const ProgressBar = require('@uppy/progress-bar')
const Tus = require('@uppy/tus')

// Function for displaying uploaded files
const onUploadSuccess = (elForUploadedFiles) =>
(file, response) => {
const url = response.uploadURL
const fileName = file.name
const onUploadSuccess = (elForUploadedFiles) => (file, response) => {
const url = response.uploadURL
const fileName = file.name

const li = document.createElement('li')
const a = document.createElement('a')
a.href = url
a.target = '_blank'
a.appendChild(document.createTextNode(fileName))
li.appendChild(a)
const li = document.createElement('li')
const a = document.createElement('a')
a.href = url
a.target = '_blank'
a.appendChild(document.createTextNode(fileName))
li.appendChild(a)

document.querySelector(elForUploadedFiles).appendChild(li)
}
document.querySelector(elForUploadedFiles).appendChild(li)
}

const uppyOne = new Uppy({ debug: true, autoProceed: true })
uppyOne
Expand All @@ -34,6 +33,6 @@ uppyTwo
.on('upload-success', onUploadSuccess('.example-two .uploaded-files ol'))

const uploadBtn = document.querySelector('.example-two button.upload-button')
uploadBtn.addEventListener('click', function () {
uploadBtn.addEventListener('click', () => {
uppyTwo.upload()
})
51 changes: 25 additions & 26 deletions website/src/examples/markdown-snippets/app.es6
Expand Up @@ -30,7 +30,8 @@ class MarkdownTextarea {
this.uploadLine.classList.add('form-upload')

this.uploadLine.appendChild(
document.createTextNode('Tap here to upload an attachment'))
document.createTextNode('Tap here to upload an attachment'),
)
}

install () {
Expand Down Expand Up @@ -86,24 +87,6 @@ class MarkdownTextarea {
})
}

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

results.forEach((result) => {
if (result.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],
}))
}

uploadFiles (files) {
robodog.upload(files, {
waitForEncoding: true,
Expand All @@ -114,7 +97,7 @@ class MarkdownTextarea {
}).then((result) => {
if (result === null) return
this.insertAttachments(
this.matchFilesAndThumbs(result.results)
matchFilesAndThumbs(result.results),
)
}).catch((err) => {
console.error(err)
Expand All @@ -139,7 +122,7 @@ class MarkdownTextarea {
}).then((result) => {
if (result === null) return
this.insertAttachments(
this.matchFilesAndThumbs(result.results)
matchFilesAndThumbs(result.results),
)
}).catch((err) => {
console.error(err)
Expand Down Expand Up @@ -177,11 +160,29 @@ function loadSnippets () {
}
}

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

results.forEach((result) => {
if (result.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()

const title = event.target.querySelector('input[name="title"]').value ||
'Unnamed Snippet'
const title = event.target.elements['title'].value
|| 'Unnamed Snippet'
const text = textarea.element.value

saveSnippet(title, text)
Expand All @@ -191,6 +192,4 @@ document.querySelector('#new').addEventListener('submit', (event) => {
event.target.querySelector('textarea').value = ''
})

window.addEventListener('DOMContentLoaded', () => {
loadSnippets()
})
window.addEventListener('DOMContentLoaded', loadSnippets, { once: true })
4 changes: 2 additions & 2 deletions website/src/examples/statusbar/app.es6
Expand Up @@ -3,12 +3,12 @@ const FileInput = require('@uppy/file-input')
const StatusBar = require('@uppy/status-bar')
const Tus = require('@uppy/tus')

const uppyOne = new Uppy({debug: true, autoProceed: true})
const uppyOne = new Uppy({ debug: true, autoProceed: true })
uppyOne
.use(FileInput, { target: '.UppyInput', pretty: false })
.use(Tus, { endpoint: 'https://tusd.tusdemo.net/files/' })
.use(StatusBar, {
target: '.UppyInput-Progress',
hideUploadButton: true,
hideAfterFinish: false
hideAfterFinish: false,
})
40 changes: 20 additions & 20 deletions website/src/examples/transloadit/app.es6
Expand Up @@ -28,13 +28,13 @@ function initUppy (opts = {}) {
maxFileSize: 1024 * 1024 * 1024,
maxNumberOfFiles: 2,
minNumberOfFiles: 1,
allowedFileTypes
allowedFileTypes,
},
locale: {
strings: {
youCanOnlyUploadFileTypes: 'You can only upload images'
}
}
youCanOnlyUploadFileTypes: 'You can only upload images',
},
},
})

function getExpiration (future) {
Expand All @@ -49,7 +49,7 @@ function initUppy (opts = {}) {
let params = {
auth: {
key: window.TRANSLOADIT_API_KEY,
expires: hasSecret ? getExpiration(5 * 60 * 1000) : undefined
expires: hasSecret ? getExpiration(5 * 60 * 1000) : undefined,
},
// It's more secure to use a template_id and enable
// Signature Authentication
Expand All @@ -61,18 +61,18 @@ function initUppy (opts = {}) {
resize_strategy: 'fit',
text: [
{
text: `© ${(new Date).getFullYear()} Transloadit.com`,
text: `© ${(new Date()).getFullYear()} Transloadit.com`,
size: 12,
font: 'Ubuntu',
color: '#eeeeee',
valign: 'bottom',
align: 'right',
x_offset: 16,
y_offset: -10
}
]
}
}
y_offset: -10,
},
],
},
},
}

if (zoomMode) {
Expand All @@ -83,7 +83,7 @@ function initUppy (opts = {}) {
result: true,
ffmpeg_stack: 'v3.3.3',
preset: 'ipad-high',
resize_strategy: 'fillcrop'
resize_strategy: 'fillcrop',
},
watermarked: {
use: 'resized',
Expand All @@ -96,8 +96,8 @@ function initUppy (opts = {}) {
watermark_size: '25%',
watermark_url: 'https://demos.transloadit.com/inputs/transloadit-padded.png',
watermark_x_offset: -10,
watermark_y_offset: 10
}
watermark_y_offset: 10,
},
}
}

Expand All @@ -113,37 +113,37 @@ function initUppy (opts = {}) {
uppy
.use(Transloadit, {
getAssemblyOptions,
waitForEncoding: true
waitForEncoding: true,
})
.use(Dashboard, {
inline: true,
maxHeight: 400,
target: '#uppy-dashboard-container',
note: 'Images only, 1–2 files, up to 1 MB'
note: 'Images only, 1–2 files, up to 1 MB',
})
.use(Instagram, {
target: Dashboard,
companionUrl: 'https://api2.transloadit.com/companion',
companionAllowedHosts: Transloadit.COMPANION_PATTERN
companionAllowedHosts: Transloadit.COMPANION_PATTERN,
})
.use(Facebook, {
target: Dashboard,
companionUrl: COMPANION
companionUrl: COMPANION,
})
.use(Webcam, { target: Dashboard, modes: ['picture'] })

if (zoomMode) {
uppy.use(Zoom, {
target: Dashboard,
companionUrl: 'https://api2.transloadit.com/companion',
companionAllowedHosts: Transloadit.COMPANION_PATTERN
companionAllowedHosts: Transloadit.COMPANION_PATTERN,
})
}

uppy
.on('transloadit:result', (stepName, result) => {
const file = uppy.getFile(result.localId)
var resultContainer = document.createElement('div')
const resultContainer = document.createElement('div')
if (!zoomMode) {
resultContainer.innerHTML = `
<div>
Expand Down