15d7f5e873
- notescraft-lint (rules, safe fixes, learned style) and notescraft-blocks (block model and edits); engine lint.* and block.* commands with CLI and MCP parity - Lint tab, underlines, slash menu with preview in Source and Visual, block grip and menu, Settings > Editor and lint, Vim block keys - Visual view: tables, note embeds, %% comments, wrapping property chips - Vault knowledge (Related tab, assistant sources, Settings) and calendar plugin - Sidebar top padding fixed, dot grid follows PaperCraft spacing, right-card tabs no longer cover the collapse button Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
35 lines
1.4 KiB
Rust
35 lines
1.4 KiB
Rust
//! Lint through the CLI: `run lint.* <json>` gives the engine's answer and fixes the note.
|
|
|
|
mod common;
|
|
|
|
use common::{empty_vault, note, read_file, run};
|
|
use notescraft_engine::{Registry, Session, register_core};
|
|
use serde_json::{Value, json};
|
|
|
|
const MESSY: &str = "# A\n\n### B\n\ntext with gaps\n";
|
|
|
|
fn engine(root: &std::path::Path, id: &str, params: &Value) -> Value {
|
|
let mut registry = Registry::new();
|
|
register_core(&mut registry).expect("register");
|
|
let mut session = Session::open_read_only(root).expect("open");
|
|
registry.run(id, &mut session, params).expect("engine run")
|
|
}
|
|
|
|
#[test]
|
|
fn check_matches_the_engine_and_fix_all_safe_cleans_the_note() {
|
|
let root = empty_vault("lint-cli");
|
|
note(&root, "messy.md", MESSY);
|
|
let params = json!({ "path": "messy.md" });
|
|
let checked = run(&root, &["--json", "run", "lint.check", ¶ms.to_string()]);
|
|
assert_eq!(checked.code, 0, "{}", checked.stderr);
|
|
assert_eq!(checked.result(), engine(&root, "lint.check", ¶ms));
|
|
|
|
let fixed = run(&root, &["--json", "run", "lint.fix_all_safe", ¶ms.to_string()]);
|
|
assert_eq!(fixed.code, 0, "{}", fixed.stderr);
|
|
assert_eq!(read_file(&root, "messy.md"), "# A\n\n## B\n\ntext with gaps\n");
|
|
|
|
let stale = run(&root, &["--json", "run", "lint.fix", &json!({ "path": "messy.md", "key": "heading-increment:0000000000000000" }).to_string()]);
|
|
assert_eq!(stale.code, 1);
|
|
assert!(stale.stdout.contains("stale"), "{}", stale.stdout);
|
|
}
|