building formatters • A set of language-specific parsers that build a prettier- specific intermediate representation (IR) • A printer for printing out prettier IR
source using ripper • Convert the ripper output to JSON and return to node • Walk the ripper tree with node to generate prettier IR • Ripper::SCANNER_EVENTS.size = 52 • Ripper::PARSER_EVENTS.size = 132
IR and print nodes as you go • At each node, call the correct print function for that node from the necessary plugin/printer • If you hit the line limit, break the outermost group
use parentheses (super will sometimes get parentheses) • no nested ternaries • decimal numbers will get underscores after 3 digits octal numbers will have an “o” added if it’s not there • {} lambdas for single line, do…end for multi-line • … and many more!