diff --git a/.eslintrc.js b/.eslintrc.js index df44d24e580..6110795d319 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -469,7 +469,7 @@ module.exports = { }, { files: ['packages/@uppy/*/src/**/*.ts', 'packages/@uppy/*/src/**/*.tsx'], - excludedFiles: ['packages/@uppy/**/*.test.ts'], + excludedFiles: ['packages/@uppy/**/*.test.ts', 'packages/@uppy/core/src/mocks/*.ts'], rules: { '@typescript-eslint/explicit-function-return-type': 'error', }, diff --git a/packages/@uppy/core/src/Restricter.ts b/packages/@uppy/core/src/Restricter.ts index 07eafd64458..3d75cd741b0 100644 --- a/packages/@uppy/core/src/Restricter.ts +++ b/packages/@uppy/core/src/Restricter.ts @@ -1,7 +1,5 @@ /* eslint-disable max-classes-per-file, class-methods-use-this */ -// @ts-expect-error untyped import prettierBytes from '@transloadit/prettier-bytes' -// @ts-expect-error untyped import match from 'mime-match' import Translator from '@uppy/utils/lib/Translator' import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile' diff --git a/packages/@uppy/core/src/UIPlugin.ts b/packages/@uppy/core/src/UIPlugin.ts index d7f0a5fe44c..338d8ecfc38 100644 --- a/packages/@uppy/core/src/UIPlugin.ts +++ b/packages/@uppy/core/src/UIPlugin.ts @@ -163,6 +163,7 @@ class UIPlugin< * This is the case with @uppy/react plugins, for example. */ render(state: Record): ComponentChild { + // eslint-disable-line @typescript-eslint/no-unused-vars throw new Error( 'Extend the render method to add your plugin to a DOM element', ) diff --git a/packages/@uppy/core/src/Uppy.test.ts b/packages/@uppy/core/src/Uppy.test.ts index c8571b9bd25..f9bbb6b0775 100644 --- a/packages/@uppy/core/src/Uppy.test.ts +++ b/packages/@uppy/core/src/Uppy.test.ts @@ -2291,6 +2291,8 @@ describe('src/Core', () => { data: new File([sampleImage], { type: 'image/jpeg' }), }) + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore accessing private field core[Symbol.for('uppy test: createUpload')]( Object.keys(core.getState().files), ) @@ -2312,6 +2314,7 @@ describe('src/Core', () => { strings: { test: 'beep boop', }, + pluralize: () => 0, }, }) diff --git a/packages/@uppy/core/src/Uppy.ts b/packages/@uppy/core/src/Uppy.ts index 29785d7d8b4..a84a577e867 100644 --- a/packages/@uppy/core/src/Uppy.ts +++ b/packages/@uppy/core/src/Uppy.ts @@ -2,7 +2,6 @@ /* global AggregateError */ import Translator from '@uppy/utils/lib/Translator' -// @ts-expect-error untyped import ee from 'namespace-emitter' import { nanoid } from 'nanoid/non-secure' import throttle from 'lodash/throttle.js' @@ -327,7 +326,6 @@ export class Uppy { // Exposing uppy object on window for debugging and testing if (this.opts.debug && typeof window !== 'undefined') { - // @ts-expect-error string as index type is fine window[this.opts.id] = this } @@ -1623,7 +1621,9 @@ export class Uppy { return undefined } - [Symbol.for('uppy test: getPlugins')](type: string): UnknownPlugin[] { + private [Symbol.for('uppy test: getPlugins')]( + type: string, + ): UnknownPlugin[] { return this.#plugins[type] } @@ -1798,9 +1798,8 @@ export class Uppy { return uploadID } - // @ts-expect-error same type as createUpload - [Symbol.for('uppy test: createUpload')](...args): string { - // @ts-expect-error same type as createUpload + private [Symbol.for('uppy test: createUpload')](...args): string { + // @ts-expect-error https://github.com/microsoft/TypeScript/issues/47595 return this.#createUpload(...args) } diff --git a/packages/@uppy/core/src/mocks/acquirerPlugin1.ts b/packages/@uppy/core/src/mocks/acquirerPlugin1.ts index 5b08d2b1adf..5fc46ba2f36 100644 --- a/packages/@uppy/core/src/mocks/acquirerPlugin1.ts +++ b/packages/@uppy/core/src/mocks/acquirerPlugin1.ts @@ -1,8 +1,8 @@ import { vi } from 'vitest' // eslint-disable-line import/no-extraneous-dependencies import UIPlugin from '../UIPlugin.ts' -export default class TestSelector1 extends UIPlugin { - constructor (uppy, opts) { +export default class TestSelector1 extends UIPlugin { + constructor(uppy, opts) { super(uppy, opts) this.type = 'acquirer' this.id = 'TestSelector1' @@ -15,7 +15,7 @@ export default class TestSelector1 extends UIPlugin { } } - run (results) { + run(results) { this.uppy.log({ class: this.constructor.name, method: 'run', @@ -25,11 +25,11 @@ export default class TestSelector1 extends UIPlugin { return Promise.resolve('success') } - update (state) { + update(state) { this.mocks.update(state) } - uninstall () { + uninstall() { this.mocks.uninstall() } } diff --git a/packages/@uppy/core/src/mocks/acquirerPlugin2.ts b/packages/@uppy/core/src/mocks/acquirerPlugin2.ts index 42da1f378c9..15e499c0bd1 100644 --- a/packages/@uppy/core/src/mocks/acquirerPlugin2.ts +++ b/packages/@uppy/core/src/mocks/acquirerPlugin2.ts @@ -1,8 +1,8 @@ import { vi } from 'vitest' // eslint-disable-line import/no-extraneous-dependencies import UIPlugin from '../UIPlugin.ts' -export default class TestSelector2 extends UIPlugin { - constructor (uppy, opts) { +export default class TestSelector2 extends UIPlugin { + constructor(uppy, opts) { super(uppy, opts) this.type = 'acquirer' this.id = 'TestSelector2' @@ -15,7 +15,7 @@ export default class TestSelector2 extends UIPlugin { } } - run (results) { + run(results) { this.uppy.log({ class: this.constructor.name, method: 'run', @@ -25,11 +25,11 @@ export default class TestSelector2 extends UIPlugin { return Promise.resolve('success') } - update (state) { + update(state) { this.mocks.update(state) } - uninstall () { + uninstall() { this.mocks.uninstall() } } diff --git a/packages/@uppy/core/src/mocks/invalidPluginWithoutId.ts b/packages/@uppy/core/src/mocks/invalidPluginWithoutId.ts index 6d4fcf3dde8..93fe3e4cc74 100644 --- a/packages/@uppy/core/src/mocks/invalidPluginWithoutId.ts +++ b/packages/@uppy/core/src/mocks/invalidPluginWithoutId.ts @@ -1,13 +1,17 @@ import UIPlugin from '../UIPlugin.ts' -export default class InvalidPluginWithoutName extends UIPlugin { - constructor (uppy, opts) { +export default class InvalidPluginWithoutName extends UIPlugin { + public type: string + + public name: string + + constructor(uppy, opts) { super(uppy, opts) this.type = 'acquirer' this.name = this.constructor.name } - run (results) { + run(results) { this.uppy.log({ class: this.constructor.name, method: 'run', diff --git a/packages/@uppy/core/src/mocks/invalidPluginWithoutType.ts b/packages/@uppy/core/src/mocks/invalidPluginWithoutType.ts index 2a2cbfaa248..96ebad2c8cc 100644 --- a/packages/@uppy/core/src/mocks/invalidPluginWithoutType.ts +++ b/packages/@uppy/core/src/mocks/invalidPluginWithoutType.ts @@ -1,13 +1,17 @@ import UIPlugin from '../UIPlugin.ts' -export default class InvalidPluginWithoutType extends UIPlugin { - constructor (uppy, opts) { +export default class InvalidPluginWithoutType extends UIPlugin { + public id: string + + public name: string + + constructor(uppy, opts) { super(uppy, opts) this.id = 'InvalidPluginWithoutType' this.name = this.constructor.name } - run (results) { + run(results) { this.uppy.log({ class: this.constructor.name, method: 'run',