https://pantsbuild.org/ logo
#general
Title
# general
m

mysterious-action-44812

11/30/2018, 6:18 AM
is there an easy way to write BUILD file lint rules? my use case (simplified) is I have a codebase like
src/scala/models/*
and
src/scala/services/*
. I want to make sure no BUILD file in a services subfolder depends on anything from any other services subfolder
w

wide-energy-11069

11/30/2018, 7:42 AM
this sounds related to the dep banning work that @red-balloon-89377 is working on
r

red-balloon-89377

11/30/2018, 9:56 AM
Yes, there is an open PR that is being worked on intermittently: https://github.com/pantsbuild/pants/pull/6541
The way you’d implement it when it’s merged is that you can declare things like
Copy code
scala_library(..., dependency_constraints=DependencyConstraints([TargetName("a_banned_target"), Tag("a_banned_tag")])
If you can think of other types of constraints you’d like, feel free to comment on the PR with feedback
m

mysterious-action-44812

12/01/2018, 2:33 PM
interesting cool will check it out. are there other ways to write BUILD lint rules in general? for example another one that would be useful for us is discouraging use of
exports
in library rules
w

wide-energy-11069

12/01/2018, 6:36 PM
A custom task, probably, depending on how general/specific you want it to be.
5 Views