kopia lustrzana https://github.com/cloudflare/wildebeest
improve the frontend lint coverage
by including in the lint check not only src but also mock-db, test and adaptorspull/115/head
rodzic
0e67c9f680
commit
3db6ca6602
|
@ -5,13 +5,16 @@ import { statuses } from 'wildebeest/frontend/src/dummyData'
|
|||
import type { Account, MastodonStatus } from 'wildebeest/frontend/src/types'
|
||||
|
||||
const kek = 'test-kek'
|
||||
/* eslint-disable @typescript-eslint/no-empty-function */
|
||||
const queue = {
|
||||
async send() {},
|
||||
async sendBatch() {},
|
||||
}
|
||||
const kv_cache: any = {
|
||||
const kv_cache = {
|
||||
async put() {},
|
||||
}
|
||||
/* eslint-enable @typescript-eslint/no-empty-function */
|
||||
|
||||
/**
|
||||
* Run helper commands to initialize the database with actors, statuses, etc.
|
||||
*/
|
||||
|
@ -46,7 +49,7 @@ async function createStatus(db: D1Database, actor: Person, status: string, visib
|
|||
headers,
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
const resp = await statusesAPI.handleRequest(req, db, actor, kek, queue, kv_cache)
|
||||
const resp = await statusesAPI.handleRequest(req, db, actor, kek, queue, kv_cache as unknown as KVNamespace)
|
||||
return (await resp.json()) as MastodonStatus
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,11 @@ const handler: ExportedHandler<Env> = {
|
|||
const domain = new URL(req.url).hostname
|
||||
try {
|
||||
await init(domain, DATABASE)
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Database initialized.')
|
||||
} catch (e) {
|
||||
if (isD1ConstraintError(e)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Database already initialized.')
|
||||
} else {
|
||||
throw e
|
||||
|
@ -29,7 +31,10 @@ const handler: ExportedHandler<Env> = {
|
|||
* which will indicate that the database was already populated.
|
||||
*/
|
||||
function isD1ConstraintError(e: unknown) {
|
||||
return (e as any).message === 'D1_RUN_ERROR' && (e as any).cause?.code === 'SQLITE_CONSTRAINT_PRIMARYKEY'
|
||||
return (
|
||||
(e as { message: string }).message === 'D1_RUN_ERROR' &&
|
||||
(e as { cause?: { code: string } }).cause?.code === 'SQLITE_CONSTRAINT_PRIMARYKEY'
|
||||
)
|
||||
}
|
||||
|
||||
export default handler
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
},
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"lint": "eslint src",
|
||||
"lint": "eslint src mock-db test adaptors",
|
||||
"build": "vite build && vite build -c adaptors/cloudflare-pages/vite.config.ts",
|
||||
"dev": "vite --mode ssr",
|
||||
"watch": "concurrently \"vite build -w\" \"vite build -w -c adaptors/cloudflare-pages/vite.config.ts\""
|
||||
|
|
|
@ -22,5 +22,5 @@
|
|||
"wildebeest/*": ["../*"]
|
||||
}
|
||||
},
|
||||
"include": ["src", "mock-db", "../backend/src", "../config", "../functions"]
|
||||
"include": ["src", "mock-db", "test", "adaptors","../backend/src", "../config", "../functions"]
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue