AEP-0191 Linter Rules
File layout
File layout
This rule attempts to enforce a consistent file layout for proto files, as mandated in AEP-191.
Details
This rule checks for common file layout mistakes, but does not currently check the exhaustive file layout in AEP-191. This rule currently complains if within a file:
- …services appear below messages.
- …top-level enums appear above messages.
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a comment at the top of the file. Remember to also include an aep.dev/not-precedent comment explaining why.
Filenames
Filenames
This rule attempts to enforce reasonable filenames for proto files, as mandated in AEP-191.
Details
Because proto filenames show up in client libraries (for example, as import paths), it is important not to have odd paths.
This rule currently complains if the filename:
- …is set to the proto version.
- …contains invalid cahracters.
Examples
Incorrect filenames for this rule:
v1.proto
v1beta1.proto
library.service.proto
library#.proto
library$.proto
library service.proto
library_Service.proto
Correct filenames for this rule:
library.proto
library_service.proto
Disabling
If you need to violate this rule, use a comment at the top of the file. Remember to also include an aep.dev/not-precedent comment explaining why.
Protobuf Package
Protobuf Package
This rule attempts to enforce that the proto package and the directory structure match, as mandated in AEP-191.
Details
Accordig to the Protobuf Style Guide, the package name must correspond to the directory structure.
This rule currently complains if the package and the directory structure do not correspond.
Examples
Incorrect directory structures and proto packages for this rule:
example/v1
example.library.v1
example/library/v1
example.librarian.v1
Correct directory structures and proto packages for this rule:
example/library/v1
example.library.v1
example/library/v1/types
example.library.v1.types
Disabling
If you need to violate this rule, use a comment at the top of the file. Remember to also include an aep.dev/not-precedent comment explaining why.
Proto3 syntax
Proto3 syntax
This rule enforces that every proto file for a public API surface uses proto3, as mandated in AEP-191.
Details
This rule looks at each proto file, and complains if the syntax is set to
proto2
(or missing, which means it defaults to proto2
).
Examples
Incorrect code for this rule:
Correct code for this rule:
Disabling
If you need to violate this rule, use a comment at the top of the file. Remember to also include an aep.dev/not-precedent comment explaining why.