Skip to content

Commit d2171dc

Browse files
authored
Use biome (#181)
Replace ESLint and Prettier with Biome <img width="703" height="110" alt="image" src="https://github.com/user-attachments/assets/84ca4bdb-6994-4d32-bc47-247cc8b1684e" /> ```release-note None ```
1 parent 5a5d657 commit d2171dc

40 files changed

+809
-1277
lines changed

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lint-staged

biome.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.1.2/schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
8+
"files": {
9+
"ignoreUnknown": false,
10+
"includes": ["**", "!**/generated/**"]
11+
},
12+
"formatter": {
13+
"enabled": true,
14+
"indentStyle": "space",
15+
"indentWidth": 2
16+
},
17+
"linter": {
18+
"enabled": true,
19+
"rules": {
20+
"recommended": true
21+
}
22+
},
23+
"javascript": {
24+
"formatter": {
25+
"quoteStyle": "single",
26+
"trailingCommas": "es5"
27+
}
28+
},
29+
"assist": {
30+
"enabled": true,
31+
"actions": {
32+
"source": {
33+
"organizeImports": "on"
34+
}
35+
}
36+
}
37+
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ node {
3232
}
3333

3434
tasks.register('buildFrontend', PnpmTask) {
35-
args = ['build:packages']
35+
args = ['build']
3636
dependsOn('installDepsForUI')
3737
}
3838

package.json

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"license": "GPL-3.0",
33
"author": {
4-
"name": "Halo OSS Team",
4+
"name": "Halo",
55
"url": "https://github.com/halo-dev"
66
},
77
"contributors": [
@@ -12,20 +12,23 @@
1212
}
1313
],
1414
"scripts": {
15-
"build:packages": "pnpm --filter \"./packages/**\" build",
16-
"example:dev": "pnpm --filter \"./packages/example\" dev",
17-
"release:packages": "pnpm --filter \"./packages/**\" release"
15+
"build": "pnpm -r run build",
16+
"check": "biome check --write",
17+
"example:dev": "pnpm -C packages/example dev",
18+
"prepare": "husky",
19+
"release": "pnpm -r run release"
20+
},
21+
"lint-staged": {
22+
"*": [
23+
"biome check --no-errors-on-unmatched --files-ignore-unknown=true"
24+
]
1825
},
1926
"devDependencies": {
20-
"@rushstack/eslint-patch": "^1.7.2",
27+
"@biomejs/biome": "^2.1.2",
2128
"@tsconfig/node18": "^18.2.2",
2229
"@types/node": "^18.19.18",
23-
"@typescript-eslint/eslint-plugin": "^6.21.0",
24-
"@typescript-eslint/parser": "^6.21.0",
25-
"eslint": "^8.57.0",
26-
"eslint-config-prettier": "^9.1.0",
27-
"eslint-plugin-prettier": "^5.1.3",
28-
"prettier": "^3.2.5",
30+
"husky": "^9.1.7",
31+
"lint-staged": "^16.1.2",
2932
"typescript": "~5.3.3",
3033
"vite": "^5.1.4"
3134
},

packages/comment-widget/.eslintrc.json

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

packages/comment-widget/.gitignore

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

packages/comment-widget/.prettierrc.json

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
{
22
"$schema": "https://raw.githubusercontent.com/lit/lit/main/packages/localize-tools/config.schema.json",
33
"sourceLocale": "en",
4-
"targetLocales": [
5-
"es",
6-
"zh-CN",
7-
"zh-TW"
8-
],
4+
"targetLocales": ["es", "zh-CN", "zh-TW"],
95
"tsConfig": "./tsconfig.json",
106
"output": {
117
"mode": "runtime",
@@ -16,4 +12,4 @@
1612
"format": "xliff",
1713
"xliffDir": "./xliff/"
1814
}
19-
}
15+
}

packages/comment-widget/package.json

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
],
2929
"scripts": {
3030
"build": "tsc",
31-
"dev": "tsc -w",
32-
"lint": "lit-analyzer && eslint 'src/**/*.ts'",
33-
"prettier": "prettier \"**/*.{cjs,html,js,json,md,ts}\" --ignore-path ./.gitignore --write"
31+
"dev": "tsc -w"
3432
},
3533
"dependencies": {
3634
"@emoji-mart/data": "^1.1.2",
@@ -39,13 +37,12 @@
3937
"@lit/localize": "^0.12.2",
4038
"dayjs": "^1.11.10",
4139
"emoji-mart": "^5.5.2",
40+
"es-toolkit": "^1.39.7",
4241
"javascript-time-ago": "^2.5.9",
43-
"lit": "^3.1.2",
44-
"lodash-es": "^4.17.21"
42+
"lit": "^3.1.2"
4543
},
4644
"devDependencies": {
4745
"@lit/localize-tools": "^0.8.0",
48-
"@types/lodash-es": "^4.17.12",
4946
"lit-analyzer": "^2.0.3"
5047
}
5148
}

packages/comment-widget/src/avatar/avatar-policy.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { CommentVo, ReplyVo } from '@halo-dev/api-client';
1+
import type { CommentVo, ReplyVo } from '@halo-dev/api-client';
22
import { getAvatarProvider } from './providers';
33

44
abstract class AvatarPolicy {
5-
abstract applyCommentPolicy(comment: CommentVo | undefined): string | undefined;
5+
abstract applyCommentPolicy(
6+
comment: CommentVo | undefined
7+
): string | undefined;
68
abstract applyReplyPolicy(reply: ReplyVo | undefined): string | undefined;
79
}
810

@@ -15,15 +17,19 @@ class AnonymousUserPolicy extends AvatarPolicy {
1517
const avatarProvider = getAvatarProvider();
1618
const isAnonymous = comment?.owner.kind === emailKind;
1719
if (isAnonymous) {
18-
return avatarProvider?.getAvatarSrc(comment?.spec.owner.annotations?.[emailHash]);
20+
return avatarProvider?.getAvatarSrc(
21+
comment?.spec.owner.annotations?.[emailHash]
22+
);
1923
}
2024
return comment?.owner.avatar;
2125
}
2226
applyReplyPolicy(reply: ReplyVo | undefined): string | undefined {
2327
const avatarProvider = getAvatarProvider();
2428
const isAnonymous = reply?.owner.kind === emailKind;
2529
if (isAnonymous) {
26-
return avatarProvider?.getAvatarSrc(reply?.spec.owner.annotations?.[emailHash]);
30+
return avatarProvider?.getAvatarSrc(
31+
reply?.spec.owner.annotations?.[emailHash]
32+
);
2733
}
2834
return reply?.owner.avatar;
2935
}
@@ -32,11 +38,15 @@ class AnonymousUserPolicy extends AvatarPolicy {
3238
class AllUserPolicy extends AvatarPolicy {
3339
applyCommentPolicy(comment: CommentVo | undefined): string | undefined {
3440
const avatarProvider = getAvatarProvider();
35-
return avatarProvider?.getAvatarSrc(comment?.spec.owner.annotations?.[emailHash]);
41+
return avatarProvider?.getAvatarSrc(
42+
comment?.spec.owner.annotations?.[emailHash]
43+
);
3644
}
3745
applyReplyPolicy(reply: ReplyVo | undefined): string | undefined {
3846
const avatarProvider = getAvatarProvider();
39-
return avatarProvider?.getAvatarSrc(reply?.spec.owner.annotations?.[emailHash]);
47+
return avatarProvider?.getAvatarSrc(
48+
reply?.spec.owner.annotations?.[emailHash]
49+
);
4050
}
4151
}
4252

@@ -46,7 +56,9 @@ class NoAvatarUserPolicy extends AvatarPolicy {
4656
const isAnonymous = comment?.owner.kind === emailKind;
4757
const avatar = comment?.owner.avatar;
4858
if (isAnonymous || !avatar) {
49-
return avatarProvider?.getAvatarSrc(comment?.spec.owner.annotations?.[emailHash]);
59+
return avatarProvider?.getAvatarSrc(
60+
comment?.spec.owner.annotations?.[emailHash]
61+
);
5062
}
5163
return avatar;
5264
}
@@ -55,7 +67,9 @@ class NoAvatarUserPolicy extends AvatarPolicy {
5567
const isAnonymous = reply?.owner.kind === emailKind;
5668
const avatar = reply?.owner.avatar;
5769
if (isAnonymous || !avatar) {
58-
return avatarProvider?.getAvatarSrc(reply?.spec.owner.annotations?.[emailHash]);
70+
return avatarProvider?.getAvatarSrc(
71+
reply?.spec.owner.annotations?.[emailHash]
72+
);
5973
}
6074
return avatar;
6175
}

0 commit comments

Comments
 (0)