# package-defined

Source: https://apigenie.pl/docs/linter/protobuf/rules/package-defined

A rule of the Protobuf linter, which reads proto3 files; the reader rejects proto2 and editions files. Since 0.9.0. In the rulesets: Recommended at error, Strict at error, All at error.

This rule checks whether every Protobuf file declares a package.

## Rule details

Without a `package` declaration, the messages, enums and services of a file live in the global
namespace, where they can clash with the declarations of any other file. Most code generators
also derive the names of the generated packages or namespaces from the Protobuf package.

The `package-defined` rule reports `File has no package declaration` for every file without a
`package` statement. The issue is reported at the syntax statement.

## Examples

**Good**.

```proto
syntax = "proto3";

package acme.pets.v1;

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

**Bad**. The linter reports `File has no package declaration`.

```proto
syntax = "proto3";

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