You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A typical Bazel setup would involve several deps.bzl files, which declare several http_archive and other repository rules that are later loaded in WORKSPACE. In the future, with BzlMod support importing smaller files into MODULE.bazel, we expect to also have multiple deps.bzl files loaded there as well.
To effectively lint these files, the user would need to specify the correct file type. For example, a deps.bzl file that is loaded in WORKSPACE should be treated as WORKSPACE type and not bzl type.
Today, buildifier chooses the parser type based on (a) user-specified value in -type flag or (b) the file name. Given that (a) is not automatable, and (b) does not apply in many cases, there needs to be a better solution.
I think it would be best if we allow something like
# buildifier: type=WORKSPACE
that goes on the very top of the file so that we can switch the result file type after parsing the Starlark file.
A typical Bazel setup would involve several
deps.bzl
files, which declare severalhttp_archive
and other repository rules that are later loaded in WORKSPACE. In the future, with BzlMod support importing smaller files into MODULE.bazel, we expect to also have multiple deps.bzl files loaded there as well.To effectively lint these files, the user would need to specify the correct file type. For example, a
deps.bzl
file that is loaded in WORKSPACE should be treated as WORKSPACE type and notbzl
type.Today,
buildifier
chooses the parser type based on (a) user-specified value in-type
flag or (b) the file name. Given that (a) is not automatable, and (b) does not apply in many cases, there needs to be a better solution.I think it would be best if we allow something like
that goes on the very top of the file so that we can switch the result file type after parsing the Starlark file.
See the code at
buildtools/build/lex.go
Lines 157 to 169 in 80f1f68
The text was updated successfully, but these errors were encountered: