Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 committed Dec 5, 2023
1 parent b43f9e9 commit 95629da
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand Down
2 changes: 0 additions & 2 deletions packages/@uppy/core/src/Restricter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
/* eslint-disable max-classes-per-file, class-methods-use-this */
// @ts-expect-error untyped
import prettierBytes from '@transloadit/prettier-bytes'

Check failure on line 2 in packages/@uppy/core/src/Restricter.ts

View workflow job for this annotation

GitHub Actions / Type tests

Could not find a declaration file for module '@transloadit/prettier-bytes'. '/home/runner/work/uppy/uppy/node_modules/@transloadit/prettier-bytes/prettierBytes.js' implicitly has an 'any' type.
// @ts-expect-error untyped
import match from 'mime-match'

Check failure on line 3 in packages/@uppy/core/src/Restricter.ts

View workflow job for this annotation

GitHub Actions / Type tests

Could not find a declaration file for module 'mime-match'. '/home/runner/work/uppy/uppy/node_modules/mime-match/index.js' implicitly has an 'any' type.
import Translator from '@uppy/utils/lib/Translator'
import type { Body, Meta, UppyFile } from '@uppy/utils/lib/UppyFile'
Expand Down
1 change: 1 addition & 0 deletions packages/@uppy/core/src/UIPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ class UIPlugin<
* This is the case with @uppy/react plugins, for example.
*/
render(state: Record<string, unknown>): ComponentChild {

Check warning on line 165 in packages/@uppy/core/src/UIPlugin.ts

View workflow job for this annotation

GitHub Actions / Lint JavaScript/TypeScript

'state' is defined but never used
// eslint-disable-line @typescript-eslint/no-unused-vars
throw new Error(
'Extend the render method to add your plugin to a DOM element',
)
Expand Down
3 changes: 3 additions & 0 deletions packages/@uppy/core/src/Uppy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand All @@ -2312,6 +2314,7 @@ describe('src/Core', () => {
strings: {
test: 'beep boop',
},
pluralize: () => 0,
},
})

Expand Down
11 changes: 5 additions & 6 deletions packages/@uppy/core/src/Uppy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/* global AggregateError */

import Translator from '@uppy/utils/lib/Translator'
// @ts-expect-error untyped
import ee from 'namespace-emitter'

Check failure on line 5 in packages/@uppy/core/src/Uppy.ts

View workflow job for this annotation

GitHub Actions / Type tests

Could not find a declaration file for module 'namespace-emitter'. '/home/runner/work/uppy/uppy/node_modules/namespace-emitter/index.js' implicitly has an 'any' type.
import { nanoid } from 'nanoid/non-secure'
import throttle from 'lodash/throttle.js'
Expand Down Expand Up @@ -327,7 +326,6 @@ export class Uppy<M extends Meta, B extends Body> {

// 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

Check failure on line 329 in packages/@uppy/core/src/Uppy.ts

View workflow job for this annotation

GitHub Actions / Type tests

Element implicitly has an 'any' type because index expression is not of type 'number'.
}

Expand Down Expand Up @@ -1623,7 +1621,9 @@ export class Uppy<M extends Meta, B extends Body> {
return undefined
}

[Symbol.for('uppy test: getPlugins')](type: string): UnknownPlugin<M, B>[] {
private [Symbol.for('uppy test: getPlugins')](
type: string,
): UnknownPlugin<M, B>[] {
return this.#plugins[type]
}

Expand Down Expand Up @@ -1798,9 +1798,8 @@ export class Uppy<M extends Meta, B extends Body> {
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 {

Check failure on line 1801 in packages/@uppy/core/src/Uppy.ts

View workflow job for this annotation

GitHub Actions / Type tests

Rest parameter 'args' implicitly has an 'any[]' type.
// @ts-expect-error https://github.com/microsoft/TypeScript/issues/47595
return this.#createUpload(...args)
}

Expand Down
10 changes: 5 additions & 5 deletions packages/@uppy/core/src/mocks/acquirerPlugin1.ts
Original file line number Diff line number Diff line change
@@ -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<any, any, any> {
constructor(uppy, opts) {

Check failure on line 5 in packages/@uppy/core/src/mocks/acquirerPlugin1.ts

View workflow job for this annotation

GitHub Actions / Type tests

Parameter 'uppy' implicitly has an 'any' type.

Check failure on line 5 in packages/@uppy/core/src/mocks/acquirerPlugin1.ts

View workflow job for this annotation

GitHub Actions / Type tests

Parameter 'opts' implicitly has an 'any' type.
super(uppy, opts)
this.type = 'acquirer'
this.id = 'TestSelector1'
Expand All @@ -15,7 +15,7 @@ export default class TestSelector1 extends UIPlugin {
}
}

run (results) {
run(results) {

Check failure on line 18 in packages/@uppy/core/src/mocks/acquirerPlugin1.ts

View workflow job for this annotation

GitHub Actions / Type tests

Parameter 'results' implicitly has an 'any' type.
this.uppy.log({
class: this.constructor.name,
method: 'run',
Expand All @@ -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()
}
}
10 changes: 5 additions & 5 deletions packages/@uppy/core/src/mocks/acquirerPlugin2.ts
Original file line number Diff line number Diff line change
@@ -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<any, any, any> {
constructor(uppy, opts) {
super(uppy, opts)
this.type = 'acquirer'
this.id = 'TestSelector2'
Expand All @@ -15,7 +15,7 @@ export default class TestSelector2 extends UIPlugin {
}
}

run (results) {
run(results) {
this.uppy.log({
class: this.constructor.name,
method: 'run',
Expand All @@ -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()
}
}
10 changes: 7 additions & 3 deletions packages/@uppy/core/src/mocks/invalidPluginWithoutId.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import UIPlugin from '../UIPlugin.ts'

export default class InvalidPluginWithoutName extends UIPlugin {
constructor (uppy, opts) {
export default class InvalidPluginWithoutName extends UIPlugin<any, any, any> {
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',
Expand Down
10 changes: 7 additions & 3 deletions packages/@uppy/core/src/mocks/invalidPluginWithoutType.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import UIPlugin from '../UIPlugin.ts'

export default class InvalidPluginWithoutType extends UIPlugin {
constructor (uppy, opts) {
export default class InvalidPluginWithoutType extends UIPlugin<any, any, any> {
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',
Expand Down

0 comments on commit 95629da

Please sign in to comment.