Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 113 additions & 31 deletions content/docs/cli/breaking-changes/index.mdx

Large diffs are not rendered by default.

146 changes: 114 additions & 32 deletions content/docs/cli/breaking-changes/index.ru.mdx

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions content/docs/cli/breaking-changes/meta.ru.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"title": "Несовместимые изменения",
"pages": [
"index",
"rules"
]
}
60 changes: 60 additions & 0 deletions content/docs/cli/breaking-changes/rules/enum-moved.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: "Enum Moved"
description: "Checks that enums are not moved to a different .proto file in the FILE profile."
---

- **Rule ID:** `ENUM_MOVED`
- **Profiles:** `FILE`

In the `FILE` profile, moving an `enum` from one `.proto` file to another (even within the same protobuf package) is flagged because generated file-level headers and imports (for example, C++ `#include` or Python module imports) depend on the declaring file path. Use the `PACKAGE` profile if you allow moving declarations between files in the same package.

## Examples

### Bad

**Before:**

```proto
// File: myapi/v1/order.proto
syntax = "proto3";

package myapi.v1;

enum OrderStatus {
ORDER_STATUS_UNSPECIFIED = 0;
}
```

**After:**

```proto
// File: myapi/v1/status.proto
syntax = "proto3";

package myapi.v1;

enum OrderStatus {
ORDER_STATUS_UNSPECIFIED = 0;
}
```

**Error:**

```text
myapi/v1/order.proto:6:1: Enum "myapi.v1.OrderStatus" was moved from "myapi/v1/order.proto" to "myapi/v1/status.proto". (ENUM_MOVED)
```

### Good

Keep the enum in its original `.proto` file when using the `FILE` profile:

```proto
// File: myapi/v1/order.proto
syntax = "proto3";

package myapi.v1;

enum OrderStatus {
ORDER_STATUS_UNSPECIFIED = 0;
}
```
60 changes: 60 additions & 0 deletions content/docs/cli/breaking-changes/rules/enum-moved.ru.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
title: "Enum Moved"
description: "Проверяет, что объявления enum не переносятся в другой .proto-файл в профиле FILE."
---

- **ID правила:** `ENUM_MOVED`
- **Профили:** `FILE`

В профиле `FILE` перенос `enum` из одного `.proto`-файла в другой (даже внутри того же пакета) считается несовместимым, поскольку сгенерированные файловые импорты и заголовки (например, `#include` в C++ или модули Python) зависят от пути файла. Если переносы внутри пакета допустимы, используйте профиль `PACKAGE`.

## Примеры

### Неправильно

**До:**

```proto
// File: myapi/v1/order.proto
syntax = "proto3";

package myapi.v1;

enum OrderStatus {
ORDER_STATUS_UNSPECIFIED = 0;
}
```

**После:**

```proto
// File: myapi/v1/status.proto
syntax = "proto3";

package myapi.v1;

enum OrderStatus {
ORDER_STATUS_UNSPECIFIED = 0;
}
```

**Ошибка:**

```text
myapi/v1/order.proto:6:1: Enum "myapi.v1.OrderStatus" was moved from "myapi/v1/order.proto" to "myapi/v1/status.proto". (ENUM_MOVED)
```

### Правильно

Оставьте `enum` в исходном `.proto`-файле при использовании профиля `FILE`:

```proto
// File: myapi/v1/order.proto
syntax = "proto3";

package myapi.v1;

enum OrderStatus {
ORDER_STATUS_UNSPECIFIED = 0;
}
```
Loading
Loading