Forbid usage of omitzero for fields marked optional

This commit is contained in:
Joel Speed 2026-03-10 15:03:08 +00:00
parent f8b277b2b8
commit 47d830f3cd
No known key found for this signature in database
GPG key ID: 6E80578D6751DEFB
3 changed files with 24 additions and 24 deletions

View file

@ -424,14 +424,14 @@ linters:
# jsonTagRegex: "^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case.
# nomaps:
# policy: AllowStringToStringMaps # Determines how the linter should handle maps of basic types. Maps of objects are always disallowed.
# optionalFields:
# pointers:
# preference: Always | WhenRequired # Whether to always require pointers, or only when required. Defaults to `Always`.
# policy: SuggestFix | Warn # The policy for pointers in optional fields. Defaults to `SuggestFix`.
# omitempty:
# policy: SuggestFix | Warn | Ignore # The policy for omitempty in optional fields. Defaults to `SuggestFix`.
# omitzero:
# policy: SuggestFix | Warn | Forbid # The policy for omitzero in optional fields. Defaults to `SuggestFix`.
optionalFields:
pointers:
preference: Always # Whether to always require pointers, or only when required. Defaults to `Always`.
policy: SuggestFix # The policy for pointers in optional fields. Defaults to `SuggestFix`.
omitempty:
policy: SuggestFix # The policy for omitempty in optional fields. Defaults to `SuggestFix`.
omitzero:
policy: Forbid # The policy for omitzero in optional fields. Defaults to `SuggestFix`.
# optionalOrRequired:
# preferredOptionalMarker: optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`.
# preferredRequiredMarker: required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`.

View file

@ -437,14 +437,14 @@ linters:
# jsonTagRegex: "^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case.
# nomaps:
# policy: AllowStringToStringMaps # Determines how the linter should handle maps of basic types. Maps of objects are always disallowed.
# optionalFields:
# pointers:
# preference: Always | WhenRequired # Whether to always require pointers, or only when required. Defaults to `Always`.
# policy: SuggestFix | Warn # The policy for pointers in optional fields. Defaults to `SuggestFix`.
# omitempty:
# policy: SuggestFix | Warn | Ignore # The policy for omitempty in optional fields. Defaults to `SuggestFix`.
# omitzero:
# policy: SuggestFix | Warn | Forbid # The policy for omitzero in optional fields. Defaults to `SuggestFix`.
optionalFields:
pointers:
preference: Always # Whether to always require pointers, or only when required. Defaults to `Always`.
policy: SuggestFix # The policy for pointers in optional fields. Defaults to `SuggestFix`.
omitempty:
policy: SuggestFix # The policy for omitempty in optional fields. Defaults to `SuggestFix`.
omitzero:
policy: Forbid # The policy for omitzero in optional fields. Defaults to `SuggestFix`.
# optionalOrRequired:
# preferredOptionalMarker: optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`.
# preferredRequiredMarker: required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`.

View file

@ -51,14 +51,14 @@ lintersConfig:
# jsonTagRegex: "^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]*)*$" # The default regex is appropriate for our use case.
# nomaps:
# policy: AllowStringToStringMaps # Determines how the linter should handle maps of basic types. Maps of objects are always disallowed.
# optionalFields:
# pointers:
# preference: Always | WhenRequired # Whether to always require pointers, or only when required. Defaults to `Always`.
# policy: SuggestFix | Warn # The policy for pointers in optional fields. Defaults to `SuggestFix`.
# omitempty:
# policy: SuggestFix | Warn | Ignore # The policy for omitempty in optional fields. Defaults to `SuggestFix`.
# omitzero:
# policy: SuggestFix | Warn | Forbid # The policy for omitzero in optional fields. Defaults to `SuggestFix`.
optionalFields:
pointers:
preference: Always # Whether to always require pointers, or only when required. Defaults to `Always`.
policy: SuggestFix # The policy for pointers in optional fields. Defaults to `SuggestFix`.
omitempty:
policy: SuggestFix # The policy for omitempty in optional fields. Defaults to `SuggestFix`.
omitzero:
policy: Forbid # The policy for omitzero in optional fields. Defaults to `SuggestFix`.
# optionalOrRequired:
# preferredOptionalMarker: optional # The preferred optional marker to use, fixes will suggest to use this marker. Defaults to `optional`.
# preferredRequiredMarker: required # The preferred required marker to use, fixes will suggest to use this marker. Defaults to `required`.