Skip to content

Commit

Permalink
chore(frontend): 迁移到 biome (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
yansongda authored May 3, 2024
1 parent 6c375b0 commit 6d47edc
Show file tree
Hide file tree
Showing 47 changed files with 1,222 additions and 2,238 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/coding-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
with:
toolchain: stable
- name: Cache crates
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
Expand All @@ -47,7 +47,7 @@ jobs:
toolchain: stable
components: rustfmt, clippy
- name: Cache crates
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
Expand All @@ -72,11 +72,11 @@ jobs:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: latest
- name: Install pnpm
uses: pnpm/action-setup@v2
uses: pnpm/action-setup@v3
with:
version: latest
run_install: false
Expand All @@ -85,7 +85,7 @@ jobs:
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
Expand All @@ -96,4 +96,4 @@ jobs:
pnpm i
- name: Run pnpm lint
run: |
pnpm run lint
pnpm biome:check
9 changes: 0 additions & 9 deletions .prettierrc

This file was deleted.

6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v1.4.3

### chore

- chore(frontend): 迁移到 biome(#65)

## v1.4.2

### fixed
Expand Down
15 changes: 15 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.2/schema.json",
"files": {
"ignore": ["miniprogram/miniprogram_npm/**/*"]
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
}
}
14 changes: 0 additions & 14 deletions eslint.config.js

This file was deleted.

33 changes: 18 additions & 15 deletions miniprogram/api/accessToken.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import http from '@utils/http'
import { URL } from '@constant/accessToken'
import { CODE } from '@constant/error'
import logger from '@utils/logger'
import error from '@utils/error'
import { HttpError } from '@models/error'
import type { LoginRequest, LoginResponse } from 'types/accessToken'
import { URL } from "@constant/accessToken";
import { CODE } from "@constant/error";
import { HttpError } from "@models/error";
import error from "@utils/error";
import http from "@utils/http";
import logger from "@utils/logger";
import type { LoginRequest, LoginResponse } from "types/accessToken";

const login = async (code: string) => {
try {
return await http.post<LoginResponse>(URL.LOGIN, { code } as LoginRequest)
} catch (e: unknown) {
logger.error('登录接口请求失败', e)
try {
return await http.post<LoginResponse>(URL.LOGIN, { code } as LoginRequest);
} catch (e: unknown) {
logger.error("登录接口请求失败", e);

throw new HttpError(CODE.HTTP_API_ACCESS_TOKEN_LOGIN, error.getErrorMessage(e))
}
}
throw new HttpError(
CODE.HTTP_API_ACCESS_TOKEN_LOGIN,
error.getErrorMessage(e),
);
}
};

export default { login }
export default { login };
37 changes: 20 additions & 17 deletions miniprogram/api/shortUrl.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import http from '@utils/http'
import { URL } from '@constant/shortUrl'
import { CODE } from '@constant/error'
import { HttpError } from '@models/error'
import logger from '@utils/logger'
import error from '@utils/error'
import type { CreateRequest, CreateResponse } from 'types/shortUrl'
import { CODE } from "@constant/error";
import { URL } from "@constant/shortUrl";
import { HttpError } from "@models/error";
import error from "@utils/error";
import http from "@utils/http";
import logger from "@utils/logger";
import type { CreateRequest, CreateResponse } from "types/shortUrl";

const create = async (url: string) => {
try {
return await http.post<CreateResponse>(URL.CREATE, {
url
} as CreateRequest)
} catch (e: unknown) {
logger.error('创建短链接失败', e)
try {
return await http.post<CreateResponse>(URL.CREATE, {
url,
} as CreateRequest);
} catch (e: unknown) {
logger.error("创建短链接失败", e);

throw new HttpError(CODE.HTTP_API_SHORT_URL_CREATE, error.getErrorMessage(e))
}
}
throw new HttpError(
CODE.HTTP_API_SHORT_URL_CREATE,
error.getErrorMessage(e),
);
}
};

export default { create }
export default { create };
98 changes: 49 additions & 49 deletions miniprogram/api/totp.ts
Original file line number Diff line number Diff line change
@@ -1,66 +1,66 @@
import http from '@utils/http'
import { URL } from '@constant/totp'
import { CODE } from '@constant/error'
import { HttpError } from '@models/error'
import logger from '@utils/logger'
import error from '@utils/error'
import { CODE } from "@constant/error";
import { URL } from "@constant/totp";
import { HttpError } from "@models/error";
import error from "@utils/error";
import http from "@utils/http";
import logger from "@utils/logger";
import type {
CreateRequest,
DeleteRequest,
DetailRequest,
Item,
Response,
UpdateRequest
} from 'types/totp'
CreateRequest,
DeleteRequest,
DetailRequest,
Item,
Response,
UpdateRequest,
} from "types/totp";

const all = async () => {
try {
return await http.post<Item[]>(URL.ALL)
} catch (e: unknown) {
logger.error('查询 TOTP 列表失败', e)
try {
return await http.post<Item[]>(URL.ALL);
} catch (e: unknown) {
logger.error("查询 TOTP 列表失败", e);

throw new HttpError(CODE.HTTP_API_TOTP_ALL, error.getErrorMessage(e))
}
}
throw new HttpError(CODE.HTTP_API_TOTP_ALL, error.getErrorMessage(e));
}
};

const detail = async (id: number) => {
try {
return await http.post<Item>(URL.DETAIL, { id } as DetailRequest)
} catch (e: unknown) {
logger.error('查询 TOTP 详情失败', e)
try {
return await http.post<Item>(URL.DETAIL, { id } as DetailRequest);
} catch (e: unknown) {
logger.error("查询 TOTP 详情失败", e);

throw new HttpError(CODE.HTTP_API_TOTP_DETAIL, error.getErrorMessage(e))
}
}
throw new HttpError(CODE.HTTP_API_TOTP_DETAIL, error.getErrorMessage(e));
}
};

const create = async (uri: string) => {
try {
return await http.post<Response>(URL.CREATE, { uri } as CreateRequest)
} catch (e: unknown) {
logger.error('创建 TOTP 失败', e)
try {
return await http.post<Response>(URL.CREATE, { uri } as CreateRequest);
} catch (e: unknown) {
logger.error("创建 TOTP 失败", e);

throw new HttpError(CODE.HTTP_API_TOTP_CREATE, error.getErrorMessage(e))
}
}
throw new HttpError(CODE.HTTP_API_TOTP_CREATE, error.getErrorMessage(e));
}
};

const update = async (data: UpdateRequest) => {
try {
return await http.post<Response>(URL.UPDATE, data)
} catch (e: unknown) {
logger.error('更新 TOTP 信息失败', e)
try {
return await http.post<Response>(URL.UPDATE, data);
} catch (e: unknown) {
logger.error("更新 TOTP 信息失败", e);

throw new HttpError(CODE.HTTP_API_TOTP_UPDATE, error.getErrorMessage(e))
}
}
throw new HttpError(CODE.HTTP_API_TOTP_UPDATE, error.getErrorMessage(e));
}
};

const deleteTotp = async (id: number) => {
try {
return await http.post<Response>(URL.DELETE, { id } as DeleteRequest)
} catch (e: unknown) {
logger.error('删除 TOTP 失败', e)
try {
return await http.post<Response>(URL.DELETE, { id } as DeleteRequest);
} catch (e: unknown) {
logger.error("删除 TOTP 失败", e);

throw new HttpError(CODE.HTTP_API_TOTP_ALL, error.getErrorMessage(e))
}
}
throw new HttpError(CODE.HTTP_API_TOTP_ALL, error.getErrorMessage(e));
}
};

export default { all, detail, create, update, deleteTotp }
export default { all, detail, create, update, deleteTotp };
44 changes: 22 additions & 22 deletions miniprogram/api/user.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import http from '@utils/http'
import { URL } from '@constant/user'
import { CODE } from '@constant/error'
import logger from '@utils/logger'
import error from '@utils/error'
import { HttpError } from '@models/error'
import type { DetailResponse, UpdateRequest, UpdateResponse } from 'types/user'
import { CODE } from "@constant/error";
import { URL } from "@constant/user";
import { HttpError } from "@models/error";
import error from "@utils/error";
import http from "@utils/http";
import logger from "@utils/logger";
import type { DetailResponse, UpdateRequest, UpdateResponse } from "types/user";

const detail = async () => {
try {
return await http.post<DetailResponse>(URL.DETAIL)
} catch (e: unknown) {
logger.error('查询用户详情失败', e)
try {
return await http.post<DetailResponse>(URL.DETAIL);
} catch (e: unknown) {
logger.error("查询用户详情失败", e);

throw new HttpError(CODE.HTTP_API_USER_DETAIL, error.getErrorMessage(e))
}
}
throw new HttpError(CODE.HTTP_API_USER_DETAIL, error.getErrorMessage(e));
}
};

const update = async (updated: UpdateRequest) => {
try {
return await http.post<UpdateResponse>(URL.UPDATE, updated)
} catch (e: unknown) {
logger.error('更新用户信息失败', e)
try {
return await http.post<UpdateResponse>(URL.UPDATE, updated);
} catch (e: unknown) {
logger.error("更新用户信息失败", e);

throw new HttpError(CODE.HTTP_API_USER_UPDATE, error.getErrorMessage(e))
}
}
throw new HttpError(CODE.HTTP_API_USER_UPDATE, error.getErrorMessage(e));
}
};

export default { detail, update }
export default { detail, update };
Loading

0 comments on commit 6d47edc

Please sign in to comment.