buildtools
buildtools copied to clipboard
load-on-top should put the load at the right location
When a load
statement is put to the top with buildifier --lint=fix --warnings=load-on-top
, the statement is added to the end of the loads. This means the statement is not placed correctly according to --warnings=out-of-order-load
.
Should load-on-top
also sort the load statements that are already on top if they are not sorted? Should it do anything if all load statements are already on top but not sorted?
A simple solution is to assume that the statements are sorted and try to find the correct place to insert. This guarantees we're not regressing.
I don't know if we should sort the existing statements. It increases the diff, but maybe it's okay.
My end goal is to have out-of-order-load on by default in the formatter, but this will require updating lots of existing files. I think it would improve the user experience (they don't have to think where to put a load), and it's done by formatters in other languages.