You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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."
Yeah, I would be okay with a flag on the various nodes that would need to support it (arrays, hashes, array patterns, hash patterns, find patterns, arguments). I wouldn't want it to be a node like rubyvm::ast.
Sorry I've actually changed my mind on this. I realized there are a lot of syntax-related concerns that we would want if we went down this road, like whether something was in a modifier form, whether something was a heredoc, whether there was a trailing comma, etc. I think I'd rather keep it just related to semantics and keep the syntax concerns out of it as much as possible.
Activity
kddnewton commentedon May 2, 2026
Yeah, I would be okay with a flag on the various nodes that would need to support it (arrays, hashes, array patterns, hash patterns, find patterns, arguments). I wouldn't want it to be a node like rubyvm::ast.
kddnewton commentedon Oct 13, 2026
Sorry I've actually changed my mind on this. I realized there are a lot of syntax-related concerns that we would want if we went down this road, like whether something was in a modifier form, whether something was a heredoc, whether there was a trailing comma, etc. I think I'd rather keep it just related to semantics and keep the syntax concerns out of it as much as possible.