Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Lint: One top level entity (message, enum, service) per file #3254

Open
ngbrown opened this issue Aug 20, 2024 · 1 comment
Open

Lint: One top level entity (message, enum, service) per file #3254

ngbrown opened this issue Aug 20, 2024 · 1 comment
Labels
Feature New feature or request

Comments

@ngbrown
Copy link

ngbrown commented Aug 20, 2024

Feature

The Protocol Buffers Documentation has in their guide the 1-1-1 Rule:

  • One proto_library rule
  • One source .proto file
  • One top-level entity (message, enum, or extension)

And states: "When defining a proto schema, you should have a single message, enum, extension, service, or group of cyclic dependencies per file."

It would be great if the buf lint command would check for this. It would be fairly straight forward for one enum or service per file. For messages that are cyclic, it could be a bit more challenging, but I've never made such a message, so most messages should be one per file.

@ngbrown ngbrown added the Feature New feature or request label Aug 20, 2024
@ngbrown ngbrown changed the title Lint: One message or enum per file Lint: One top level entity (message, enum, service) per file Aug 20, 2024
@bufdev
Copy link
Member

bufdev commented Aug 21, 2024

The 1-1-1 methodology sounds impractical, and isn't something we would recommend to our users at all. To start with, you shouldn't be moving files generally - doing so can cause breaking changes in source code. Moving files wouldn't be a concern at Google though, but that gets to the point: 1-1-1 feels like something for Google, but not for the rest of us.

Regardless, reasonable people can disagree, which is why we are currently working on buf plugins for lint and breaking change detection! This will let you write your own rules, including for rules that the Buf team disagrees with. We will keep you up to date when this is available!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants