Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Buildifier doesn't recognise MODULE.bazel #1254

Open
wingsofovnia opened this issue Mar 19, 2024 · 0 comments
Open

Buildifier doesn't recognise MODULE.bazel #1254

wingsofovnia opened this issue Mar 19, 2024 · 0 comments

Comments

@wingsofovnia
Copy link

wingsofovnia commented Mar 19, 2024

I am using the latest buildifier to check Bazel files in a project with bzlmod enabled.

> ls -1
BUILD.bazel
MODULE.bazel
MODULE.bazel.lock
src

It appears to me that buildifier's linter incorrectly detects the type of MODULE.bazel files. There is a module-docstring violations in this file but buildifier reports nothing:

> buildifier --mode=check --lint=warn -r . && echo "$?"
0
> buildifier --mode=check --lint=warn MODULE.bazel && echo "$?"
0

However, if the type is set to default explicitly, it works fine:

> buildifier --mode=check --lint=warn --type=default MODULE.bazel
MODULE.bazel:1: module-docstring: The file has no module docstring.
A module docstring is a string literal (not a comment) which should be the first statement of a file (it may follow comment lines). (https://github.com/bazelbuild/buildtools/blob/master/WARNINGS.md#module-docstring)

At the same time, formatting is still detected without setting --type=default:

> buildifier --mode=diff --lint=warn MODULE.bazel
--- MODULE.bazel	2024-03-19 12:34:36
+++ /var/folders/pj/jqnlngf95nlg3qd7l5js_wb40000gr/T/buildifier-tmp-2791490739	2024-03-19 12:34:41
@@ -1,4 +1,5 @@
 bazel_dep(name = "buildifier_prebuilt", version = "6.4.0", dev_dependency = True)
+
 bazel_dep(name = "gazelle", version = "0.35.0")
 bazel_dep(name = "rules_go", version = "0.46.0")
exit status 1

Am I missing something or there is an issue with buildifier?

The version of buildifier used:

> brew info buildifier | head -1
==> buildifier: stable 6.4.0 (bottled), HEAD
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant