chore(frontend): introduce prettier + eslint and prune unused code
- Add Prettier 3 with prettier-plugin-organize-imports (sorts/removes unused imports) - Add ESLint 10 flat config with typescript-eslint + eslint-plugin-vue + eslint-config-prettier - Add root scripts: format, format:check, lint, lint:fix - Reformat 257 files across admin-web, ops-web, desktop-client, packages - Remove unused locals/exports flagged by --noUnusedLocals/--noUnusedParameters - Fix duplicate localTabLabel key, surrogate-pair regex u-flag, NBSP literal in regex - Skip server/ (Go) and apps/browser-extension/ (deprecated per ADR) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,130 +1,130 @@
|
||||
import { beforeAll, describe, expect, it, vi } from "vitest";
|
||||
import { beforeAll, describe, expect, it, vi } from 'vitest'
|
||||
|
||||
vi.mock("./account-binder", () => ({
|
||||
vi.mock('./account-binder', () => ({
|
||||
probePublishAccountSession: vi.fn(),
|
||||
silentRefreshPublishAccountSession: vi.fn(),
|
||||
}));
|
||||
}))
|
||||
|
||||
let getPlatformAdapter: typeof import("./platform-auth-adapters").getPlatformAdapter;
|
||||
let getPlatformAdapter: typeof import('./platform-auth-adapters').getPlatformAdapter
|
||||
|
||||
beforeAll(async () => {
|
||||
({ getPlatformAdapter } = await import("./platform-auth-adapters"));
|
||||
});
|
||||
;({ getPlatformAdapter } = await import('./platform-auth-adapters'))
|
||||
})
|
||||
|
||||
describe("platform auth adapters", () => {
|
||||
it("classifies Wenxin environment abnormal messages as risk control", () => {
|
||||
const adapter = getPlatformAdapter("wenxin");
|
||||
describe('platform auth adapters', () => {
|
||||
it('classifies Wenxin environment abnormal messages as risk control', () => {
|
||||
const adapter = getPlatformAdapter('wenxin')
|
||||
|
||||
expect(
|
||||
adapter.classifyFailure({
|
||||
message: "当前访问环境存在异常,请更换浏览器再尝试提问",
|
||||
message: '当前访问环境存在异常,请更换浏览器再尝试提问',
|
||||
}),
|
||||
).toBe("risk_control");
|
||||
});
|
||||
).toBe('risk_control')
|
||||
})
|
||||
|
||||
it("classifies Qiehao missing cookie as auth failure", () => {
|
||||
const adapter = getPlatformAdapter("qiehao");
|
||||
it('classifies Qiehao missing cookie as auth failure', () => {
|
||||
const adapter = getPlatformAdapter('qiehao')
|
||||
|
||||
expect(
|
||||
adapter.classifyFailure({
|
||||
error: {
|
||||
code: "qiehao_cookie_missing",
|
||||
code: 'qiehao_cookie_missing',
|
||||
},
|
||||
}),
|
||||
).toBe("auth_failure");
|
||||
});
|
||||
).toBe('auth_failure')
|
||||
})
|
||||
|
||||
it("classifies Bilibili missing csrf as auth failure", () => {
|
||||
const adapter = getPlatformAdapter("bilibili");
|
||||
it('classifies Bilibili missing csrf as auth failure', () => {
|
||||
const adapter = getPlatformAdapter('bilibili')
|
||||
|
||||
expect(
|
||||
adapter.classifyFailure({
|
||||
error: {
|
||||
code: "bilibili_csrf_missing",
|
||||
code: 'bilibili_csrf_missing',
|
||||
},
|
||||
}),
|
||||
).toBe("auth_failure");
|
||||
});
|
||||
).toBe('auth_failure')
|
||||
})
|
||||
|
||||
it("classifies Juejin missing login as auth failure", () => {
|
||||
const adapter = getPlatformAdapter("juejin");
|
||||
it('classifies Juejin missing login as auth failure', () => {
|
||||
const adapter = getPlatformAdapter('juejin')
|
||||
|
||||
expect(
|
||||
adapter.classifyFailure({
|
||||
error: {
|
||||
code: "juejin_not_logged_in",
|
||||
code: 'juejin_not_logged_in',
|
||||
},
|
||||
}),
|
||||
).toBe("auth_failure");
|
||||
});
|
||||
).toBe('auth_failure')
|
||||
})
|
||||
|
||||
it("classifies Sohuhao missing login as auth failure", () => {
|
||||
const adapter = getPlatformAdapter("sohuhao");
|
||||
it('classifies Sohuhao missing login as auth failure', () => {
|
||||
const adapter = getPlatformAdapter('sohuhao')
|
||||
|
||||
expect(
|
||||
adapter.classifyFailure({
|
||||
error: {
|
||||
code: "sohuhao_not_logged_in",
|
||||
code: 'sohuhao_not_logged_in',
|
||||
},
|
||||
}),
|
||||
).toBe("auth_failure");
|
||||
});
|
||||
).toBe('auth_failure')
|
||||
})
|
||||
|
||||
it("does not classify Wangyihao publish token misses as auth failure", () => {
|
||||
const adapter = getPlatformAdapter("wangyihao");
|
||||
it('does not classify Wangyihao publish token misses as auth failure', () => {
|
||||
const adapter = getPlatformAdapter('wangyihao')
|
||||
|
||||
expect(
|
||||
adapter.classifyFailure({
|
||||
error: {
|
||||
code: "wangyihao_token_missing",
|
||||
code: 'wangyihao_token_missing',
|
||||
},
|
||||
}),
|
||||
).toBe("ok");
|
||||
});
|
||||
).toBe('ok')
|
||||
})
|
||||
|
||||
it("classifies Weixin GZH verification as challenge", () => {
|
||||
const adapter = getPlatformAdapter("weixin_gzh");
|
||||
it('classifies Weixin GZH verification as challenge', () => {
|
||||
const adapter = getPlatformAdapter('weixin_gzh')
|
||||
|
||||
expect(
|
||||
adapter.classifyFailure({
|
||||
error: {
|
||||
code: "weixin_gzh_challenge_required",
|
||||
code: 'weixin_gzh_challenge_required',
|
||||
},
|
||||
}),
|
||||
).toBe("challenge");
|
||||
});
|
||||
).toBe('challenge')
|
||||
})
|
||||
|
||||
it("classifies Weixin GZH login timeout as auth failure", () => {
|
||||
const adapter = getPlatformAdapter("weixin_gzh");
|
||||
it('classifies Weixin GZH login timeout as auth failure', () => {
|
||||
const adapter = getPlatformAdapter('weixin_gzh')
|
||||
|
||||
expect(
|
||||
adapter.classifyFailure({
|
||||
message: "登录超时,请重新登录",
|
||||
message: '登录超时,请重新登录',
|
||||
}),
|
||||
).toBe("auth_failure");
|
||||
});
|
||||
).toBe('auth_failure')
|
||||
})
|
||||
|
||||
it("classifies ZOL missing login as auth failure", () => {
|
||||
const adapter = getPlatformAdapter("zol");
|
||||
it('classifies ZOL missing login as auth failure', () => {
|
||||
const adapter = getPlatformAdapter('zol')
|
||||
|
||||
expect(
|
||||
adapter.classifyFailure({
|
||||
error: {
|
||||
code: "zol_not_logged_in",
|
||||
code: 'zol_not_logged_in',
|
||||
},
|
||||
}),
|
||||
).toBe("auth_failure");
|
||||
});
|
||||
).toBe('auth_failure')
|
||||
})
|
||||
|
||||
it("classifies Dongchedi platform verification as challenge", () => {
|
||||
const adapter = getPlatformAdapter("dongchedi");
|
||||
it('classifies Dongchedi platform verification as challenge', () => {
|
||||
const adapter = getPlatformAdapter('dongchedi')
|
||||
|
||||
expect(
|
||||
adapter.classifyFailure({
|
||||
error: {
|
||||
code: "dongchedi_challenge_required",
|
||||
code: 'dongchedi_challenge_required',
|
||||
},
|
||||
}),
|
||||
).toBe("challenge");
|
||||
});
|
||||
});
|
||||
).toBe('challenge')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user