# import-no-public

Source: https://api-genie.dev/docs/linter/protobuf/rules/import-no-public

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 warning, Strict at error, All at error.

This rule checks whether a Protobuf file uses `import public`.

## Rule details

A public import makes the declarations of the imported file visible to every file that imports
the importing one. It is meant as a temporary measure when moving declarations between files, but
it hides the real dependencies of the importers, and several code generators support it poorly
or not at all.

The `import-no-public` rule reports `Import '<import>' should not be public` for every
`import public` statement.

Turn the rule off while moving declarations from one file to another, when a public import keeps the
existing importers working. To allow a single import, add an `// apigenie-lint-disable
import-no-public` comment to it.

## Examples

**Good**.

```proto
syntax = "proto3";

package acme.pets.v1;

import "google/protobuf/timestamp.proto";

message Pet {
  string name = 1;
  google.protobuf.Timestamp born_at = 2;
}
```

**Bad**. The linter reports `Import 'google/protobuf/timestamp.proto' should not be public`.

```proto
syntax = "proto3";

package acme.pets.v1;

import public "google/protobuf/timestamp.proto";

message Pet {
  string name = 1;
  google.protobuf.Timestamp born_at = 2;
}
```
