Example repository demonstrating dunolint's automatic config discovery and hierarchical configuration loading
- Shell 78.6%
- Dune 11.7%
- OCaml 9.7%
π€ Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> |
||
|---|---|---|
| lib | ||
| repo | ||
| .gitignore | ||
| dune | ||
| dune-project | ||
| dune-workspace | ||
| dunolint | ||
| LICENSE | ||
| README.md | ||
| test.expected | ||
| test.sh | ||
Dunolint Autoload Config Test Repository
β οΈ Example Repository This is a demonstration/example repository showing how dunolint's config autoloading feature works. Not an official dunolint repository. Created for educational and testing purposes.
This repository tests the dunolint autoloading config feature, which allows dunolint to automatically discover and apply configuration files from different levels of the project hierarchy.
Repository Structure
.
βββ dune-project # Root project (lang dune 3.18)
βββ dunolint # Root config: base rules
βββ lib/
β βββ dune # Library with violations
β βββ root_lib.ml
βββ repo/
β βββ foo/
β β βββ dune-project # Foo subproject
β β βββ dunolint # Foo config: overrides + additions
β β βββ lib/
β β βββ dune # Library with violations
β β βββ wrong_name.ml
β βββ bar/
β βββ dune-project # Bar subproject
β βββ dunolint # Bar config: different overrides
β βββ lib/
β βββ dune # Library with minimal violations
β βββ bar_lib.ml
βββ test.sh # Test script with multiple scenarios
βββ dune # Test runner with promotion
βββ test.expected # Expected output (promoted)
Config Strategy
Root dunolint Config
-
Combinable rules:
- Enforce
(instrumentation (backend bisect_ppx))on all libraries
- Enforce
-
Base rules (can be overridden):
(implicit_transitive_deps (equals false))(name (is_suffix _lib))
Foo dunolint Config
- Overrides:
- Specific name requirement:
(name (equals foo_lib))- overrides root'sis_suffix _librule
- Specific name requirement:
Bar dunolint Config
- Overrides:
- Allow implicit transitive deps:
(implicit_transitive_deps (equals true))- overrides root's requirement forfalse - Specific name:
(name (equals bar_lib))- overrides root'sis_suffix _librule
- Allow implicit transitive deps:
Intentional Violations
Root dune-project
- β
implicit_transitive_deps true(violates root rule requiring false)
lib/dune (Root Library)
- β Missing
instrumentationfield (violates root combinable rule) - β
name root_lib(matchesis_suffix _lib)
repo/foo/dune-project
- β
implicit_transitive_deps true(violates inherited root rule requiring false)
repo/foo/lib/dune (Foo Library)
- β
name wrong_name(violates foo override requiringfoo_lib) - β Missing
instrumentationfield (violates inherited root rule)
repo/bar/dune-project
- β
implicit_transitive_deps false(violates bar override requiring true)
repo/bar/lib/dune (Bar Library)
- β Missing
instrumentationfield (violates inherited root rule) - β
name bar_lib(matches bar override)
Test Scenarios
The test.sh script runs 6 different test scenarios:
- From root directory: Should apply root config to entire tree
--below lib: Check only root lib with root config--below repo/foo: Check foo with foo config loaded--below repo/bar: Check bar with bar config loaded- From
repo/fooas root: Foo config as root - From
repo/baras root: Bar config as root
Running Tests
Manual Test Run
./test.sh
Dune Test with Promotion
# Run tests and see diff
dune runtest
# Promote new output as expected
dune runtest --auto-promote
Initial Setup
To generate the initial expected output:
dune runtest --auto-promote
Expected Behavior
The test verifies that:
- Root config rules are applied to all libraries by default
- Subproject configs can override specific rules
- Subproject configs can add new rules that combine with inherited ones
- The
--belowflag correctly limits the scope - Running from different directories correctly identifies the root config
Usage for Validating New Dunolint Versions
After updating dunolint:
- Run
dune runtestin this repository - Review the diff to ensure behavior is as expected
- If behavior changed intentionally, promote with
dune runtest --auto-promote - Commit the updated
test.expectedto track the new baseline