# import-no-public

Source: https://apigenie.pl/docs/linter/protobuf/rules/import-no-public

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.

## Configuration

This rule has no options.

## 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;
}
```

## When Not to Use It

You may disable this rule 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.

## Compatibility

This rule is compatible with proto3 files. proto2 and editions files are rejected by the reader
and are not linted.
