Skip to content

Commit caeb211

Browse files
committed
chore: switch to biome and bun
1 parent 9934774 commit caeb211

File tree

16 files changed

+134
-4087
lines changed

16 files changed

+134
-4087
lines changed

.eslintrc

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

.prettierrc

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

.vscode/settings.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"npm.packageManager": "pnpm",
3+
"editor.formatOnSave": true,
4+
"biome.enabled": true,
5+
"eslint.enable": false,
6+
"editor.codeActionsOnSave": {
7+
"source.fixAll": "explicit",
8+
"source.organizeImports.biome": "explicit"
9+
},
10+
"typescript.tsdk": "node_modules/typescript/lib"
11+
}

biome.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.8.2/schema.json",
3+
"files": {
4+
"ignore": [
5+
"node_modules",
6+
"dist",
7+
"coverage",
8+
".pnpm-store"
9+
]
10+
},
11+
"formatter": {
12+
"enabled": true,
13+
"formatWithErrors": false,
14+
"indentStyle": "space",
15+
"indentWidth": 2,
16+
"lineEnding": "lf",
17+
"lineWidth": 120,
18+
"attributePosition": "auto"
19+
},
20+
"organizeImports": { "enabled": true },
21+
"linter": {
22+
"enabled": true,
23+
"rules": {
24+
"recommended": true,
25+
"correctness": {
26+
"noVoidTypeReturn": "off"
27+
},
28+
"style": {
29+
"noParameterAssign": "off"
30+
},
31+
"suspicious": {
32+
"noAssignInExpressions": "off",
33+
"noExplicitAny": "off"
34+
}
35+
}
36+
},
37+
"javascript": {
38+
"formatter": {
39+
"jsxQuoteStyle": "double",
40+
"quoteProperties": "asNeeded",
41+
"trailingCommas": "none",
42+
"semicolons": "asNeeded",
43+
"arrowParentheses": "always",
44+
"bracketSpacing": true,
45+
"bracketSameLine": false,
46+
"quoteStyle": "single",
47+
"attributePosition": "auto"
48+
}
49+
}
50+
}

bun.lockb

127 KB
Binary file not shown.

commitlint.config.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
// eslint-disable-next-line @typescript-eslint/no-var-requires
2-
const defaultConfig = require('@commitlint/config-conventional')
1+
import commitlint from '@commitlint/config-conventional'
32

4-
module.exports = {
3+
export default {
54
extends: ['@commitlint/config-conventional'],
6-
rules: {
7-
...defaultConfig.rules,
8-
'type-enum': [
9-
2,
10-
'always',
11-
['fix', 'test', 'tooling', 'refactor', 'revert', 'example', 'docs', 'format', 'feat', 'chore']
12-
]
13-
}
5+
...commitlint.rules,
6+
'type-enum': [
7+
2,
8+
'always',
9+
['fix', 'test', 'tooling', 'refactor', 'revert', 'example', 'docs', 'format', 'feat', 'chore', 'ci']
10+
]
1411
}

examples/basic.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { App, Request } from '@tinyhttp/app'
1+
import { App, type Request } from '@tinyhttp/app'
22

3-
import { tinyws, TinyWSRequest } from '../src/index'
3+
import { type TinyWSRequest, tinyws } from '../src/index'
44

5-
const app = new App<any, Request & TinyWSRequest>()
5+
const app = new App<Request & TinyWSRequest>()
66

77
app.use(tinyws())
88

@@ -11,9 +11,8 @@ app.use('/hmr', async (req, res) => {
1111
const ws = await req.ws()
1212

1313
return ws.send('hello there')
14-
} else {
15-
res.send('Hello from HTTP!')
1614
}
15+
res.send('Hello from HTTP!')
1716
})
1817

1918
app.listen(3000)

examples/chat/server.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { App, Request } from '@tinyhttp/app'
2-
import { WebSocket } from 'ws'
3-
import { tinyws, TinyWSRequest } from '../../src/index'
1+
import { App, type Request } from '@tinyhttp/app'
2+
import type { WebSocket } from 'ws'
3+
import { type TinyWSRequest, tinyws } from '../../src/index'
44

5-
const app = new App<any, Request & TinyWSRequest>()
5+
const app = new App<Request & TinyWSRequest>()
66

77
app.use(tinyws())
88

@@ -18,10 +18,11 @@ app.use('/chat', async (req) => {
1818
console.log('Received message:', message)
1919

2020
// broadcast
21+
// biome-ignore lint/complexity/noForEach: <explanation>
2122
connections.forEach((socket) => socket.send(message))
2223
})
2324

24-
ws.on('close', () => (connections = connections.filter((conn) => (conn === ws ? false : true))))
25+
ws.on('close', () => (connections = connections.filter((conn) => conn !== ws)))
2526
}
2627
})
2728

examples/express.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import express from 'express'
2-
import ws from 'ws'
1+
import * as express from 'express'
2+
import type { WebSocket } from 'ws'
33
import { tinyws } from '../src/index'
44

5-
export {}
6-
75
declare global {
86
namespace Express {
97
export interface Request {
10-
ws: () => Promise<ws>
8+
ws: () => Promise<WebSocket>
119
}
1210
}
1311
}
@@ -19,9 +17,8 @@ app.use('/hmr', tinyws(), async (req, res) => {
1917
const ws = await req.ws()
2018

2119
return ws.send('hello from express@4')
22-
} else {
23-
res.send('Hello from HTTP!')
2420
}
21+
res.send('Hello from HTTP!')
2522
})
2623

2724
app.listen(3000)

examples/polka.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import polka, { Request } from 'polka'
1+
import * as polka from 'polka'
22

3-
import { tinyws, TinyWSRequest } from '../src/index'
3+
import { type TinyWSRequest, tinyws } from '../src/index'
44

5-
const app = polka<Request & TinyWSRequest>()
5+
const app = polka<polka.Request & TinyWSRequest>()
66

77
app.use(tinyws())
88

@@ -11,9 +11,8 @@ app.use('/hmr', async (req, res) => {
1111
const ws = await req.ws()
1212

1313
return ws.send('hello from polka@1.0')
14-
} else {
15-
res.end('Hello from HTTP!')
1614
}
15+
res.end('Hello from HTTP!')
1716
})
1817

1918
app.listen(3000)

0 commit comments

Comments
 (0)