Explorar o código

meta: fix linter warnings (#4039)

Antoine du Hamel %!s(int64=2) %!d(string=hai) anos
pai
achega
e0f17e3753

+ 0 - 31
examples/angular-example/src/app/app.component.spec.ts

@@ -1,31 +0,0 @@
-import { TestBed } from '@angular/core/testing'
-import { AppComponent } from './app.component'
-
-describe('AppComponent', () => {
-  beforeEach(async () => {
-    await TestBed.configureTestingModule({
-      declarations: [
-        AppComponent,
-      ],
-    }).compileComponents()
-  })
-
-  it('should create the app', () => {
-    const fixture = TestBed.createComponent(AppComponent)
-    const app = fixture.componentInstance
-    expect(app).toBeTruthy()
-  })
-
-  it(`should have as title 'angular-example'`, () => {
-    const fixture = TestBed.createComponent(AppComponent)
-    const app = fixture.componentInstance
-    expect(app.title).toEqual('angular-example')
-  })
-
-  it('should render title', () => {
-    const fixture = TestBed.createComponent(AppComponent)
-    fixture.detectChanges()
-    const compiled = fixture.nativeElement as HTMLElement
-    expect(compiled.querySelector('.content span')?.textContent).toContain('angular-example app is running!')
-  })
-})

+ 2 - 0
examples/bundled/sw.js

@@ -62,5 +62,7 @@ self.addEventListener('message', (event) => {
     case 'uppy/GET_FILES':
       getFiles(event.data.store)
       break
+
+    default: throw new Error('unreachable')
   }
 })

+ 0 - 0
examples/react-native-expo/babel.config.js → examples/react-native-expo/babel.config.cjs


+ 1 - 0
examples/svelte-example/postcss.config.js

@@ -1,5 +1,6 @@
 module.exports = {
   plugins: [
+    // eslint-disable-next-line global-require
     require('postcss-import')(),
   ],
 }

+ 1 - 0
examples/svelte-example/rollup.config.js

@@ -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,

+ 21 - 20
examples/transloadit-markdown-bin/main.js

@@ -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.
  */
@@ -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()
 

+ 63 - 63
examples/transloadit/server.js

@@ -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>
@@ -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
@@ -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)

+ 6 - 5
examples/xhr-bundle/server.cjs

@@ -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)

+ 1 - 1
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'

+ 1 - 1
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'

+ 1 - 0
packages/@uppy/core/src/Uppy.js

@@ -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,

+ 1 - 1
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'

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

@@ -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) {

+ 21 - 20
website/src/examples/markdown-snippets/app.es6

@@ -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.
  */
@@ -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()