Skip to content

Commit

Permalink
Feature/biome (#456)
Browse files Browse the repository at this point in the history
* biome 追加

* biome 化

* eslint サヨナラ

* lint 対応していく

* 直せる範囲をなおす

* pnpm run lint は通るようになった

* pnpm up -L -r

* tslib を入れてみる

* 変更履歴を更新する
  • Loading branch information
voluntas authored Nov 17, 2023
1 parent d2a6a6a commit 274b97d
Show file tree
Hide file tree
Showing 22 changed files with 266 additions and 1,078 deletions.
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["biomejs.biome"]
}
20 changes: 20 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[javascript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[javascriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescript]": {
"editor.defaultFormatter": "biomejs.biome"
},
"[typescriptreact]": {
"editor.defaultFormatter": "biomejs.biome"
},
"editor.codeActionsOnSave": {
"quickfix.biome": true,
"source.organizeImports.biome": true
}
}
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

## develop

- [CHANGE] fmt / lint を biome へ移行する
- @voluntas
- [CHANGE] Node.js 16 系を落とす
- @voluntas
- [FIX] stopVideoTrack で例外を握りつぶしていたのを修正する
Expand Down
45 changes: 45 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"$schema": "https://biomejs.dev/schemas/1.3.3/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"ignore": [],
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100
},
"json": {
"parser": {
"allowComments": true
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100
}
},
"javascript": {
"formatter": {
"enabled": true,
"quoteStyle": "single",
"jsxQuoteStyle": "double",
"trailingComma": "all",
"semicolons": "asNeeded",
"arrowParentheses": "always",
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100,
"quoteProperties": "asNeeded"
}
}
}
11 changes: 3 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@
"dist"
],
"devDependencies": {
"@typescript-eslint/eslint-plugin": "6.11.0",
"@typescript-eslint/parser": "6.11.0",
"eslint": "8.53.0",
"eslint-config-prettier": "9.0.0",
"eslint-plugin-prettier": "5.0.1",
"prettier": "3.1.0",
"@biomejs/biome": "1.3.3",
"serve": "14.2.1",
"typedoc": "0.25.3",
"typescript": "5.2.2",
Expand All @@ -42,8 +37,8 @@
"resolutions": {
"get-pkg-repo": "5.0.0"
},
"packageManager": "[email protected].3",
"packageManager": "[email protected].5",
"engines": {
"node": ">=18.17.1"
}
}
}
76 changes: 0 additions & 76 deletions packages/e2ee/.eslintrc.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/e2ee/.prettierrc.json

This file was deleted.

7 changes: 4 additions & 3 deletions packages/e2ee/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@
"build": "pnpm run build:worker && pnpm run build:development",
"build:development": "NODE_ENV=development rollup -c rollup.config.mjs --bundleConfigAsCjs",
"build:worker": "tsc --project tsconfig.worker.json",
"fmt": "prettier --write src",
"lint": "eslint --ext .ts ./src",
"lint": "biome lint ./src",
"fmt": "biome format --write ./src",
"test": "echo \"no test\""
},
"devDependencies": {
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-replace": "5.0.5",
"@rollup/plugin-typescript": "11.1.5",
"rollup": "4.4.1"
"rollup": "4.4.1",
"tslib": "2.6.2"
},
"dependencies": {
"@sora/go-wasm": "workspace:^"
Expand Down
2 changes: 1 addition & 1 deletion packages/e2ee/src/sora_e2ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const WORKER_SCRIPT = '__WORKER_SCRIPT__'

class SoraE2EE {
worker: Worker | null
// eslint-disable-next-line @typescript-eslint/no-explicit-any
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
onWorkerDisconnect: (() => any) | null

constructor() {
Expand Down
24 changes: 14 additions & 10 deletions packages/e2ee/src/worker/e2ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ function setLatestRemoteKeyId(connectionId: string, keyId: number): void {
}

function removeOldRemoteDeriveKeys(): void {
// biome-ignore lint/complexity/noForEach: Array ではなく Map
latestRemoteKeyIdMap.forEach((latestKeyId, connectionId) => {
const deriveKeyMap = remoteDeriveKeyMap.get(connectionId)
if (deriveKeyMap) {
// biome-ignore lint/complexity/noForEach: Array ではなく Map
deriveKeyMap.forEach((_, keyId) => {
if (latestKeyId !== keyId) {
deriveKeyMap.delete(keyId)
Expand All @@ -99,7 +101,11 @@ function removeDeriveKey(connectionId: string): void {
remoteDeriveKeyMap.delete(connectionId)
}

function getLatestSelfDeriveKey(): { connectionId: string; keyId: number; deriveKey: CryptoKey } {
function getLatestSelfDeriveKey(): {
connectionId: string
keyId: number
deriveKey: CryptoKey
} {
const deriveKey = selfDeriveKeyMap.get('latest')
if (!deriveKey) {
throw new Error('LATEST-SELF-DERIVEKEY-NOT_FOUND')
Expand All @@ -110,7 +116,7 @@ function getLatestSelfDeriveKey(): { connectionId: string; keyId: number; derive
function setSelfDeriveKey(connectionId: string, keyId: number, deriveKey: CryptoKey): void {
const currentSelfDeriveKey = selfDeriveKeyMap.get('latest')
if (currentSelfDeriveKey) {
if (currentSelfDeriveKey['keyId'] < keyId) {
if (currentSelfDeriveKey.keyId < keyId) {
const nextSelfDeriveKey = { connectionId, keyId, deriveKey }
selfDeriveKeyMap.set('latest', nextSelfDeriveKey)
}
Expand All @@ -136,14 +142,12 @@ function silenceFrame(encodedFrame: Chunk): Chunk {
const newData = new ArrayBuffer(60)
const newUint8 = new Uint8Array(newData)

// prettier-ignore
newUint8.set([0xb0, 0x05, 0x00, 0x9d, 0x01, 0x2a, 0xa0, 0x00, 0x5a, 0x00,
0x39, 0x03, 0x00, 0x00, 0x1c, 0x22, 0x16, 0x16, 0x22, 0x66,
0x12, 0x20, 0x04, 0x90, 0x40, 0x00, 0xc5, 0x01, 0xe0, 0x7c,
0x4d, 0x2f, 0xfa, 0xdd, 0x4d, 0xa5, 0x7f, 0x89, 0xa5, 0xff,
0x5b, 0xa9, 0xb4, 0xaf, 0xf1, 0x34, 0xbf, 0xeb, 0x75, 0x36,
0x95, 0xfe, 0x26, 0x96, 0x60, 0xfe, 0xff, 0xba, 0xff, 0x40,
]);
newUint8.set([
0xb0, 0x05, 0x00, 0x9d, 0x01, 0x2a, 0xa0, 0x00, 0x5a, 0x00, 0x39, 0x03, 0x00, 0x00, 0x1c,
0x22, 0x16, 0x16, 0x22, 0x66, 0x12, 0x20, 0x04, 0x90, 0x40, 0x00, 0xc5, 0x01, 0xe0, 0x7c,
0x4d, 0x2f, 0xfa, 0xdd, 0x4d, 0xa5, 0x7f, 0x89, 0xa5, 0xff, 0x5b, 0xa9, 0xb4, 0xaf, 0xf1,
0x34, 0xbf, 0xeb, 0x75, 0x36, 0x95, 0xfe, 0x26, 0x96, 0x60, 0xfe, 0xff, 0xba, 0xff, 0x40,
])
encodedFrame.data = newData
}
return encodedFrame
Expand Down
2 changes: 1 addition & 1 deletion packages/e2ee/src/worker/sframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const connectionIdLength = 26

function byteCount(n: number): number {
if (n == 0) {
if (n === 0) {
return 1
}
// log256(x) = log(x) / log(256)
Expand Down
82 changes: 0 additions & 82 deletions packages/sdk/.eslintrc.json

This file was deleted.

7 changes: 0 additions & 7 deletions packages/sdk/.prettierrc.json

This file was deleted.

4 changes: 2 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"scripts": {
"build": "rollup -c rollup.config.mjs --bundleConfigAsCjs",
"watch": "rollup -c -w",
"lint": "eslint --ext .ts ./src",
"fmt": "prettier --write src",
"lint": "biome lint ./src",
"fmt": "biome format --write ./src",
"test": "vitest run"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit 274b97d

Please sign in to comment.