Adjust ESLint rules and resolve warnings - #147
Conversation
b3189b7 to
1fe0f93
Compare
1fe0f93 to
a8a6324
Compare
🤖 Codex-Style Code Review by OpenCode
|
🤖 Codex-Style Code Review by OpenCode
🔴 PR 代码审查概述本次变更涉及 16 个文件,核心主题是:提取公共模式、增强类型安全、修复竞态条件和内存泄漏、降低圈复杂度。整体方向积极,但有几项需要重点关注。 🔴 [blocking]
|
| 改进点 | 文件 |
|---|---|
Typed emits(defineEmits<{msgClick: [message: CommentResult]}>()) |
MessageList.vue |
try/finally 确保 loading.value = false 不会因异常跳过 |
MessageList.vue, NotificationList.vue, wortList.vue |
| 竞态条件保护(requestId 模式) | NotificationItem.vue, ExperimentSummary.vue, Profile.vue |
合理的函数提取:reportLoadError、appendMessages、createQuery |
多个组件 |
XSS 净化:移除 <script>、<foreignObject>、事件属性 |
advancedParser.ts |
removeToken 循环保护(WeakSet) |
utils.ts |
About.vue TypeScript 迁移 + 定时器清理 |
About.vue |
errorLogger.ts 类型安全改进 + dispose() 生命周期 |
errorLogger.ts |
apiError.ts 防重复挂载保护(closed flag) |
apiError.ts |
formatDate 拆分为 formatRelativeDate / formatAbsoluteDate |
utils.ts |
总结
| 级别 | 数量 | 关键项 |
|---|---|---|
| 🔴 blocking | 3 | 匿名 Token 硬编码、login headers 遗漏 version、SVG XSS 不充分 |
| 🟡 important | 5 | removeToken 就地修改、竞态条件不一致、watch 无 error handling、errorHandler 保存时机、cwrap 类型 |
| 🟢 nit | 4 | 常量提取、函数长度、Query 重建、类型假设 |
建议:修复 blocking 项后再合并,important 项需讨论或附带注释,nit 项可选。整体重构质量高,值得肯定。
a8a6324 to
7ad45cc
Compare
7ad45cc to
3214504
Compare
🤖 Codex-Style Code Review by OpenCode
|
🤖 Codex-Style Code Review by OpenCode
🔴 Review: Large-Scale Refactoring PROverall assessment: High-quality refactoring with meaningful improvements in type safety, memory management, race-condition handling, and code organization. The PR extracts repeated patterns, fixes lifecycle bugs, and improves consistency across components. Below are findings organized by severity. 🔴 Blocking1. Blind type assertion in function asNotificationMessages(items: unknown[]): NotificationMessage[] {
return items as NotificationMessage[]
}This is a type-erasing cast — no runtime validation. If 2. Parameter mutation in function appendMessages(messages: CommentResult[]) {
const receivedCount = messages.length
if (from) messages.shift() // mutates caller's array
3. Error:
🟡 Important4. app.config.errorHandler = (error, _instance, info) => {
this.captureError({ ... })
// NOTE: this.previousErrorHandler is never called
}The constructor saves 5. function reportLoadError(response, ...) {
showAPiError(..., handleLoad, ...) // retry calls handleLoad
}If 6. const ANONYMOUS_API_TOKEN = '7pEWTsF4gR9qauzJCDQkxPLOZlnbMtAG'If this is a public/shared token it should be documented as such. If it's sensitive, move to an env variable. Its module-level scope means it's bundled into every build. 7. const img = new Image()
img.src = `https://...`
// No abort if component unmounts before responseThe 8. 9. app.use(i18n)
// mount happens at the end now, after current is set
current = { close, title: titleRef, message: messageRef, retry }
app.mount(div)The old code mounted before assigning 🟢 Nits & Suggestions10. 11. 12. const rawHtml = await advancedParser(source, ...getParserContext(context))This is fine but implicitly couples the tuple order to 13. 14. Summary
General praise: The PR consistently improves race-condition safety (request counters), eliminates DOM leaks (duplicate IDs, timer cleanup), adds |
Summary
Dependency
This PR is based on #165 so Mermaid SVG rendering is sanitized before this refactor is merged.
Verification
Closes #139