buildtools
buildtools copied to clipboard
How to ignore specific lines in buildifier?
Hi, I'm looking for the equivalent of "clang-format: off; clang-format: on" for buildifier to ignore specific lines of code. Does that feature exist?
What is your example, and why do you want this?
There are a few rules in: https://github.com/bazelbuild/buildtools/blob/195b83e94906df245fdc44da27b1be5489087025/build/rewrite.go including 'buildifier: leave-alone' will that handle your case?
@pmbethe09 I am actually looking for something similar as well.
My use case is I have classpath loading issue, and I do want to turn off buildifier for some code blocks. Thanks!
What exactly do you want to ignore?
If you use a linter and want to ignore a warning, use this: https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#how-to-disable-warnings
If you don't want a certain list to be automatically sorted, use a comment do not sort. If you want to disable any transformations like reordering rule arguments or shortening the labels, comment the node with buildifier: leave-alone.
It's not possible to disable formatting completely because formatting itself is not supposed to change the semantics. If it does, please file a bug.
what I am looking is to disable reordering for certain lines (something like below):
# buildifier: leave-alone
deps = [
"//modules/base",
"//modules/module-b",
"//modules/module-a",
]
https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#how-to-disable-warnings is probably what you are looking for.