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

Enforce specific type usage via lint #320

Closed
AlexeiZenin opened this issue May 17, 2021 · 3 comments
Closed

Enforce specific type usage via lint #320

AlexeiZenin opened this issue May 17, 2021 · 3 comments
Labels
Feature New feature or request

Comments

@AlexeiZenin
Copy link

Currently we have some best practices in our org that we would want to enforce on specific types users should use for primitives or wrapper types such as StringValue.

Would it be possible for Buf to add support for some custom rules which could be configured to allow enforcing all int64 types are sint64 for example?

There are many types in Protobuf 3 which leads to confusion and bad decisions taken on part by an unsuspecting user (see https://stackoverflow.com/questions/765916/is-there-ever-a-good-time-to-use-int32-instead-of-sint32-in-google-protocol-buff).

If this could be configurable that would be great. The granularity would be to disallow certain datatypes from appearing or another way could be doing an allowed type list as well (StringValue, IntValue, sint64, etc).

This would help us enforce these rules through automation rather than through documentation, word of mouth or PR review.

@aantono
Copy link

aantono commented May 26, 2021

I think this would be a great addition to be able to configure "undesirable" types. For example the use of google.protobuf.Struct or google.protobuf.Any might not be desired for particular applications, as it introduces ambiguity, and might want to be prevented in particular design scenarios.

If there was a configurable linter option to provide a list of disallowed types, it would help a lot.

@bufdev bufdev changed the title [Lint] Enforce specific type usage in Proto files Enforce specific type usage via lint Jul 31, 2021
@bufdev bufdev added Feature New feature or request P3 labels Jul 31, 2021
@bufdev
Copy link
Member

bufdev commented Jul 31, 2021

We can consider this, it's a little out of scope but I see the use case.

@bufdev bufdev removed the P3 label Feb 2, 2023
@bufdev
Copy link
Member

bufdev commented Nov 27, 2023

Tracking on #29

@bufdev bufdev closed this as completed Nov 27, 2023
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

3 participants