mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
chore(ci): eslint + prettier → biome (#325)
This commit is contained in:
@@ -10,7 +10,7 @@ describe('uniqBy', () => {
|
||||
{ id: 'a', v: 3 },
|
||||
];
|
||||
|
||||
const result = uniqBy(arr, item => item.id);
|
||||
const result = uniqBy(arr, (item) => item.id);
|
||||
|
||||
expect(result).toEqual([
|
||||
{ id: 'b', v: 2 },
|
||||
@@ -19,14 +19,14 @@ describe('uniqBy', () => {
|
||||
});
|
||||
|
||||
it('returns empty array for empty input', () => {
|
||||
const result = uniqBy([], item => item);
|
||||
const result = uniqBy([], (item) => item);
|
||||
expect(result).toEqual([]);
|
||||
});
|
||||
|
||||
it('returns same array when no duplicates', () => {
|
||||
const arr = [{ id: 'a' }, { id: 'b' }, { id: 'c' }];
|
||||
|
||||
const result = uniqBy(arr, item => item.id);
|
||||
const result = uniqBy(arr, (item) => item.id);
|
||||
|
||||
expect(result).toEqual(arr);
|
||||
});
|
||||
@@ -34,7 +34,7 @@ describe('uniqBy', () => {
|
||||
it('works with primitive values', () => {
|
||||
const arr = [1, 2, 3, 2, 1];
|
||||
|
||||
const result = uniqBy(arr, item => item);
|
||||
const result = uniqBy(arr, (item) => item);
|
||||
|
||||
expect(result).toEqual([3, 2, 1]);
|
||||
});
|
||||
@@ -48,7 +48,7 @@ describe('uniqBy', () => {
|
||||
{ id: 'y', order: 5 },
|
||||
];
|
||||
|
||||
const result = uniqBy(arr, item => item.id);
|
||||
const result = uniqBy(arr, (item) => item.id);
|
||||
|
||||
expect(result).toEqual([
|
||||
{ id: 'z', order: 3 },
|
||||
|
||||
@@ -18,25 +18,25 @@ export interface OnEventOptions extends AddEventListenerOptions {
|
||||
export function onEvent<K extends keyof HTMLMediaElementEventMap>(
|
||||
target: HTMLMediaElement,
|
||||
type: K,
|
||||
options?: OnEventOptions,
|
||||
options?: OnEventOptions
|
||||
): Promise<HTMLMediaElementEventMap[K]>;
|
||||
|
||||
export function onEvent<K extends keyof HTMLElementEventMap>(
|
||||
target: HTMLElement,
|
||||
type: K,
|
||||
options?: OnEventOptions,
|
||||
options?: OnEventOptions
|
||||
): Promise<HTMLElementEventMap[K]>;
|
||||
|
||||
export function onEvent<K extends keyof WindowEventMap>(
|
||||
target: Window,
|
||||
type: K,
|
||||
options?: OnEventOptions,
|
||||
options?: OnEventOptions
|
||||
): Promise<WindowEventMap[K]>;
|
||||
|
||||
export function onEvent<K extends keyof DocumentEventMap>(
|
||||
target: Document,
|
||||
type: K,
|
||||
options?: OnEventOptions,
|
||||
options?: OnEventOptions
|
||||
): Promise<DocumentEventMap[K]>;
|
||||
|
||||
export function onEvent(target: EventTarget, type: string, options?: OnEventOptions): Promise<Event>;
|
||||
@@ -63,7 +63,7 @@ export function onEvent(target: EventTarget, type: string, options?: OnEventOpti
|
||||
options?.signal?.removeEventListener('abort', handleAbort);
|
||||
resolve(event);
|
||||
},
|
||||
{ ...options, once: true },
|
||||
{ ...options, once: true }
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export { animationFrame } from './animation-frame';
|
||||
export { onEvent, type OnEventOptions } from './event';
|
||||
export { type OnEventOptions, onEvent } from './event';
|
||||
export { idleCallback } from './idle-callback';
|
||||
export { listen } from './listen';
|
||||
export { isHTMLAudioElement, isHTMLMediaElement, isHTMLVideoElement } from './predicates';
|
||||
|
||||
@@ -11,42 +11,42 @@ export function listen<K extends keyof HTMLMediaElementEventMap>(
|
||||
target: HTMLMediaElement,
|
||||
type: K,
|
||||
listener: (event: HTMLMediaElementEventMap[K]) => void,
|
||||
options?: AddEventListenerOptions,
|
||||
options?: AddEventListenerOptions
|
||||
): () => void;
|
||||
|
||||
export function listen<K extends keyof HTMLElementEventMap>(
|
||||
target: HTMLElement,
|
||||
type: K,
|
||||
listener: (event: HTMLElementEventMap[K]) => void,
|
||||
options?: AddEventListenerOptions,
|
||||
options?: AddEventListenerOptions
|
||||
): () => void;
|
||||
|
||||
export function listen<K extends keyof WindowEventMap>(
|
||||
target: Window,
|
||||
type: K,
|
||||
listener: (event: WindowEventMap[K]) => void,
|
||||
options?: AddEventListenerOptions,
|
||||
options?: AddEventListenerOptions
|
||||
): () => void;
|
||||
|
||||
export function listen<K extends keyof DocumentEventMap>(
|
||||
target: Document,
|
||||
type: K,
|
||||
listener: (event: DocumentEventMap[K]) => void,
|
||||
options?: AddEventListenerOptions,
|
||||
options?: AddEventListenerOptions
|
||||
): () => void;
|
||||
|
||||
export function listen(
|
||||
target: EventTarget,
|
||||
type: string,
|
||||
listener: EventListenerOrEventListenerObject,
|
||||
options?: AddEventListenerOptions,
|
||||
options?: AddEventListenerOptions
|
||||
): () => void;
|
||||
|
||||
export function listen(
|
||||
target: EventTarget,
|
||||
type: string,
|
||||
listener: EventListenerOrEventListenerObject,
|
||||
options?: AddEventListenerOptions,
|
||||
options?: AddEventListenerOptions
|
||||
): () => void {
|
||||
target.addEventListener(type, listener, options);
|
||||
return () => target.removeEventListener(type, listener, options);
|
||||
|
||||
@@ -21,7 +21,7 @@ import type { Falsy } from '../types';
|
||||
export function getSlottedElement<T extends Element>(
|
||||
shadowRoot: ShadowRoot,
|
||||
slotName: string,
|
||||
predicate: (el: Element) => Falsy<T>,
|
||||
predicate: (el: Element) => Falsy<T>
|
||||
): T | null {
|
||||
const slot = querySlot(shadowRoot, slotName);
|
||||
if (!slot) return null;
|
||||
|
||||
@@ -97,7 +97,7 @@ describe('onEvent', () => {
|
||||
passive: true,
|
||||
capture: true,
|
||||
once: true,
|
||||
}),
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ describe('idleCallback', () => {
|
||||
expect.objectContaining({
|
||||
didTimeout: expect.any(Boolean),
|
||||
timeRemaining: expect.any(Function),
|
||||
}),
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ describe('getSlottedElement', () => {
|
||||
const video = document.createElement('video');
|
||||
host.appendChild(video);
|
||||
|
||||
const result = getSlottedElement(host.shadowRoot!, '', el => (el instanceof HTMLVideoElement ? el : null));
|
||||
const result = getSlottedElement(host.shadowRoot!, '', (el) => (el instanceof HTMLVideoElement ? el : null));
|
||||
|
||||
expect(result).toBe(video);
|
||||
});
|
||||
@@ -48,7 +48,7 @@ describe('getSlottedElement', () => {
|
||||
host.appendChild(video1);
|
||||
host.appendChild(video2);
|
||||
|
||||
const result = getSlottedElement(host.shadowRoot!, '', el => (el instanceof HTMLVideoElement ? el : null));
|
||||
const result = getSlottedElement(host.shadowRoot!, '', (el) => (el instanceof HTMLVideoElement ? el : null));
|
||||
|
||||
expect(result).toBe(video1);
|
||||
});
|
||||
@@ -58,7 +58,7 @@ describe('getSlottedElement', () => {
|
||||
const span = document.createElement('span');
|
||||
host.appendChild(span);
|
||||
|
||||
const result = getSlottedElement(host.shadowRoot!, '', el => (el instanceof HTMLVideoElement ? el : null));
|
||||
const result = getSlottedElement(host.shadowRoot!, '', (el) => (el instanceof HTMLVideoElement ? el : null));
|
||||
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
@@ -66,7 +66,7 @@ describe('getSlottedElement', () => {
|
||||
it('returns null when slot is empty', () => {
|
||||
const host = createHost();
|
||||
|
||||
const result = getSlottedElement(host.shadowRoot!, '', el => (el instanceof HTMLVideoElement ? el : null));
|
||||
const result = getSlottedElement(host.shadowRoot!, '', (el) => (el instanceof HTMLVideoElement ? el : null));
|
||||
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
@@ -76,7 +76,7 @@ describe('getSlottedElement', () => {
|
||||
const div = document.createElement('div');
|
||||
host.appendChild(div);
|
||||
|
||||
const result = getSlottedElement(host.shadowRoot!, '', el => (el instanceof HTMLVideoElement ? el : false));
|
||||
const result = getSlottedElement(host.shadowRoot!, '', (el) => (el instanceof HTMLVideoElement ? el : false));
|
||||
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
@@ -88,7 +88,7 @@ describe('getSlottedElement', () => {
|
||||
|
||||
const isMedia = (el: Element): el is HTMLMediaElement => el instanceof HTMLMediaElement;
|
||||
|
||||
const result = getSlottedElement(host.shadowRoot!, '', el => (isMedia(el) ? el : null));
|
||||
const result = getSlottedElement(host.shadowRoot!, '', (el) => (isMedia(el) ? el : null));
|
||||
|
||||
expect(result).toBe(video);
|
||||
expect(result?.play).toBeDefined();
|
||||
@@ -119,7 +119,7 @@ describe('getSlottedElement', () => {
|
||||
video.slot = 'media';
|
||||
host.appendChild(video);
|
||||
|
||||
const result = getSlottedElement(host.shadowRoot!, 'media', el => (el instanceof HTMLVideoElement ? el : null));
|
||||
const result = getSlottedElement(host.shadowRoot!, 'media', (el) => (el instanceof HTMLVideoElement ? el : null));
|
||||
|
||||
expect(result).toBe(video);
|
||||
});
|
||||
@@ -130,7 +130,7 @@ describe('getSlottedElement', () => {
|
||||
// No slot attribute - goes to default slot
|
||||
host.appendChild(video);
|
||||
|
||||
const result = getSlottedElement(host.shadowRoot!, 'media', el => (el instanceof HTMLVideoElement ? el : null));
|
||||
const result = getSlottedElement(host.shadowRoot!, 'media', (el) => (el instanceof HTMLVideoElement ? el : null));
|
||||
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
@@ -141,8 +141,9 @@ describe('getSlottedElement', () => {
|
||||
video.slot = 'nonexistent';
|
||||
host.appendChild(video);
|
||||
|
||||
const result = getSlottedElement(host.shadowRoot!, 'nonexistent', el =>
|
||||
el instanceof HTMLVideoElement ? el : null);
|
||||
const result = getSlottedElement(host.shadowRoot!, 'nonexistent', (el) =>
|
||||
el instanceof HTMLVideoElement ? el : null
|
||||
);
|
||||
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
@@ -167,7 +168,7 @@ describe('getSlottedElement', () => {
|
||||
const video = document.createElement('video');
|
||||
host.appendChild(video);
|
||||
|
||||
const result = getSlottedElement(host.shadowRoot!, '', el => (el instanceof HTMLVideoElement ? el : null));
|
||||
const result = getSlottedElement(host.shadowRoot!, '', (el) => (el instanceof HTMLVideoElement ? el : null));
|
||||
|
||||
expect(result).toBeNull();
|
||||
});
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint-disable ts/method-signature-style */
|
||||
// Method syntax is required here for TypeScript's class inheritance checking.
|
||||
// Using property syntax (e.g., `connectedCallback?: () => void`) causes TS2425
|
||||
// when a class extends a generic mixin that defines lifecycle callbacks.
|
||||
@@ -8,7 +7,6 @@ export interface CustomElementCallbacks {
|
||||
adoptedCallback?(): void;
|
||||
attributeChangedCallback?(name: string, oldValue: string | null, newValue: string | null): void;
|
||||
}
|
||||
/* eslint-enable ts/method-signature-style */
|
||||
|
||||
export interface CustomElement extends HTMLElement, CustomElementCallbacks {}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ export class Disposer {
|
||||
}
|
||||
|
||||
async disposeAsync(): Promise<void> {
|
||||
await Promise.all([...this.#cleanups].map(cleanup => cleanup()));
|
||||
await Promise.all([...this.#cleanups].map((cleanup) => cleanup()));
|
||||
this.#cleanups.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ describe('disposer', () => {
|
||||
results.push(1);
|
||||
});
|
||||
disposer.add(async () => {
|
||||
await new Promise(r => setTimeout(r, 10));
|
||||
await new Promise((r) => setTimeout(r, 10));
|
||||
results.push(2);
|
||||
});
|
||||
disposer.add(() => {
|
||||
|
||||
@@ -17,7 +17,7 @@ describe('event-like', () => {
|
||||
timeStamp: 123,
|
||||
isTrusted: true,
|
||||
target: null,
|
||||
}),
|
||||
})
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
@@ -18,6 +18,6 @@ export function composeCallbacks<T extends (...args: any[]) => void>(...fns: (T
|
||||
if (defined.length === 1) return defined[0];
|
||||
|
||||
return ((...args: Parameters<T>) => {
|
||||
defined.forEach(fn => fn(...args));
|
||||
defined.forEach((fn) => fn(...args));
|
||||
}) as T;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
export function tryCatch<T extends (...args: any[]) => unknown>(
|
||||
fn: T | undefined,
|
||||
onError: (error: unknown) => void = console.error,
|
||||
onError: (error: unknown) => void = console.error
|
||||
): T | undefined {
|
||||
if (!fn) return undefined;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ export function pick<T extends Record<string, unknown>, K extends keyof T>(obj:
|
||||
const result = {} as Pick<T, K>;
|
||||
|
||||
for (const key of keys) {
|
||||
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
||||
if (Object.hasOwn(obj, key)) {
|
||||
result[key] = obj[key];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,6 @@ describe('predicate', () => {
|
||||
describe('isPromise', () => {
|
||||
it('returns true for promises', () => {
|
||||
expect(isPromise(Promise.resolve())).toBe(true);
|
||||
// eslint-disable-next-line prefer-promise-reject-errors
|
||||
expect(isPromise(Promise.reject().catch(() => {}))).toBe(true);
|
||||
expect(isPromise(new Promise(() => {}))).toBe(true);
|
||||
});
|
||||
@@ -167,7 +166,6 @@ describe('predicate', () => {
|
||||
expect(isObject('string')).toBe(false);
|
||||
expect(isObject(123)).toBe(false);
|
||||
expect(isObject(true)).toBe(false);
|
||||
// eslint-disable-next-line symbol-description
|
||||
expect(isObject(Symbol())).toBe(false);
|
||||
});
|
||||
|
||||
@@ -204,7 +202,6 @@ describe('predicate', () => {
|
||||
expect(isPlainObject('string')).toBe(false);
|
||||
expect(isPlainObject(123)).toBe(false);
|
||||
expect(isPlainObject(true)).toBe(false);
|
||||
// eslint-disable-next-line symbol-description
|
||||
expect(isPlainObject(Symbol())).toBe(false);
|
||||
});
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ export type Constructor<T, Arguments extends unknown[] = any[]> = new (...args:
|
||||
|
||||
export type AbstractConstructor<T, Arguments extends unknown[] = any[]> = abstract new (...args: Arguments) => T;
|
||||
|
||||
export type AnyConstructor<T, Arguments extends unknown[] = any[]>
|
||||
= | Constructor<T, Arguments>
|
||||
| AbstractConstructor<T, Arguments>;
|
||||
export type AnyConstructor<T, Arguments extends unknown[] = any[]> =
|
||||
| Constructor<T, Arguments>
|
||||
| AbstractConstructor<T, Arguments>;
|
||||
|
||||
export type Mixin<Base, Result> = <T extends Constructor<Base>>(Base: T) => T & Constructor<Result>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user