bazel-contrib / bazel-contrib/buildtools

[buildifier]: add lint warning for disallowed load

Open
#1,231 2 comments 1 reaction 0 assignees View on GitHub
P3
Dominant language
Go
Stars
1.2k
Forks
471
Avg merge
2d 22h
Merged PRs (30d)
13

Description

Many ruleset users wrap the upstream rules with a macro that sets defaults, enforces policies, or creates an additional rule.

Gazelle can generate rules with a `load` statement that ensures the macro is used rather than directly loading the external rule, using the `map_kind` directive.

However, these users still need a way to prevent their developers accidentally loading symbols from a starlark module they forbid.

For example I'd want to configure buildifier to detect

```
load("@rules_python//python:defs.bzl", "py_library")
```

and print the suggestion of using a macro instead like

```
load("//tools/bazel/python:defs.bzl", "py_library")
```

Contributor guide

Open the contributing guide

Research direction

No source files, tests, or entry points are named. Start by locating buildifier's lint-warning implementation and configuration handling, then compare how existing warnings are configured. Done means a configured forbidden Starlark load produces a suggestion to use the permitted replacement load, with coverage for the examples in the issue.

Written by the indexing model from the issue text.

Assessment

Domain
build-system, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.