chore: Code changes & formatting and linting (#3552)

* Do some code changes & run prettier and eslint

* Fix test:test-type script

* Apply code review suggestions

* update heartbeat interval & add a reason for the specific value

* Fix husky error

* Update to TS 5.5

And use ${configDir}

* Fix test.json tsconfig base

---------

Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
This commit is contained in:
Fleny
2024-07-08 22:11:41 +02:00
committed by GitHub
parent 2f89d4da30
commit 97a8016041
83 changed files with 370 additions and 526 deletions

View File

@@ -3,7 +3,7 @@ import os from 'node:os'
const hostCpu = os.cpus()[0].model.trim()
const targetCpu = await fetch('https://raw.githubusercontent.com/discordeno/discordeno/benchies/cpu')
.then((res) => res.text())
.then(async (res) => await res.text())
.then((text) => text.slice(0, -1))
console.dir(`host cpu: ${hostCpu} target cpu: ${targetCpu}`)

View File

@@ -5,7 +5,7 @@ import fs from 'node:fs'
import path from 'node:path'
// these two paths may vary depending on where you place this script, and your project structure including where typedoc generates its output files.
const typedocOutPath = await import('../typedoc.json', { assert: { type: 'json' } }).then((module) => module.default.out)
const typedocOutPath = await import('../typedoc.json', { with: { type: 'json' } }).then((module) => module.default.out)
async function* walk(dir) {
for await (const d of await fs.promises.opendir(dir)) {

View File

@@ -1,10 +1,13 @@
/* eslint-disable @typescript-eslint/explicit-function-return-type */
/* eslint-disable @typescript-eslint/no-unsafe-argument */
import fs from 'fs'
// TODO: replace with fetch of live spec
const DISCORD_SPEC = {}
function schemaRefToName(ref) {
if (!ref) return ""
if (!ref) return ''
return `Discord${ref?.substring(ref.lastIndexOf('/') + 1)}`
}
@@ -60,12 +63,12 @@ function generateFromSpec() {
type === 'integer'
? 'number'
: type === 'array'
? property.items.$ref
? `${schemaRefToName(property.items.$ref)}[]`
: Array.isArray(property.items.oneOf)
? `${property.items.oneOf.map((o) => `${schemaRefToName(o.$ref)}[]`).join(' | ')}`
: `unknown[]`
: type,
? property.items.$ref
? `${schemaRefToName(property.items.$ref)}[]`
: Array.isArray(property.items.oneOf)
? `${property.items.oneOf.map((o) => `${schemaRefToName(o.$ref)}[]`).join(' | ')}`
: `unknown[]`
: type,
)
.join(' | ') ??
property.oneOf