# file-naming

Source: https://apigenie.pl/docs/linter/protobuf/rules/file-naming

This rule checks whether the name of every Protobuf file is in `lower_snake_case`, with the
`.proto` extension.

## Rule Details

Code generators derive the names of the generated files, and sometimes of classes, from the
names of the `.proto` files. `lower_snake_case` names such as `pet_owner.proto` are safe on every
file system and in every target language, and are what the Protobuf style guide recommends.

The `file-naming` rule checks the name of the linted file, without its directory. The name must
end with `.proto`, and the part before the extension must start with a lower-case letter or a
digit (as in `2fa.proto`), and contain only lower-case letters, digits and single underscores,
with no underscore at the end. Otherwise the rule reports:

`File name '<name>' should be lower_snake_case.proto`

followed by a suggestion such as `, e.g. 'pet_store.proto'`. To build the suggestion, the part
before the extension is split into words at underscores and other separators such as `-` and `.`,
at lower-to-upper case changes and before the last capital of an acronym, and the words are
joined in lower case with underscores.

Files linted without a path are not checked.

## Configuration

This rule has no options.

## Examples

**Good**. The file `pet_store.proto`:

```proto
syntax = "proto3";

package acme.pets.v1;

message Pet {
  string name = 1;
}
```

**Bad**. The same content in the file `PetStore.proto` makes the linter report
`File name 'PetStore.proto' should be lower_snake_case.proto, e.g. 'pet_store.proto'`, and in
the file `pet-store.proto`,
`File name 'pet-store.proto' should be lower_snake_case.proto, e.g. 'pet_store.proto'`.

```proto
syntax = "proto3";

package acme.pets.v1;

message Pet {
  string name = 1;
}
```

## When Not to Use It

You may disable this rule if the file names are dictated by an existing project layout that you
cannot change.

## Compatibility

This rule is compatible with proto3 files. proto2 and editions files are rejected by the reader
and are not linted. The rule uses the path of the linted file, but not its content.
