Skip to main content

fallow_config/
lib.rs

1//! Configuration loading and resolution for fallow.
2//!
3//! Owns the user-facing config model ([`FallowConfig`] and its sections),
4//! config-file discovery and `extends` inheritance, validation of
5//! user-supplied globs and patterns, and resolution into the pre-compiled
6//! [`ResolvedConfig`] the analysis crates consume. Also hosts workspace and
7//! `package.json` discovery, declarative external plugin definitions, rule
8//! packs, and the in-place config editing used by `fallow fix`.
9
10#![warn(missing_docs)]
11#![cfg_attr(
12    test,
13    allow(
14        clippy::unwrap_used,
15        clippy::expect_used,
16        reason = "tests use unwrap and expect to keep fixture setup concise"
17    )
18)]
19
20mod config;
21mod config_writer;
22mod external_plugin;
23mod fixability;
24/// JSONC parsing helpers pinning the dialect fallow accepts.
25pub mod jsonc;
26pub mod levenshtein;
27mod rule_pack;
28mod workspace;
29
30pub use config::*;
31pub use config_writer::*;
32pub use external_plugin::*;
33pub use fixability::*;
34pub use rule_pack::*;
35pub use workspace::*;
36
37use std::path::{Path, PathBuf};
38
39/// Basename of the local walkthrough viewed-state ledger inside the cache dir.
40const WALKTHROUGH_STATE_FILE: &str = "walkthrough-state.json";
41
42/// Path to the local `fallow review --walkthrough` viewed-state ledger inside a
43/// resolved cache directory (default `<root>/.fallow`, already gitignored).
44///
45/// Pure path join, mirroring the `cache.bin` / `graph-cache.bin` / `churn.bin`
46/// conventions; the file IO and serde live in the CLI crate to keep this crate
47/// free of side effects.
48#[must_use]
49pub fn walkthrough_state_path(cache_dir: &Path) -> PathBuf {
50    cache_dir.join(WALKTHROUGH_STATE_FILE)
51}
52
53#[cfg(test)]
54mod walkthrough_state_path_tests {
55    use super::walkthrough_state_path;
56    use std::path::Path;
57
58    #[test]
59    fn joins_state_file_under_cache_dir() {
60        let path = walkthrough_state_path(Path::new("/project/.fallow"));
61        assert_eq!(path, Path::new("/project/.fallow/walkthrough-state.json"));
62    }
63}