Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/active-element/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe("makeActiveElementListener", () => {
dispatchFocusEvent();
expect(events).toBe(1);

const clear = makeActiveElementListener(e => events++);
const clear = makeActiveElementListener(_e => events++);
dispatchFocusEvent();
expect(events).toBe(2);

Expand Down
8 changes: 4 additions & 4 deletions packages/bounds/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,16 @@ export function createElementBounds(
);
if (isFn) {
createEffect(
() => (target as Accessor<Element | FalsyValue>)() || null,
() => target() || null,
el => {
if (el) ro.observe(el as Element);
if (el) ro.observe(el);
return () => {
if (el) ro.unobserve(el as Element);
if (el) ro.unobserve(el);
};
},
);
} else {
ro.observe(target as Element);
ro.observe(target);
}
onCleanup(() => ro.disconnect());
}
Expand Down
4 changes: 2 additions & 2 deletions packages/bounds/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { createElementBounds, getElementBounds } from "../src/index.js";

class TestResizeObserver {
constructor() {}
observe(target: Element, options?: ResizeObserverOptions): void {}
unobserve(target: Element): void {}
observe(_target: Element, _options?: ResizeObserverOptions): void {}
unobserve(_target: Element): void {}
disconnect() {}
}
global.ResizeObserver = TestResizeObserver;
Expand Down
4 changes: 2 additions & 2 deletions packages/broadcast-channel/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class BroadcastChannel {
if (!_all_listeners[channel_name]) {
_all_listeners[channel_name] = [this.listeners];
} else {
_all_listeners[channel_name]!.push(this.listeners);
_all_listeners[channel_name].push(this.listeners);
}
}

Expand Down Expand Up @@ -167,7 +167,7 @@ describe("makeBroadcastChannel", () => {
data.dispose();
});

test("sending messages", async t => {
test("sending messages", async _t => {
const channelName = "channel-1";

const data = createRoot(dispose => {
Expand Down
3 changes: 2 additions & 1 deletion packages/controlled-props/test/testProps.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe("createControlledProp", () => {
expect(label).instanceOf(HTMLLabelElement);
const select = label.querySelector("select")!;
expect(select).instanceOf(HTMLSelectElement);
expect(select.selectedOptions[0].innerHTML).toBe("One");
expect(select.selectedOptions[0]?.innerHTML).toBe("One");
select.selectedIndex = 0;
select.dispatchEvent(new Event("change"));
expect(value()).toBe(Test.Zero);
Expand Down Expand Up @@ -159,5 +159,6 @@ describe("createControlledProp", () => {
enumSelect.selectedIndex = 1;
enumSelect.dispatchEvent(new Event("change"));
expect(props.enum()).toBe(Test.One);
dispose();
}));
});
6 changes: 3 additions & 3 deletions packages/date/test/date-difference.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, it, expect } from "vitest";
import { createRoot, createSignal } from "solid-js";
import {
createTimeAgo,
RelativeFormatMessages,
type RelativeFormatMessages,
DAY,
HOUR,
MINUTE,
Expand Down Expand Up @@ -110,8 +110,8 @@ describe("createTimeAgo", () => {
const messages: Partial<RelativeFormatMessages> = {
justNow: "NOW",
future: n => `in the next ${n}`,
day: (n, past) => `${n} DAY${n > 1 ? "S" : ""}`,
week: (n, past) => (n === 1 ? "week" : `${n} weeks`),
day: (n, _past) => `${n} DAY${n > 1 ? "S" : ""}`,
week: (n, _past) => (n === 1 ? "week" : `${n} weeks`),
};

const [timeago] = createTimeAgo(date, {
Expand Down
2 changes: 1 addition & 1 deletion packages/deep/test/track.bench.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, bench } from "vitest";
import { batch, createEffect, createRoot } from "solid-js";
import { captureStoreUpdates, trackDeep, trackStore } from "../src/index.js";
import { trackDeep, trackStore } from "../src/index.js";
import { createStore } from "solid-js/store";

const fns = {
Expand Down
4 changes: 2 additions & 2 deletions packages/event-listener/src/eventListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ export function createEventListener(
type State = { els: EventTarget[]; types: string[] };

const compute = (): State => ({
els: asArray(access(targets)).filter(Boolean) as EventTarget[],
types: asArray(access(type)) as string[],
els: asArray(access(targets)).filter(x => !!x),
types: asArray(access(type)),
});

const apply = ({ els, types }: State) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/event-listener/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { JSX } from "solid-js";
import type { JSX } from "@solidjs/web";

export type EventListenerOptions = boolean | AddEventListenerOptions;

Expand Down
4 changes: 2 additions & 2 deletions packages/event-listener/test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ export const event_target = new EventTarget();
const globalListeners: Record<string, Set<(e: Event) => void>> = {};

// @ts-ignore
event_target.addEventListener = (name: string, callback: (e: Event) => void, o: any) => {
event_target.addEventListener = (name: string, callback: (e: Event) => void, _o: any) => {
if (!globalListeners[name]) globalListeners[name] = new Set();
// @ts-ignore
globalListeners[name].add(callback);
};
// @ts-ignore
event_target.removeEventListener = (name: string, callback: (e: Event) => void, o: any) => {
event_target.removeEventListener = (name: string, callback: (e: Event) => void, _o: any) => {
if (!globalListeners[name]) return;
// @ts-ignore
globalListeners[name].delete(callback);
Expand Down
6 changes: 3 additions & 3 deletions packages/fetch/test/setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ResponseMock {
constructor(
public body: BodyInit | null,
private init: ResponseInit & { redirected: boolean; type: "cors" | "basic"; url: string },
private init: Partial<ResponseInit> & { redirected?: boolean; type?: "cors" | "basic"; url?: string },
) {}
get status() {
return this.init.status || -1;
Expand All @@ -12,7 +12,7 @@ class ResponseMock {
get headers() {
return this.init.headers instanceof Headers
? this.init.headers
: new Headers(this.init.headers) || new Headers();
: new Headers(this.init.headers || {});
}
get ok() {
return this.status >= 200 && this.status < 300;
Expand Down Expand Up @@ -67,7 +67,7 @@ class ResponseMock {
class HeadersMock {
private headers: Record<string, string> = {};
constructor(headers: Record<string, string>) {
Object.entries(headers || {}).forEach(([key, value]) => {
Object.entries(headers).forEach(([key, value]) => {
this.headers[key.toLowerCase()] = value;
});
}
Expand Down
8 changes: 4 additions & 4 deletions packages/geolocation/test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ Object.defineProperty(global.navigator, "geolocation", {
clearWatch: () => {},
getCurrentPosition(
successCallback: PositionCallback,
errorCallback?: PositionErrorCallback | null,
options?: PositionOptions,
_errorCallback?: PositionErrorCallback | null,
_options?: PositionOptions,
) {
successCallback({ coords: mockCoordinates } as GeolocationPosition);
},
watchPosition(
successCallback: PositionCallback,
errorCallback?: PositionErrorCallback | null,
options?: PositionOptions,
_errorCallback?: PositionErrorCallback | null,
_options?: PositionOptions,
) {
successCallback({ coords: mockCoordinates } as GeolocationPosition);
},
Expand Down
2 changes: 1 addition & 1 deletion packages/keyboard/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "../src/index.js";

const dispatchKeyEvent = (key: string, type: "keydown" | "keyup") => {
let ev = new Event(type) as any;
const ev = new Event(type) as any;
ev.key = key;
window.dispatchEvent(ev);
};
Expand Down
13 changes: 6 additions & 7 deletions packages/pagination/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ import {
createInfiniteScroll,
createPagination,
createSegment,
PaginationOptions,
type PaginationOptions,
} from "../src/index.js";
import { testEffect } from "../../resource/test/index.test.js";

describe("createPagination", () => {
test("createPagination returns page getter and setter", () =>
Expand Down Expand Up @@ -89,7 +88,7 @@ describe("createPagination", () => {

test("createPagination next back", () => {
createRoot(dispose => {
const [paginationProps, page, setPage] = createPagination({
const [paginationProps, _page, _setPage] = createPagination({
pages: 100,
maxPages: 1,
showFirst: false,
Expand All @@ -107,7 +106,7 @@ describe("createPagination", () => {

test("setting page below one will yield the first page", () => {
createRoot(dispose => {
const [paginationProps, page, setPage] = createPagination({
const [_paginationProps, page, setPage] = createPagination({
pages: 10,
maxPages: 5,
});
Expand All @@ -124,7 +123,7 @@ describe("createPagination", () => {

test("setting page beyond the number pages will yield the last page", () => {
createRoot(dispose => {
const [paginationProps, page, setPage] = createPagination({
const [_paginationProps, page, setPage] = createPagination({
pages: 10,
maxPages: 5,
initialPage: 10,
Expand All @@ -147,7 +146,7 @@ describe("createPagination", () => {
maxPages: 5,
initialPage: 10,
});
const [paginationProps, page, setPage] = createPagination(options);
const [_paginationProps, page, _setPage] = createPagination(options);

expect(page()).toBe(10);
setOptions({ pages: 8, maxPages: 5 });
Expand Down Expand Up @@ -200,7 +199,7 @@ describe("createSegment", () => {
createRoot(dispose => {
const [length, setLength] = createSignal(55);
const items = createMemo(() => Array.from({ length: length() }, (_, i) => i + 1));
const [page, setPage] = createSignal(6);
const [page, _setPage] = createSignal(6);
const segment = createSegment(items, 10, page);

const seg1 = segment();
Expand Down
6 changes: 2 additions & 4 deletions packages/presence/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ export function createPresence<TItem>(
options: Options,
): PresenceResult<TItem> {
const initial = untrack(item);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const [mountedItem, setMountedItem] = createSignal<TItem | undefined>(initial as any, INTERNAL_OPTIONS);
const [mountedItem, setMountedItem] = createSignal<TItem | undefined>(initial as Exclude<TItem, Function>, INTERNAL_OPTIONS);
const [shouldBeMounted, setShouldBeMounted] = createSignal(itemShouldBeMounted(initial), INTERNAL_OPTIONS);
const { isMounted, ...rest } = createPresenceBase(shouldBeMounted, options);

Expand All @@ -160,8 +159,7 @@ export function createPresence<TItem>(
if (isM) {
setShouldBeMounted(false);
} else if (itemShouldBeMounted(currentItem)) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
setMountedItem(currentItem as any);
setMountedItem(currentItem as Exclude<TItem, Function>);
setShouldBeMounted(true);
}
} else if (!itemShouldBeMounted(currentItem)) {
Expand Down
3 changes: 1 addition & 2 deletions packages/props/test/combineProps.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { describe, it, expect, vi } from "vitest";
import { createComputed, createRoot, createSignal, mergeProps, ValidComponent } from "solid-js";
import { DynamicProps, Dynamic } from "solid-js/web";
import { createComputed, createRoot, createSignal, mergeProps } from "solid-js";
import { combineProps } from "../src/index.js";

describe("combineProps", () => {
Expand Down
26 changes: 13 additions & 13 deletions packages/range/test/indexRange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,28 @@ describe("indexRange", () => {

const a = mapped();
expect(a.length).toBe(3);
expect(a[0]()).toBe(-3.5);
expect(a[1]()).toBe(-2);
expect(a[2]()).toBe(-0.5);
expect(a[0]?.()).toBe(-3.5);
expect(a[1]?.()).toBe(-2);
expect(a[2]?.()).toBe(-0.5);

setStart(0);
setTo(2);
setStep(0.2);
const b = mapped();
for (let n = 0, i = 0; i < 10; n += 0.2, i++) {
expect(b[i]()).toBe(n);
expect(b[i]?.()).toBe(n);
}

setStart(5);
setTo(-5);
setStep(2);
const c = mapped();
expect(c.length).toBe(5);
expect(c[0]()).toBe(5);
expect(c[1]()).toBe(3);
expect(c[2]()).toBe(1);
expect(c[3]()).toBe(-1);
expect(c[4]()).toBe(-3);
expect(c[0]?.()).toBe(5);
expect(c[1]?.()).toBe(3);
expect(c[2]?.()).toBe(1);
expect(c[3]?.()).toBe(-1);
expect(c[4]?.()).toBe(-3);

dispose();
}));
Expand All @@ -94,9 +94,9 @@ describe("indexRange", () => {
createRoot(dispose => {
const [start, setStart] = createSignal(4);
const [to, setTo] = createSignal(8);
const [step, setStep] = createSignal(1);
const [step, _setStep] = createSignal(1);

let captured: (string | number)[] = [];
const captured: (string | number)[] = [];
const mapped = indexRange(start, to, step, n => {
captured.push(n());
});
Expand All @@ -123,7 +123,7 @@ describe("indexRange", () => {
const [to, setTo] = createSignal(8);
const [step, setStep] = createSignal(1);

let captured: (string | number)[] = [];
const captured: (string | number)[] = [];
const mapped = indexRange(start, to, step, n => {
onCleanup(() => captured.push(n()));
});
Expand Down Expand Up @@ -152,7 +152,7 @@ describe("indexRange", () => {
createRoot(dispose => {
const [start, setStart] = createSignal(4);
const [to, setTo] = createSignal(8);
const [step, setStep] = createSignal(1);
const [step, _setStep] = createSignal(1);

const mapped = indexRange<string | number>(start, to, step, n => n(), {
fallback: () => "fb",
Expand Down
6 changes: 3 additions & 3 deletions packages/range/test/mapRange.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe("mapRange", () => {
const [to, setTo] = createSignal(8);
const [step, setStep] = createSignal(1);

let captured: (string | number)[] = [];
const captured: (string | number)[] = [];
const mapped = mapRange(start, to, step, n => {
captured.push(n);
});
Expand Down Expand Up @@ -118,7 +118,7 @@ describe("mapRange", () => {
const [to, setTo] = createSignal(8);
const [step, setStep] = createSignal(1);

let captured: (string | number)[] = [];
const captured: (string | number)[] = [];
const mapped = mapRange(start, to, step, n => {
onCleanup(() => captured.push(n));
});
Expand Down Expand Up @@ -148,7 +148,7 @@ describe("mapRange", () => {
createRoot(dispose => {
const [start, setStart] = createSignal(4);
const [to, setTo] = createSignal(8);
const [step, setStep] = createSignal(1);
const [step, _setStep] = createSignal(1);

const mapped = mapRange<string | number>(start, to, step, n => n, { fallback: () => "fb" });

Expand Down
6 changes: 3 additions & 3 deletions packages/range/test/repeat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe("repeat", () => {
it("maps only added items", () =>
createRoot(dispose => {
const [length, setLength] = createSignal(5);
let captured: number[] = [];
const captured: number[] = [];
const mapped = repeat(length, i => {
captured.push(i);
return i;
Expand All @@ -28,7 +28,7 @@ describe("repeat", () => {
it("uses fallback if length is 0", () =>
createRoot(dispose => {
const [length, setLength] = createSignal(4);
let captured: (string | number)[] = [];
const captured: (string | number)[] = [];
const mapped = repeat<string | number>(
length,
i => {
Expand Down Expand Up @@ -56,7 +56,7 @@ describe("repeat", () => {
it("disposing on remove and cleanup", () =>
createRoot(dispose => {
const [length, setLength] = createSignal(2);
let cleanups: (string | number)[] = [];
const cleanups: (string | number)[] = [];
const mapped = repeat<string | number>(
length,
i => {
Expand Down
Loading
Loading