Skip to content

Add hierarchical configuration for pony-lint#5135

Merged
SeanTAllen merged 1 commit intomainfrom
implement-hierarchical-lint-config
Apr 5, 2026
Merged

Add hierarchical configuration for pony-lint#5135
SeanTAllen merged 1 commit intomainfrom
implement-hierarchical-lint-config

Conversation

@SeanTAllen
Copy link
Copy Markdown
Member

@SeanTAllen SeanTAllen commented Apr 5, 2026

pony-lint now supports .pony-lint.json files in subdirectories, not just at the project root. A subdirectory config overrides the root config for all files in that subtree, using the same JSON format and proximity-first precedence.

New types: ConfigResolver resolves per-directory rule status by merging the config hierarchy. LintConfig.merge() layers child overrides on parent configs with category-cleaning semantics.

Config discovery piggybacks on the existing file-discovery walk alongside .gitignore/.ignore loading. Intermediate configs between the hierarchy root and walk targets are pre-loaded, and explicit file targets load their directory's config directly.

Malformed subdirectory configs produce lint/config-error diagnostics and fall through to the parent config.

Design: #5028

Things to note

  1. Uncached RuleRegistry per file in text phase_registry_for() constructs a new RuleRegistry for every file in an overridden directory. The config is cached but the registry is not. Negligible for a CLI tool; easy to add a registry cache later if needed.

  2. Walk-discovered configs ignore empty root_dir sentinel_FileCollector._load_config runs unconditionally during the walk regardless of whether hierarchical config is enabled (empty root_dir). No practical impact since main.pony always passes a non-empty root_dir.

@SeanTAllen SeanTAllen added the changelog - added Automatically add "Added" CHANGELOG entry on merge label Apr 5, 2026
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Apr 5, 2026
@SeanTAllen SeanTAllen force-pushed the implement-hierarchical-lint-config branch 2 times, most recently from a55bc24 to 411062f Compare April 5, 2026 16:48
Subdirectory .pony-lint.json files override the root config for their
subtree using proximity-first precedence. This lets projects disable
rules for specific directories (e.g., turning off package-docstring
for examples/) without affecting the rest of the codebase.

Addresses: #5028
@SeanTAllen SeanTAllen force-pushed the implement-hierarchical-lint-config branch from 411062f to c1d8b44 Compare April 5, 2026 17:06
@SeanTAllen SeanTAllen merged commit 669b10c into main Apr 5, 2026
12 checks passed
@SeanTAllen SeanTAllen deleted the implement-hierarchical-lint-config branch April 5, 2026 17:28
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Apr 5, 2026
github-actions bot pushed a commit that referenced this pull request Apr 5, 2026
github-actions bot pushed a commit that referenced this pull request Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog - added Automatically add "Added" CHANGELOG entry on merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants