Extract the shell-syntax scanner from parse-command.ts into its own module

未关闭
#2,466 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
44/100
Issue 类型
重构
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript

调研方向

Read src/shared/parse-command.ts, focusing on scanShellSyntax, skipHeredoc, walkBodyPayloads, and the placeholder and line-continuation helpers; use PR #2068 for context. Extract the scanner and its private helpers into src/shared/parse-command-scanner.ts, making their shared state explicit. Run the existing test suite; done when it passes without assertion changes and parseCommand's exported contract is unchanged.

由索引模型根据 Issue 内容生成。

描述

enhancement

scanShellSyntax in src/shared/parse-command.ts is roughly two thirds of the file — 2,150 of 3,230 lines — and its two largest pieces, skipHeredoc and walkBodyPayloads, are inner closures that share mutable scanner state. Moving it into a module of its own would let each rule be read and tested on its own.

  • Move scanShellSyntax and the helpers only it uses (skipHeredoc, walkBodyPayloads, the placeholder and line-continuation helpers) into e.g. src/shared/parse-command-scanner.ts, leaving parseCommand and the tokenizer as its only consumer.
  • Make the state the two closures share explicit at the boundary — which quote or substitution the scanner is inside, the results collected so far, the nesting depth — passed or returned as a named object instead of captured.
  • Change no behavior: parseCommand's exported contract stays as is, and the existing test suite stays green with no assertion changes.

Context: PR #2068 (https://github.com/Zoo-Code-Org/Zoo-Code/pull/2068), commit b193815dddcd6e82e80bf31bc5ea84dd15bd48e4.

主要语言
TypeScript
星标
2k
派生
301
平均合并
3 天 14 小时
30 天内合并 PR
103

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Zoo-Code-Org/Zoo-Code 的其他 Issue

查看 Zoo-Code-Org/Zoo-Code 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。