Skip to content

Commit d36a0e1

Browse files
Added enums linter
1 parent dda830a commit d36a0e1

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
@@ -195,13 +196,34 @@ will not.
195196
The `duplicatemarkers` linter can automatically fix all markers that are exact match to another markers.
196197
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.
197198

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

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

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

204-
### Configuation
226+
### Configuration
205227

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

0 commit comments

Comments
 (0)