fix linter warnings
This commit is contained in:
@@ -97,6 +97,6 @@ export interface UserInfo {
|
||||
username: string
|
||||
discriminator: string
|
||||
tag: string
|
||||
avatarUrl: string
|
||||
avatarUrl: string | null
|
||||
accentColor?: number
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import type {
|
||||
import { Node } from "../../internal/node.js"
|
||||
import type { ComponentEvent } from "../component-event"
|
||||
import { OptionNode } from "./option-node"
|
||||
import { omit } from "@reacord/helpers/omit.js"
|
||||
|
||||
/** @category Select */
|
||||
export interface SelectProps {
|
||||
@@ -102,12 +103,13 @@ class SelectNode extends Node<SelectProps> {
|
||||
values,
|
||||
minValues = 0,
|
||||
maxValues = 25,
|
||||
children,
|
||||
onChange,
|
||||
onChangeValue,
|
||||
onChangeMultiple,
|
||||
...props
|
||||
} = this.props
|
||||
} = omit(this.props, [
|
||||
"children",
|
||||
"onChange",
|
||||
"onChangeValue",
|
||||
"onChangeMultiple",
|
||||
])
|
||||
|
||||
const item: ActionRowItem = {
|
||||
...props,
|
||||
|
||||
@@ -237,7 +237,7 @@ export class ReacordDiscordJs extends Reacord {
|
||||
...pruneNullishValues(
|
||||
pick(interaction.user, ["id", "username", "discriminator", "tag"]),
|
||||
),
|
||||
avatarUrl: interaction.user.avatarURL()!,
|
||||
avatarUrl: interaction.user.avatarURL(),
|
||||
accentColor: interaction.user.accentColor ?? undefined,
|
||||
}
|
||||
|
||||
|
||||
@@ -38,13 +38,13 @@ export abstract class Reacord {
|
||||
}
|
||||
|
||||
protected createInstance(renderer: Renderer, initialContent?: ReactNode) {
|
||||
if (this.renderers.length > this.maxInstances) {
|
||||
this.deactivate(this.renderers[0]!)
|
||||
if (this.renderers.length > this.maxInstances && this.renderers[0]) {
|
||||
this.deactivate(this.renderers[0])
|
||||
}
|
||||
|
||||
this.renderers.push(renderer)
|
||||
|
||||
const container = reconciler.createContainer(
|
||||
const container: unknown = reconciler.createContainer(
|
||||
renderer,
|
||||
0,
|
||||
null,
|
||||
|
||||
@@ -41,7 +41,7 @@ const config: HostConfig<
|
||||
raise(`Missing createNode function`)
|
||||
}
|
||||
|
||||
const node = props.createNode(props.props)
|
||||
const node: unknown = props.createNode(props.props)
|
||||
if (!(node instanceof Node)) {
|
||||
raise(`createNode function did not return a Node`)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { raise } from "@reacord/helpers/raise.js"
|
||||
import {
|
||||
Button,
|
||||
Link,
|
||||
@@ -18,9 +19,13 @@ const reacord = new ReacordDiscordJs(client)
|
||||
|
||||
await client.login(process.env.TEST_BOT_TOKEN)
|
||||
|
||||
const guild = await client.guilds.fetch(process.env.TEST_GUILD_ID!)
|
||||
const guild = await client.guilds.fetch(
|
||||
process.env.TEST_GUILD_ID ?? raise("TEST_GUILD_ID not defined"),
|
||||
)
|
||||
|
||||
const category = await guild.channels.fetch(process.env.TEST_CATEGORY_ID!)
|
||||
const category = await guild.channels.fetch(
|
||||
process.env.TEST_CATEGORY_ID ?? raise("TEST_CATEGORY_ID not defined"),
|
||||
)
|
||||
if (category?.type !== ChannelType.GuildCategory) {
|
||||
throw new Error(
|
||||
`channel ${process.env.TEST_CATEGORY_ID} is not a guild category. received ${category?.type}`,
|
||||
|
||||
@@ -8,5 +8,5 @@ beforeAll(() => {
|
||||
|
||||
test("can require commonjs", () => {
|
||||
const require = createRequire(import.meta.url)
|
||||
expect(() => require("../dist/main.cjs")).not.toThrow()
|
||||
expect(() => require("../dist/main.cjs") as unknown).not.toThrow()
|
||||
})
|
||||
|
||||
@@ -128,13 +128,17 @@ test("multiple select", async () => {
|
||||
await tester.findSelectByPlaceholder("select").select("1", "3")
|
||||
await assertSelect(expect.arrayContaining(["1", "3"]) as unknown as string[])
|
||||
expect(onSelect).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ values: expect.arrayContaining(["1", "3"]) }),
|
||||
expect.objectContaining({
|
||||
values: expect.arrayContaining(["1", "3"]) as unknown,
|
||||
}),
|
||||
)
|
||||
|
||||
await tester.findSelectByPlaceholder("select").select("2")
|
||||
await assertSelect(expect.arrayContaining(["2"]) as unknown as string[])
|
||||
expect(onSelect).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ values: expect.arrayContaining(["2"]) }),
|
||||
expect.objectContaining({
|
||||
values: expect.arrayContaining(["2"]) as unknown,
|
||||
}),
|
||||
)
|
||||
|
||||
await tester.findSelectByPlaceholder("select").select()
|
||||
|
||||
Reference in New Issue
Block a user