add eslint plugin unicorn

This commit is contained in:
MapleLeaf
2021-12-08 20:16:55 -06:00
parent 0953b4d831
commit 7acce161b5
9 changed files with 480 additions and 16 deletions

View File

@@ -20,9 +20,9 @@ export class ReacordContainer {
}
clear() {
this.instances.forEach((instance) => {
for (const instance of this.instances) {
instance.destroy()
})
}
this.instances.clear()
}
}

View File

@@ -1,3 +1,4 @@
// eslint-disable-next-line import/no-unused-modules
export type Deferred<T> = PromiseLike<T> & {
resolve: (value: T | PromiseLike<T>) => void
reject: (reason?: unknown) => void

View File

@@ -1,3 +1,4 @@
/* eslint-disable unicorn/no-null */
import ReactReconciler from "react-reconciler"
import type { ReacordContainer } from "./container.js"
import { ReacordInstance } from "./instance.js"
@@ -30,7 +31,7 @@ export const reconciler = ReactReconciler<
createInstance: (
type,
props,
properties,
rootContainerInstance,
hostContext,
internalInstanceHandle,

View File

@@ -1,10 +1,10 @@
import test from "ava"
import { Client, TextChannel } from "discord.js"
import { nanoid } from "nanoid"
import { testBotToken, testChannelId } from "../test/env.js"
import { raise } from "./helpers/raise.js"
import { waitForWithTimeout } from "./helpers/wait-for-with-timeout.js"
import { render } from "./render.js"
import { testBotToken, testChannelId } from "./test-environment.js"
const client = new Client({
intents: ["GUILDS"],
@@ -21,7 +21,7 @@ test.before(async () => {
raise("Channel not found")
if (!(result instanceof TextChannel)) {
throw new Error("Channel must be a text channel")
throw new TypeError("Channel must be a text channel")
}
channel = result

View File

@@ -1,3 +1,4 @@
/* eslint-disable unicorn/no-null */
import type { TextBasedChannels } from "discord.js"
import { ReacordContainer } from "./container"
import { reconciler } from "./reconciler"

10
src/test-environment.ts Normal file
View File

@@ -0,0 +1,10 @@
import "dotenv/config.js"
import { raise } from "./helpers/raise.js"
function getEnvironmentValue(name: string) {
return process.env[name] ?? raise(`Missing environment variable: ${name}`)
}
export const testBotToken = getEnvironmentValue("TEST_BOT_TOKEN")
// export const testGuildId = getEnvironmentValue("TEST_GUILD_ID")
export const testChannelId = getEnvironmentValue("TEST_CHANNEL_ID")