Merge pull request #370 from cloudflare/add-prelint-script

add type-check frontend script
pull/377/head
Sven Sauleau 2023-03-07 09:03:09 +01:00 zatwierdzone przez GitHub
commit 2bc881e9ca
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
11 zmienionych plików z 24 dodań i 16 usunięć

Wyświetl plik

@ -53,6 +53,9 @@ jobs:
- name: Check frontend linting
run: yarn lint:frontend
- name: Check frontend types
run: yarn --cwd types-check
test-ui:
runs-on: ubuntu-latest
steps:

Wyświetl plik

@ -270,7 +270,8 @@ function getContentRewriter() {
contentRewriter.on('*', {
element(el) {
if (!['p', 'span', 'br', 'a'].includes(el.tagName)) {
el.tagName = 'p'
const element = el as { tagName: string }
element.tagName = 'p'
}
if (el.hasAttribute('class')) {

Wyświetl plik

@ -4,7 +4,7 @@ import type { Env } from 'wildebeest/backend/src/types/env'
function sqliteToPsql(query: string): string {
let c = 0
return query.replaceAll(/\?([0-9])?/g, (match: string, p1: string) => {
return query.replace(/\?([0-9])?/g, (match: string, p1: string) => {
c += 1
return `$${p1 || c}`
})

Wyświetl plik

@ -281,11 +281,12 @@ export function parseRequest(request: Request, options?: Options): ParsedSignatu
if (h === 'request-line') {
if (!options.strict) {
const cf = (request as { cf?: IncomingRequestCfProperties }).cf
/*
* We allow headers from the older spec drafts if strict parsing isn't
* specified in options.
*/
parsed.signingString += request.method + ' ' + request.url + ' ' + request.cf?.httpProtocol
parsed.signingString += request.method + ' ' + request.url + ' ' + cf?.httpProtocol
} else {
/* Strict parsing doesn't allow older draft headers. */
throw new StrictParsingError('request-line is not a valid header ' + 'with strict parsing enabled.')

Wyświetl plik

@ -19,7 +19,8 @@ export function initSentry(request: Request, env: Env, context: any) {
request,
transportOptions: { headers },
})
const colo = request.cf && request.cf.colo ? request.cf.colo : 'UNKNOWN'
const cf = (request as { cf?: IncomingRequestCfProperties }).cf
const colo = cf?.colo ? cf.colo : 'UNKNOWN'
sentry.setTag('colo', colo)
// cf-connecting-ip should always be present, but if not we can fallback to XFF.

Wyświetl plik

@ -26,12 +26,12 @@ export function arrayBufferToBase64(buffer: ArrayBuffer): string {
}
export function b64ToUrlEncoded(str: string): string {
return str.replaceAll(/\+/g, '-').replaceAll(/\//g, '_').replace(/=+/g, '')
return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+/g, '')
}
export function urlEncodedToB64(str: string): string {
const padding = '='.repeat((4 - (str.length % 4)) % 4)
return str.replaceAll(/-/g, '+').replaceAll(/_/g, '/') + padding
return str.replace(/-/g, '+').replace(/_/g, '/') + padding
}
export function stringToU8Array(str: string): Uint8Array {

Wyświetl plik

@ -1,4 +1,4 @@
import { cloudflarePagesAdaptor } from '@builder.io/qwik-city/adaptors/cloudflare-pages/vite'
import { cloudflarePagesAdapter } from '@builder.io/qwik-city/adapters/cloudflare-pages/vite'
import { extendConfig } from '@builder.io/qwik-city/vite'
import baseConfig from '../../vite.config'
@ -11,7 +11,7 @@ export default extendConfig(baseConfig, () => {
},
},
plugins: [
cloudflarePagesAdaptor({
cloudflarePagesAdapter({
// Do not SSG as the D1 database is not available at build time, I think.
// staticGenerate: true,
}),

Wyświetl plik

@ -7,6 +7,8 @@
},
"private": true,
"scripts": {
"pretypes-check": "yarn build",
"types-check": "tsc",
"lint": "eslint src mock-db adaptors",
"build": "vite build && vite build -c adaptors/cloudflare-pages/vite.config.ts",
"dev": "vite --mode ssr",

Wyświetl plik

@ -59,12 +59,12 @@ export async function handleRequest(
if (formData.has('display_name')) {
const value = formData.get('display_name')!
await updateActorProperty(db, connectedActor.id, 'name', value)
await updateActorProperty(db, connectedActor.id, 'name', value as string)
}
if (formData.has('note')) {
const value = formData.get('note')!
await updateActorProperty(db, connectedActor.id, 'summary', value)
await updateActorProperty(db, connectedActor.id, 'summary', value as string)
}
if (formData.has('avatar')) {

Wyświetl plik

@ -42,11 +42,11 @@ export async function handlePostRequest(
const properties: Record<string, string> = {}
if (formData.has('username')) {
properties.preferredUsername = formData.get('username') || ''
properties.preferredUsername = (formData.get('username') as string) || ''
}
if (formData.has('name')) {
properties.name = formData.get('name') || ''
properties.name = (formData.get('name') as string) || ''
}
await createPerson(domain, db, userKEK, email, properties)

Wyświetl plik

@ -50,7 +50,7 @@
"http-message-signatures": "^0.1.2",
"toucan-js": "^3.1.0"
},
"simple-git-hooks": {
"pre-commit": "yarn lint"
}
}
"simple-git-hooks": {
"pre-commit": "yarn lint"
}
}