Skip to content

fix(lint): providers.ts 模型列表正则去掉多余转义(修 CI 红) - #22

Merged
1-ztc merged 1 commit into
mainfrom
fix/providers-no-useless-escape
Jul 26, 2026
Merged

fix(lint): providers.ts 模型列表正则去掉多余转义(修 CI 红)#22
1-ztc merged 1 commit into
mainfrom
fix/providers-no-useless-escape

Conversation

@1-ztc

@1-ztc 1-ztc commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

问题

main 上的 CI 全红(3 个平台全 fail),挂在一条 lint 错:

providers.ts:218  error  Unnecessary escape character: \-  no-useless-escape
✖ 1 problem (1 error)

根因

44a03d9(hostProvidesPlanStore + provider error hints)在 providers.ts:218 引入了:

msg.match(/(?:supported|available)\s+models?\s*[:\-]?\s*([^\n.]{5,})/i)
//                                              ^^
//                                              \- 在字符组 [] 内是多余转义

\- 在字符组里不必要(- 在末尾/开头本就是字面量)。no-useless-escape 规则报它。

为什么之前没挂

44a03d9 是直接 push 到 main 的(没走 PR/没触发 CI),所以这条 lint 错从未被 CI 抓过。PR #21(完成门死锁修复)merge 时触发的新 CI 是第一个完整跑 44a03d9 + lint 的,于是挂在 #21 的 merge commit 上 —— 但代码错不在 #21,在 44a03d9

Fix

[:\-]?[:-]?(去 \)。正则匹配行为完全不变([:-]?[:\-]? 都匹配可选的 :-),只是去掉多余转义。

已验证:三个测试用例(Supported models: [a,b] / Available models- gpt-4 / supported model foo)新旧正则匹配结果一模一样;lint EXIT=0;build ok。

影响

修这个 main 才能恢复 CI 绿(否则后续任何 PR 合进 main 都被这条拖红)。一行修。

🤖 Generated with Claude Code

The regex /(?:supported|available)\s+models?\s*[:\-]?\s*([^\n.]{5,})/i (added
in 44a03d9) used \- inside a character class, which eslint no-useless-escape
flags. \- is unnecessary there (a trailing - in [] is literal). CI failed on
main after merging #21 because that commit was the first to run the full
lint pipeline over 44a03d9's change. Change [:\-]? -> [:-]? — identical
match behavior (optional : or -), just no useless escape.

Co-Authored-By: Claude <noreply@anthropic.com>
@1-ztc
1-ztc merged commit 76796b2 into main Jul 26, 2026
3 checks passed
@1-ztc
1-ztc deleted the fix/providers-no-useless-escape branch July 26, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant