Repository navigation
refactor: allow kebab-cased and lowercased config options - #1750
Merged
alexandear merged 4 commits intoJun 26, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors revive’s TOML configuration loading to accept top-level options in camelCase, kebab-case, or fully lowercased form, aligning this behavior with the existing rule-option casing flexibility (per #1272) and updating docs/default configs accordingly.
Changes:
- Add a shared
internal/config.NormalizeOptionhelper and reuse it across rule-option normalization and top-level config parsing. - Update top-level TOML tags in
lint.Configtokebab-caseand implement normalized-key decoding inconfig.parseConfig. - Update repository config examples/defaults and expand config parsing test coverage for option casing.
Reviewed changes
Copilot reviewed 45 out of 46 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
rule/utils.go |
Switch rule option normalization to the shared internal/config.NormalizeOption. |
rule/defer.go |
Use shared option normalization for the defer rule sub-options and parsed args. |
revive.toml |
Update project’s self-lint config to use kebab-cased top-level options. |
README.md |
Update documentation examples and references to use kebab-cased top-level options (and lowercase rule config keys in examples). |
lint/config.go |
Change TOML tags for top-level config fields to kebab-case (e.g. enable-all-rules, error-code). |
internal/config/config.go |
Introduce NormalizeOption helper (lowercase + strip hyphens) for config/option key matching. |
defaults.toml |
Update default config file to kebab-cased top-level options. |
config/testdata/var-naming-configure-error.toml |
Update test fixture to kebab-cased enable-all-rules. |
config/testdata/rule-option-casing.toml |
Add/adjust fixture ensuring rule config keys remain case-insensitive (e.g. disabled/Disabled). |
config/testdata/rule-level-exclude-850.toml |
Update fixture to kebab-cased top-level options. |
config/testdata/options-lowercase.toml |
New fixture: top-level options specified fully lowercased (e.g. enabledefaultrules). |
config/testdata/options-kebab-case.toml |
New fixture: top-level options specified in kebab-case. |
config/testdata/options-camelCase.toml |
New fixture: top-level options specified in camelCase (legacy form). |
config/testdata/noRules.toml |
Remove old fixture (replaced by kebab-case equivalent). |
config/testdata/non-defaults.toml |
Update fixture to kebab-cased top-level options. |
config/testdata/no-rules.toml |
Add kebab-case equivalent fixture for “no rules”. |
config/testdata/malformed.toml |
Update fixture to kebab-cased top-level options. |
config/testdata/issue-969.toml |
Update fixture to kebab-cased top-level options. |
config/testdata/issue-585.toml |
Update fixture to kebab-cased top-level options. |
config/testdata/issue-585-defaultConfidence.toml |
Remove old fixture (replaced by kebab-case equivalent). |
config/testdata/issue-585-default-confidence.toml |
Add kebab-case equivalent fixture for default confidence case. |
config/testdata/issue-470.toml |
Update fixture to kebab-cased top-level options. |
config/testdata/invalid-exclude-pattern.toml |
Add fixture for invalid rule-level exclude patterns (using lowercase rule key). |
config/testdata/ignoreGeneratedHeader.toml |
Remove old fixture (replaced by kebab-case equivalent). |
config/testdata/ignore-generated-header.toml |
Add kebab-case equivalent fixture. |
config/testdata/goVersion.toml |
Remove old fixture (replaced by kebab-case equivalent). |
config/testdata/go-version.toml |
Add kebab-case equivalent fixture. |
config/testdata/enableAllOneSpecificSeverity.toml |
Remove old fixture (replaced by kebab-case equivalent). |
config/testdata/enableAll.toml |
Remove old fixture (replaced by kebab-case equivalent). |
config/testdata/enable2.toml |
Update fixture to kebab-cased top-level options. |
config/testdata/enable2-one-specific-severity.toml |
Update fixture to kebab-cased top-level options. |
config/testdata/enable-default.toml |
Update fixture to kebab-cased enable-default-rules. |
config/testdata/enable-default-plus1.toml |
Update fixture to kebab-cased enable-default-rules. |
config/testdata/enable-default-plus-default-rule.toml |
Update fixture to kebab-cased enable-default-rules. |
config/testdata/enable-default-but2.toml |
Update fixture to kebab-cased enable-default-rules and lowercase disabled. |
config/testdata/enable-all.toml |
Add kebab-case fixture for enabling all rules with standard top-level defaults. |
config/testdata/enable-all-with-rule.toml |
Update fixture to kebab-cased enable-all-rules. |
config/testdata/enable-all-one-specific-severity.toml |
Add kebab-case fixture variant for per-rule severity with enable-all. |
config/testdata/enable-all-lowercase.toml |
Add lowercase fixture variant for enable-all-rules. |
config/testdata/enable-all-kebab-case.toml |
Add kebab-case fixture variant for enable-all-rules. |
config/testdata/enable-all-camel-case.toml |
Add camelCase fixture variant for enable-all-rules. |
config/testdata/enable-all-but2.toml |
Update fixture to kebab-cased enable-all-rules and lowercase disabled. |
config/testdata/enable-all-and-default.toml |
Update invalid-config fixture to kebab-cased enable flags. |
config/config.go |
Implement normalized-key decoding for top-level options; update validation error wording to kebab-case. |
config/config_test.go |
Rename fixture references and add tests validating top-level option casing variants. |
cli/main.go |
Update CLI help text to reference error-code / warning-code. |
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR allows all TOML config options to be specified in camelCase, kebab-case, or lowercase. For example, the following are now all equivalent:
This follows the same convention we already have for rule options (see #1272), so configuration is now consistent across both top-level options and rule arguments.