I was looking through the prettier docs and the prettier source code. It essentially has those defined helper functions to layout the text, given an AST. It operates on the level of the whole file, on many elements next to each other. It takes the AST and outputs text, not outputting a modified AST (like ESLint does).
In a similar fashion, I was looking at the ESLint code and some example rule implementations. ESLint works it seems by walking the AST and calling every plugin at every node, if the plugin has a handler for that node type. The plugin then rewires the AST. It doesn't really operate on whitespace or text so much, more on the AST.
They seem extremely close to each other, even though it is recommended to use both. But I'm wondering, what lessons can be learned from the architecture of these and similar linting/formatting tools? If it was done again, could they be combined into one tool?
I am working on a custom language and would like to have code formatting and linting, and taking inspiration from these projects (though the code implementing them is quite complex). It seems to me their ideas can be merged to one underlying formalism, that is, manipulating the AST, and outputting text. I guess you still have two separate things (manipulating the AST, and constructing the output text), but it seems like they could be under one roof so as not to create confusion from a userland perspective. Is it better to keep these two concepts and programs separate, or to combine them?