package-naming
Since 0.9.0 · In the rulesets: Recommended at warning, Strict at error, All at error
This rule checks whether the package name of a Protobuf file consists of lower_snake_case
components separated by dots.
Rule details
Package names such as acme.pet_store.v1 map cleanly to directories and to the package and
namespace names of the generated code in every language.
The package-naming rule splits the package name at dots and checks that every component is
lower_snake_case: it starts with a lower-case letter, and contains only lower-case letters,
digits and single underscores, with no underscore at the end. If a component is not, the rule
reports Package name '<name>' should be lower_snake_case components separated by dots,
followed by a suggestion such as , e.g. 'acme.pet_store.v1' when converting the components
gives a different name.
To build the suggestion, each component is split into words at underscores and other
separators, at lower-to-upper case changes and before the last capital of an acronym (so that
HTTPServer becomes http_server), and the words are joined in lower case with underscores.
Files without a package are not checked; see the package-defined rule.
Turn the rule off if the package names are dictated by an existing API that you cannot rename.
Examples
Good.
syntax = "proto3";
package acme.pet_store.v1;
message Pet {
string name = 1;
}
Bad. The linter reports Package name 'Acme.PetStore.v1' should be lower_snake_case components separated by dots, e.g. 'acme.pet_store.v1'.
syntax = "proto3";
package Acme.PetStore.v1;
message Pet {
string name = 1;
}
Turn it off or change its severity
In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.protobuf has the details.
commands:
lint:
protobuf:
rules:
package-naming: off