Skip to content

Commit

Permalink
Use method style
Browse files Browse the repository at this point in the history
  • Loading branch information
timowestnosto committed Nov 29, 2023
1 parent b3b1075 commit b8ca903
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@
"@typescript-eslint"
],
"rules": {
"@typescript-eslint/method-signature-style": ["error", "method"]
}
}
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface AutocompleteConfig<State> {
/**
* The function to use to render the dropdown
*/
render: (container: HTMLElement, state: State) => void | PromiseLike<void>
render(container: HTMLElement, state: State): void | PromiseLike<void>
/**
* Minimum length of the query before searching
*/
Expand All @@ -32,7 +32,7 @@ export interface AutocompleteConfig<State> {
/**
* The function to use to submit the search
*/
submit: (query: string) => unknown
submit(query: string): unknown
/**
* Enable history
*/
Expand Down
14 changes: 7 additions & 7 deletions src/utils/input.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import { findAll } from "./dom"

type Callbacks = {
onSubmit?: (value: string) => void
onInput?: (value: string) => void
onFocus?: (value: string) => void
onBlur?: (value: string) => void
onKeyDown?: (value: string, key: string) => void
onClick?: (value: string) => void
onSubmit?(value: string): void
onInput?(value: string): void
onFocus?(value: string): void
onBlur?(value: string): void
onKeyDown?(value: string, key: string): void
onClick?(value: string): void
}

export function bindInput(
selector: string | HTMLInputElement,
callbacks: Callbacks
): {
destroy: () => void
destroy(): void
} {
const target =
selector instanceof HTMLInputElement
Expand Down
4 changes: 2 additions & 2 deletions src/utils/limiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ type Callback<T> = () => PromiseLike<T>

interface Event<T> {
getPromise?: Callback<T>
resolve: (result?: T) => void
reject: (...args: unknown[]) => void
resolve(result?: T): void
reject(...args: unknown[]): void
number: number
}

Expand Down
5 changes: 4 additions & 1 deletion src/utils/promise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,10 @@ export class SimplePromise<T> implements PromiseLike<T> {

export const AnyPromise = "Promise" in window ? window.Promise : SimplePromise

export type Cancellable<T> = { promise: PromiseLike<T>; cancel: () => void }
export type Cancellable<T> = {
promise: PromiseLike<T>
cancel(): void
}

export class CancellableError extends Error {}

Expand Down

0 comments on commit b8ca903

Please sign in to comment.