Skip to content

Commit 1857765

Browse files
authored
Biome (#53)
1 parent 6d77c0d commit 1857765

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+713
-4888
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repos:
1313
rev: v2.3.0
1414
hooks:
1515
- id: codespell
16-
args: ['--skip=*.snap']
16+
args: ["--skip=*.snap"]
1717

1818
- repo: local
1919
hooks:
@@ -31,13 +31,6 @@ repos:
3131
language: system
3232
types_or: [javascript, ts, json]
3333
pass_filenames: false
34-
- id: lint-ts
35-
name: lint typescript
36-
entry: make
37-
args: [lint-ts]
38-
language: system
39-
types_or: [javascript, ts, json]
40-
pass_filenames: false
4134
- id: typecheck-ts
4235
name: typecheck typescript
4336
entry: make

.prettierignore

Lines changed: 0 additions & 7 deletions
This file was deleted.

.zed/settings.json

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,39 @@
11
{
22
"languages": {
3+
"JavaScript": {
4+
"formatter": { "language_server": { "name": "biome" } },
5+
"code_actions_on_format": {
6+
"source.fixAll.biome": true,
7+
"source.organizeImports.biome": true
8+
}
9+
},
310
"TypeScript": {
4-
"formatter": { "external": { "command": "npx", "arguments": ["prettier", "--stdin-filepath", "{buffer_path}"] } }
11+
"formatter": { "language_server": { "name": "biome" } },
12+
"code_actions_on_format": {
13+
"source.fixAll.biome": true,
14+
"source.organizeImports.biome": true
15+
}
16+
},
17+
"TSX": {
18+
"formatter": { "language_server": { "name": "biome" } },
19+
"code_actions_on_format": {
20+
"source.fixAll.biome": true,
21+
"source.organizeImports.biome": true
22+
}
23+
},
24+
"JSON": { "formatter": { "language_server": { "name": "biome" } } },
25+
"JSONC": { "formatter": { "language_server": { "name": "biome" } } },
26+
"CSS": {
27+
"formatter": { "language_server": { "name": "biome" } },
28+
"language_servers": ["tailwindcss-language-server", "..."]
29+
}
30+
},
31+
"lsp": {
32+
"biome": {
33+
"settings": {
34+
"require_config_file": true,
35+
"config_path": "<path>/biome.jsonc"
36+
}
537
}
638
}
739
}

biome.jsonc

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.2.4/schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
8+
"files": {
9+
"ignoreUnknown": false
10+
},
11+
"formatter": {
12+
"enabled": true,
13+
"indentStyle": "space",
14+
"lineWidth": 119
15+
},
16+
"linter": {
17+
"enabled": true,
18+
"rules": {
19+
"recommended": true,
20+
"suspicious": {
21+
"useAwait": "error"
22+
},
23+
"style": {
24+
"noNonNullAssertion": "off",
25+
// maybe but seems unnecessarily opinionated
26+
"useTemplate": "off",
27+
// could anable this, but it's annoying with `...API` etc.
28+
// "useNamingConvention": "error",
29+
"noRestrictedImports": "error"
30+
},
31+
"nursery": {
32+
"recommended": true,
33+
"noFloatingPromises": "error"
34+
}
35+
}
36+
},
37+
"javascript": {
38+
"formatter": {
39+
"trailingCommas": "all",
40+
"quoteStyle": "single",
41+
"semicolons": "asNeeded"
42+
}
43+
},
44+
"assist": {
45+
"enabled": true,
46+
"actions": {
47+
"source": {
48+
"organizeImports": "on"
49+
}
50+
}
51+
},
52+
"overrides": [
53+
{
54+
"includes": ["**/*.ts"],
55+
"formatter": {
56+
"expand": "never"
57+
}
58+
}
59+
]
60+
}

deploy/example.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type { Config } from '@deploy/types'
21
import { env } from 'cloudflare:workers'
2+
import type { Config } from '@deploy/types'
33

44
// can be whatever you want, just used to make linking apiKeys to providers typesafe.
55
type ProviderKeys = 'a' | 'b' | 'c' | 'd'

deploy/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"limits-remote-db": "wrangler d1 execute pydantic-ai-gateway-limits --remote --file ../gateway/limits-schema.sql",
1313
"wrangler-secret-put": "wrangler secret put",
1414
"generate-api-key": "node generate_api_key.js",
15-
"typegen": "wrangler types --strict-vars false --include-runtime false && prettier worker-configuration.d.ts --write"
15+
"typegen": "wrangler types --strict-vars false --include-runtime false"
1616
},
1717
"dependencies": {
1818
"@pydantic/logfire-api": "^0.8.1",

deploy/src/db.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ApiKeyInfo, KeysDbD1, KeyStatus, ProviderProxy } from '@pydantic/ai-gateway'
1+
import { type ApiKeyInfo, type KeyStatus, KeysDbD1, type ProviderProxy } from '@pydantic/ai-gateway'
22
import { config } from './config'
33

44
export class ConfigDB extends KeysDbD1 {

deploy/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ You should have received a copy of the GNU Affero General Public License
1515
along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
*/
1717

18-
import { GatewayEnv, gatewayFetch, LimitDbD1 } from '@pydantic/ai-gateway'
18+
import { env } from 'cloudflare:workers'
19+
import { type GatewayEnv, gatewayFetch, LimitDbD1 } from '@pydantic/ai-gateway'
1920
import * as logfire from '@pydantic/logfire-api'
2021
import { instrument } from '@pydantic/logfire-cf-workers'
21-
import { env } from 'cloudflare:workers'
2222
import { config } from './config'
2323
import { ConfigDB, hash } from './db'
2424
import { status } from './status'

deploy/src/status.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LimitDb, SpendStatus } from '@pydantic/ai-gateway'
1+
import type { LimitDb, SpendStatus } from '@pydantic/ai-gateway'
22
import { config } from './config'
33

44
interface EntityStatus {
@@ -80,7 +80,7 @@ function auth(request: Request, env: Env): Response | 'ok' {
8080

8181
const authHeader = request.headers.get('authorization')
8282

83-
let key
83+
let key: string
8484
if (authHeader) {
8585
if (authHeader.toLowerCase().startsWith('bearer ')) {
8686
key = authHeader.substring(7)

deploy/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { OtelSettings, ProviderProxy } from '@pydantic/ai-gateway'
1+
import type { OtelSettings, ProviderProxy } from '@pydantic/ai-gateway'
22

33
export interface Config<ProviderKey extends string = string> {
44
/** @param team: record keys are the team ids */

0 commit comments

Comments
 (0)