Skip to content

Commit 9ebc8bf

Browse files
Added enums linter
1 parent 33e0e43 commit 9ebc8bf

File tree

9 files changed

+750
-1
lines changed

9 files changed

+750
-1
lines changed

docs/linters.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- [ConflictingMarkers](#conflictingmarkers) - Detects mutually exclusive markers on the same field
77
- [DefaultOrRequired](#defaultorrequired) - Ensures fields marked as required do not have default values
88
- [DuplicateMarkers](#duplicatemarkers) - Checks for exact duplicates of markers
9+
- [Enums](#enums) - Enforces proper usage of enumerated fields with type aliases and +enum marker
910
- [ForbiddenMarkers](#forbiddenmarkers) - Checks that no forbidden markers are present on types/fields.
1011
- [Integers](#integers) - Validates usage of supported integer types
1112
- [JSONTags](#jsontags) - Ensures proper JSON tag formatting
@@ -196,13 +197,34 @@ will not.
196197
The `duplicatemarkers` linter can automatically fix all markers that are exact match to another markers.
197198
If there are duplicates across fields and their underlying type, the marker on the type will be preferred and the marker on the field will be removed.
198199

200+
## Enums
201+
202+
The `enums` linter enforces that enumerated fields use type aliases with the `+enum` marker and that enum values follow PascalCase naming conventions.
203+
204+
This provides better API evolution, self-documentation, and validation compared to plain strings.
205+
206+
By default, `enums` is not enabled.
207+
208+
### Configuration
209+
210+
```yaml
211+
linterConfig:
212+
enums:
213+
allowlist:
214+
- kubectl
215+
- docker
216+
- helm
217+
```
218+
219+
The `allowlist` field contains enum values that should be exempt from PascalCase validation, such as command-line executable names.
220+
199221
## ForbiddenMarkers
200222

201223
The `forbiddenmarkers` linter ensures that types and fields do not contain any markers that are forbidden.
202224

203225
By default, `forbiddenmarkers` is not enabled.
204226

205-
### Configuation
227+
### Configuration
206228

207229
It can be configured with a list of marker identifiers and optionally their attributes and values that are forbidden.
208230

0 commit comments

Comments
 (0)