Open thewatts opened 9 months ago
Hey @thewatts, thanks!
Before settling on SyntaxTree I tried a few different formatters, including Rufo and Rubocop (Rubocop was especially slow for this use case hard to use for small snippets).
But if you're ok with slower times I'm happy to accept a PR extracting the ruby formatting code
with a pluggable thing and allow for alternative formatters, e.g.:
SYNTAX_TREE_FORMATTER = ->(code) {
SyntaxTree::Command.prepend SyntaxTreeCommandPatch
code = begin
SyntaxTree.format(code, @line_width)
rescue SyntaxTree::Parser::ParseError => error
p RUBY_PARSE_ERROR: error if @debug
code
end
}
def initialize(...)
@ruby_formatter = ruby_formatter || SYNTAX_TREE_FORMATTER
# …
def format_ruby(code, autoclose: false)
# …
code = @ruby_formatter.call(code)
# …
end
I just jotted down this code, no need to take names and organization too seriously, I just wanted to convey the idea 😊
Having the ability to autocrrect the ruby code with something like rubocop would be super helpful.
Hi there! :)
I love that you're working on this - it's something my team has needed for a long long time.
Reaching out because we use
erb-lint
, as well asstandard
throughout our project.The fact that this formatted will autoformat is amazing - but I'm finding that it's clashing with our linting rules.
Is it possible for the formatting, for blocks of Ruby content, to possibly leverage another tool's rules? (ex: for
erb-lint
, we've configured it to usestandardrb
).I suppose practically - is it possible to format based on
erb-lint
's ruleset?Thanks for your help!