Skip to content

Add exports-files-discouraged buildifier lint check - #1494

Open
alexeagle wants to merge 1 commit into
bazel-contrib:mainfrom
alexeagle:lint/exports-files-discouraged
Open

Add exports-files-discouraged buildifier lint check#1494
alexeagle wants to merge 1 commit into
bazel-contrib:mainfrom
alexeagle:lint/exports-files-discouraged

Conversation

@alexeagle

Copy link
Copy Markdown
Collaborator

Summary

  • Adds a new default-on buildifier lint check exports-files-discouraged that flags exports_files() as a package encapsulation violation ("feature envy").
  • When exports_files() is present, the check also warns if visibility is missing or not scoped to a package (:__pkg__ / :__subpackages__) or package_group, and if there is no comment explaining why encapsulation is being violated.
  • Suggests exposing files via a rule (e.g. filegroup) so the owning package can govern access and later swap the label for a generated artifact.

Test plan

  • bazel test //warn:warn_test --test_filter=TestExportsFilesDiscouraged
  • bazel test //warn/docs:docs_test
  • Verified disable comment # buildifier: disable=exports-files-discouraged suppresses all findings

Discourage exports_files() as a package encapsulation violation, require
scoped visibility and justification comments when it is used, and suggest
exposing files via rules such as filegroup instead.
@alexeagle
alexeagle requested a review from a team as a code owner August 19, 2026 17:19
@alexeagle
alexeagle requested review from oreflow and removed request for a team August 19, 2026 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant