Skip to content

refactor: allow kebab-cased and lowercased config options - #1750

Merged
alexandear merged 4 commits into
revive-lint:masterfrom
alexandear:refactor/kebab-cased-options
Jun 26, 2026
Merged

alexandear merged 4 commits into
revive-lint:masterfrom
alexandear:refactor/kebab-cased-options

Conversation

@alexandear

Copy link
Copy Markdown
Member

This PR allows all TOML config options to be specified in camelCase, kebab-case, or lowercase. For example, the following are now all equivalent:

enableAllRules = true
enable-all-rules = true
enableallrules = true

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.NormalizeOption helper and reuse it across rule-option normalization and top-level config parsing.
  • Update top-level TOML tags in lint.Config to kebab-case and implement normalized-key decoding in config.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.

Comment thread config/config.go Resolved
@alexandear
alexandear merged commit aa8e007 into revive-lint:master Jun 26, 2026
11 checks passed
@alexandear
alexandear deleted the refactor/kebab-cased-options branch June 26, 2026 16:16
@alexandear alexandear mentioned this pull request Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants