WhatsApp / erlfmt

An automated code formatter for Erlang
Apache License 2.0
412 stars 52 forks source link

Allow erlfmt:format_string to acccept filename as an option #336

Closed wingyplus closed 2 years ago

wingyplus commented 2 years ago

Hi,

I'm working on erlfmt_formatter_plugin which's bridge between mix formatter plugin and erlfmt. I found out that the erlfmt:format_string/2 doesn't allow to set filename (https://github.com/WhatsApp/erlfmt/blob/main/src/erlfmt.erl#L132), this cause the formatter plugin display filename as nofile when combining with erlfmt:format_error_info.

My proposal is allow erlfmt:format_string/2 to accept filename as an options and default to nofile when it doesn't set. I can open a PR to implement this.

What do you think?

michalmuskala commented 2 years ago

Yeah, that sounds reasonable. PR is definitely welcome

wingyplus commented 2 years ago

PR opened ☝️