Skip to content

Commit f0969fa

Browse files
committed
fix: markdown linter not loading repository configuration
The markdown linter was not loading .markdownlint.json because: - Missing --config flag when invoking markdownlint - No working directory specified for child processes Changes: - Add --config flag with absolute path to .markdownlint.json - Set current_dir() for find and markdownlint child processes - Ensures config is loaded regardless of invocation directory This fixes the issue where MD013 (line-length) warnings appeared even though the rule is disabled in .markdownlint.json
1 parent 7e12de4 commit f0969fa

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

packages/linting/src/linters/markdown.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use anyhow::Result;
2+
use std::env;
23
use std::process::Command;
34
use tracing::{error, info};
45

@@ -16,11 +17,16 @@ pub fn run_markdown_linter() -> Result<()> {
1617
install_npm_tool("markdownlint-cli")?;
1718
}
1819

20+
// Get the current working directory (should be repo root)
21+
let repo_root = env::current_dir()?;
22+
let config_path = repo_root.join(".markdownlint.json");
23+
1924
// Run the linter
2025
info!(target: "markdown", "Scanning markdown files...");
2126

2227
// Find all markdown files, excluding terraform and target directories
2328
let find_output = Command::new("find")
29+
.current_dir(&repo_root)
2430
.args([
2531
".",
2632
"-name",
@@ -44,13 +50,15 @@ pub fn run_markdown_linter() -> Result<()> {
4450
let files = String::from_utf8_lossy(&find_output.stdout);
4551
let file_list: Vec<&str> = files.lines().filter(|s| !s.is_empty()).collect();
4652

47-
if file_list.is_empty() {
48-
info!(target: "markdown", "No markdown files found");
49-
return Ok(());
50-
}
51-
5253
// Run markdownlint on all found files
5354
let mut cmd = Command::new("markdownlint");
55+
cmd.current_dir(&repo_root);
56+
cmd.arg("--config").arg(&config_path);
57+
cmd.args(&file_list);
58+
// Run markdownlint on all found files
59+
let mut cmd = Command::new("markdownlint");
60+
cmd.arg("--config").arg(".markdownlint.json");
61+
cmd.current_dir("."); // Ensure we run from the repository root
5462
cmd.args(&file_list);
5563

5664
let output = cmd.output()?;

0 commit comments

Comments
 (0)