-
-
Notifications
You must be signed in to change notification settings - Fork 0
JSON or YAML syntax trees #1
Comments
I think JSON (and potentially JS) is super interesting! What do you plan on doing with the syntax tree? |
True, worst case YAML could be converted to JSON first using js-yaml or similar. Good question, for our purposes we probably would not need a CST, but I could totally see the benefits. I work over @stoplightio. We're building the next version of our platform, and it includes a full blown IDE for specifications - basically a visual designer + coding environment for specs like, Swagger, Markdown, JSON Schema, protobuf files, etc. I'm evaluating the current landscape of text processing tools and I gotta say, the unified ecosystem looks fantastic - great work! In particular, we need a unified AST for all of the specifications we might want to handle, so that the rest of our tooling has a single object shape to work with for a few reasons:
There are a few other reasons, but I'll stop there since I've already written a wall of text :). Pretty excited about what you've built, and thought I'd include a bit more information to see if you think the use case is a decent fit for unified. Incidentally, the json-to-ast ast is remarkably (no pun intended) close to unist. Looks like just a change of "loc" to "position", removal of the "loc.source" property, and lowercasing the "type" property. Am I missing anything there? |
Thinking about it a bit more, we'd probably have to create the below. For fast+refile, I'm not sure if work has already been done that overlaps in unified-engine, or the vfile ecosystem? This is all a bit of a different use case for unified then what's been done so far, but it feels like the possibilities could be awesome. OR I could be totally off-base here, and perhaps this sort of thing is better farmed off to individual validators and linters that are already built (like jsonlint, or the various swagger validation libraries that are really not very good unfortunately). You've got much more experience in this space than I, I'm all ears :).
|
Prettier would probably be interested in a YAML parser that provides access to comments (prettier/prettier#3017) so that they would be able to add full support for YAML. |
JSON
Probably not! I suggest creating something like
We could use Files
Could you expand a bit on what you’d envision this to be? There’s one plugin, YAML
I know that the folks behind YAML is super interesting, but I personally don’t have time to create a YAML parser, so we’d need someone to lead that development, or some company to sponsor it! |
I see huge potential for creation of utilities to provide deep static analysis of files for tools like Kubernetes and Ansible. Having a (hypothetical) re-yaml project would enable creating transformers to domain-aware ASTs. This would enable not only static analysis, but also robust documentation creation automation. If somebody is interested in working on this and priority is the issue I might be able to help find a sponsor for funding. |
Some of the hard work to support YAML in unified has already been done, the parser: https://github.com/ikatyang/yaml-unist-parser. As far as I know, you still need:
And optionally:
|
@wtcross As I see you work on Ansible, could you expand more on what you’d be interested in? |
Thanks for starting the discussion @marbemac! |
Have you all considered this use case? Would be really useful to be able to plug JSON into the unified ecosystem. I was beginning to look through https://github.com/vtrushin/json-to-ast until I thought, why not unified!?
The text was updated successfully, but these errors were encountered: