Skip to content

Commit

Permalink
style: apply lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
unnoq committed Nov 21, 2024
1 parent 4bc53cb commit ac38727
Show file tree
Hide file tree
Showing 158 changed files with 1,220 additions and 1,168 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: '<!--pr-release-->'
body-includes: <!--pr-release-->

- name: Create or update pr-release comment with in process status
uses: peter-evans/create-or-update-comment@v4
Expand Down Expand Up @@ -147,4 +147,4 @@ jobs:

- name: Exit with failed status
if: steps.publish.outcome != 'success'
run: exit 1
run: exit 1
5 changes: 3 additions & 2 deletions apps/content/app/(home)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ReactNode } from 'react'
import { baseOptions } from '@/app/layout.config'
import { HomeLayout } from 'fumadocs-ui/layouts/home'
import type { ReactNode } from 'react'

export default function Layout({
children,
Expand Down Expand Up @@ -121,7 +121,8 @@ function Footer() {
<div className="container flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between">
<div>
<p className="text-fd-muted-foreground">
Built with ❤️ by{' '}
Built with ❤️ by
{' '}
<a
href="https://unnoq.com"
rel="noreferrer noopener"
Expand Down
6 changes: 4 additions & 2 deletions apps/content/app/docs/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export default async function Page(props: {
}) {
const params = await props.params
const page = source.getPage(params.slug)
if (!page) notFound()
if (!page)
notFound()

const MDX = page.data.body

Expand Down Expand Up @@ -60,7 +61,8 @@ export async function generateMetadata(props: {
}) {
const params = await props.params
const page = source.getPage(params.slug)
if (!page) notFound()
if (!page)
notFound()

return {
title: page.data.title,
Expand Down
2 changes: 1 addition & 1 deletion apps/content/app/docs/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { ReactNode } from 'react'
import { baseOptions } from '@/app/layout.config'
import { source } from '@/lib/source'
import { DocsLayout } from 'fumadocs-ui/layouts/docs'
import type { ReactNode } from 'react'

export default function Layout({ children }: { children: ReactNode }) {
return (
Expand Down
8 changes: 4 additions & 4 deletions apps/content/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import './global.css'
import 'fumadocs-twoslash/twoslash.css'

import type { Metadata } from 'next'
import { RootProvider } from 'fumadocs-ui/provider'

import { GeistMono } from 'geist/font/mono'
import { GeistSans } from 'geist/font/sans'
import type { Metadata } from 'next'
import './global.css'
import 'fumadocs-twoslash/twoslash.css'

export const metadata: Metadata = {
metadataBase: new URL('https://orpc.unnoq.com'),
Expand Down
4 changes: 2 additions & 2 deletions apps/content/components/icons.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export {
Album,
HeartHandshake,
Code,
ReceiptText,
GitCompareArrows,
HeartHandshake,
LayoutPanelTop,
ReceiptText,
} from 'lucide-react'
4 changes: 2 additions & 2 deletions apps/content/components/ui/icon.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { cn } from '@/utils/cn'
import type { LucideIcon } from 'lucide-react'
import { TerminalIcon } from 'lucide-react'
import type { HTMLAttributes } from 'react'
import { cn } from '@/utils/cn'
import { TerminalIcon } from 'lucide-react'

export function IconContainer({
icon: Icon,
Expand Down
2 changes: 1 addition & 1 deletion apps/content/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const server = createServer(
)

server.listen(2026, () => {
// biome-ignore lint/suspicious/noConsole: <explanation>
// eslint-disable-next-line no-console
console.log('Server is available at http://localhost:2026')
})
```
Expand Down
28 changes: 14 additions & 14 deletions apps/content/examples/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@ import { oc } from '@orpc/contract'
import { oz } from '@orpc/zod'
import { z } from 'zod'

// Implement the contract

import { ORPCError, os } from '@orpc/server'

// Expose apis to the internet with fetch handler

import { createFetchHandler } from '@orpc/server/fetch'

// Modern runtime that support fetch api like deno, bun, cloudflare workers, even node can used

import { createServer } from 'node:http'
import { createServerAdapter } from '@whatwg-node/server'

// Define your contract first
// This contract can replace server router in most-case

Expand Down Expand Up @@ -55,10 +68,6 @@ export const contract = oc.router({
}),
})

// Implement the contract

import { os, ORPCError } from '@orpc/server'

export type Context = { user?: { id: string } }
export const base = os.context<Context>()
export const pub /** os with ... */ = base.contract(contract) // Ensure every implement must be match contract
Expand Down Expand Up @@ -112,20 +121,11 @@ export const router = pub.router({
},
})

// Expose apis to the internet with fetch handler

import { createFetchHandler } from '@orpc/server/fetch'

const handler = createFetchHandler({
router,
serverless: false, // set true will improve cold start times
})

// Modern runtime that support fetch api like deno, bun, cloudflare workers, even node can used

import { createServer } from 'node:http'
import { createServerAdapter } from '@whatwg-node/server'

const server = createServer(
createServerAdapter((request: Request) => {
const url = new URL(request.url)
Expand All @@ -143,7 +143,7 @@ const server = createServer(
)

server.listen(2026, () => {
// biome-ignore lint/suspicious/noConsole: <explanation>
// eslint-disable-next-line no-console
console.log('Server is available at http://localhost:2026')
})

Expand Down
12 changes: 6 additions & 6 deletions apps/content/examples/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { os, ORPCError } from '@orpc/server'
import { ORPCError, os } from '@orpc/server'
import { z } from 'zod'

// in oRPC middleware is so powerful
Expand All @@ -12,7 +12,7 @@ export const pub /** public access */ = os
const start = Date.now()

meta.onFinish((output, error) => {
// biome-ignore lint/suspicious/noConsole: <explanation>
// eslint-disable-next-line no-console
console.log(`middleware cost ${Date.now() - start}ms`)
})
})
Expand All @@ -23,11 +23,11 @@ export const authMid = pub.middleware(async (input, context, meta) => {
}

meta.onSuccess((output) => {})
meta.onSuccess((error) => {})
meta.onSuccess((_error) => {})
meta.onFinish((output, error) => {})

meta.path // for analyze
meta.procedure // for analyze
const _path = meta.path // for analyze
const _procedure = meta.procedure // for analyze

return {
context: {
Expand All @@ -51,7 +51,7 @@ export const editPost = authed
.input(z.object({ id: z.string() }))
.output(z.string())
.use(canEditPost) // if input not match, will throw type error
.use(canEditPost, (old) => ({ id: old.id })) // Can map input if needed
.use(canEditPost, old => ({ id: old.id })) // Can map input if needed
.use((input, context, meta) => {
// If middleware create after .input and .output them will be typed

Expand Down
12 changes: 6 additions & 6 deletions apps/content/examples/open-api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { generateOpenAPI } from '@orpc/openapi'
import { router } from 'examples/server'

// or generate from contract
import { contract } from 'examples/contract'

export const specFromServerRouter = generateOpenAPI({
router,
info: {
Expand All @@ -9,9 +12,6 @@ export const specFromServerRouter = generateOpenAPI({
},
})

// or generate from contract
import { contract } from 'examples/contract'

export const specFromContractRouter = generateOpenAPI({
router: contract,
info: {
Expand Down Expand Up @@ -47,7 +47,7 @@ const _exampleSpec = {
},
},
responses: {
'200': {
200: {
description: 'OK',
content: {
'application/json': {
Expand Down Expand Up @@ -80,7 +80,7 @@ const _exampleSpec = {
},
],
responses: {
'200': {
200: {
description: 'OK',
content: {
'application/json': {
Expand Down Expand Up @@ -132,7 +132,7 @@ const _exampleSpec = {
},
},
responses: {
'200': {
200: {
description: 'OK',
content: {
'application/json': {
Expand Down
7 changes: 3 additions & 4 deletions apps/content/examples/react.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createORPCReact } from '@orpc/react'
import type { router } from 'examples/server'
import { createORPCReact } from '@orpc/react'
// biome-ignore lint/correctness/noUnusedImports: <explanation>
import * as React from 'react'

export const { orpc, ORPCContext } =
createORPCReact<typeof router /** or contract router */>()
export const { orpc, ORPCContext }
= createORPCReact<typeof router /** or contract router */>()
6 changes: 3 additions & 3 deletions apps/content/examples/server-action.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use server'

// biome-ignore lint/correctness/noUnusedImports: <explanation>
import * as React from 'react'

import { os } from '@orpc/server'

import { oz } from '@orpc/zod'
import { redirect } from 'next/navigation'
// biome-ignore lint/correctness/noUnusedImports: <explanation>
import * as React from 'react'
import { z } from 'zod'

export const createPost = os
Expand Down
24 changes: 12 additions & 12 deletions apps/content/examples/server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import { os, ORPCError } from '@orpc/server'
import { ORPCError, os } from '@orpc/server'
import { oz } from '@orpc/zod'
import { z } from 'zod'

// Expose apis to the internet with fetch handler

import { createFetchHandler } from '@orpc/server/fetch'

// Modern runtime that support fetch api like deno, bun, cloudflare workers, even node can used

import { createServer } from 'node:http'
import { createServerAdapter } from '@whatwg-node/server'

export type Context = { user?: { id: string } }

// global pub, authed completely optional
Expand Down Expand Up @@ -75,7 +84,7 @@ export const router = pub.router({
}),
)
.handler(async (input, context, meta) => {
input.thumb // file upload out of the box
const _thumb = input.thumb // file upload out of the box

return {
id: 'example',
Expand All @@ -86,20 +95,11 @@ export const router = pub.router({
}),
})

// Expose apis to the internet with fetch handler

import { createFetchHandler } from '@orpc/server/fetch'

const handler = createFetchHandler({
router,
serverless: false, // set true will improve cold start times
})

// Modern runtime that support fetch api like deno, bun, cloudflare workers, even node can used

import { createServer } from 'node:http'
import { createServerAdapter } from '@whatwg-node/server'

const server = createServer(
createServerAdapter((request: Request) => {
const url = new URL(request.url)
Expand All @@ -117,7 +117,7 @@ const server = createServer(
)

server.listen(2026, () => {
// biome-ignore lint/suspicious/noConsole: <explanation>
// eslint-disable-next-line no-console
console.log('Server is available at http://localhost:2026')
})

Expand Down
3 changes: 2 additions & 1 deletion apps/content/lib/source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ export const source = loader({
baseUrl: '/docs',
source: createMDXSource(docs, meta),
icon(icon) {
if (icon && icon in icons)
if (icon && icon in icons) {
return createElement(IconContainer, {
icon: icons[icon as keyof typeof icons],
})
}
},
})

Expand Down
22 changes: 11 additions & 11 deletions apps/content/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"compilerOptions": {
"baseUrl": ".",
"incremental": true,
"target": "ESNext",
"jsx": "preserve",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"baseUrl": ".",
"module": "esnext",
"moduleResolution": "bundler",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"incremental": true,
"paths": {
"@/*": ["./*"]
},
"resolveJsonModule": true,
"allowJs": true,
"strict": true,
"noEmit": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"skipLibCheck": true,
"plugins": [
{
"name": "next"
Expand Down
Loading

0 comments on commit ac38727

Please sign in to comment.