Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Trailing comma in AST

未关闭
#4,091 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
冷清
技术栈
ruby
领域
compilers

调研方向

首先阅读 Prism 对 ArrayNode 和 HashNode 的处理方式,以及 rubyfmt 如何使用 Prism 的 AST。调查是否可以在不改变现有格式化行为的情况下,表示这些节点是否存在尾随逗号。完成标准是记录一项关于 Prism 是否应跟踪此信息的具体建议。

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

描述

enhancement

For background, Stripe uses rubyfmt to format Ruby. One thing rubyfmt doesn't have today is trailing commas: all trailing commas are stripped by formatting, which is the preference of the maintainers of that project.

For a while I've wished for something like "rubyfmt + trailing commas." Before it even makes sense to have the conversation about whether to make that change, I was thinking through what it would even look like in practice. One thing which would make things easier to adopt would be if rubyfmt could run in a mode that preserves trailing commas, rather than universally adding or removing them (you could migrate slices of a codebase at a time, instead of having to land a PR touching hundreds of thousands of files all at once).

rubyfmt now uses prism for parsing Ruby files, and prism omits information about whether various constructs had trailing commas.

I was curious to get a temperature check on whether this is something that prism would ever want to see tracked. For example, in ArrayNode or in HashNode, to have some way to know that the user had written a trailing comma.

This is a very "what if" sort of line of thought, so please don't feel rushed to answer, and also I completely understand if the answer is definitively "that's not something prism is open to incorporating."

主要语言
C
星标
1k
派生
194
平均合并
2 天 6 小时
30 天内合并 PR
15

贡献指南

打开贡献指南

从这里开始

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

ruby/prism 的其他 Issue

查看 ruby/prism 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

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