chore: markdownlint rule source - #11265
Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughAdds Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/biome_analyze/src/rule.rs`:
- Line 458: Update the Self::MarkdownLint URL construction in the rule
formatting logic to lowercase rule_id only when interpolating the documentation
URL, while preserving the original uppercase rule ID in the public rule name.
- Around line 220-221: The MarkdownLint source contract lacks coverage. In
crates/biome_analyze/src/rule.rs around RuleSource::MarkdownLint, add tests
verifying the MD001 source’s display name, rule name, empty namespace,
documentation URL, and is_eslint_plugin() == false; in
crates/biome_markdown_analyze/src/lint/nursery/use_consistent_header_level.rs
around useConsistentHeaderLevel, add a test confirming it exposes this source
with RuleSourceKind::SameLogic.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ed84259d-f208-433a-bee4-0a1b4a595c48
📒 Files selected for processing (2)
crates/biome_analyze/src/rule.rscrates/biome_markdown_analyze/src/lint/nursery/use_consistent_header_level.rs
| /// Rules from [markdownlint](https://github.com/DavidAnson/markdownlint) | ||
| MarkdownLint(&'a str, &'a str), |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- candidate files ---'
git ls-files 'crates/biome_analyze/src/rule.rs' \
'crates/biome_markdown_analyze/src/lint/nursery/use_consistent_header_level.rs' \
'*rule*test*' '*use_consistent_header_level*'
printf '%s\n' '--- rule outline ---'
ast-grep outline crates/biome_analyze/src/rule.rs --lang rust
printf '%s\n' '--- relevant symbols and tests ---'
rg -n -C 4 'MarkdownLint|as_rule_name|to_rule_url|is_eslint_plugin|RuleSourceKind|SameLogic|heading-increment|MD001|use_consistent_header_level' \
crates/biome_analyze crates/biome_markdown_analyzeRepository: biomejs/biome
Length of output: 18980
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- RuleSource implementation: declaration and formatting ---'
sed -n '95,305p' crates/biome_analyze/src/rule.rs
printf '%s\n' '--- RuleSource implementation: metadata methods ---'
sed -n '305,555p' crates/biome_analyze/src/rule.rs
printf '%s\n' '--- all repository references ---'
rg -n -C 3 'RuleSource::MarkdownLint|MarkdownLint\(|RuleSourceKind::SameLogic|sources:.*same\(\)|sources:' . \
-g '!target' -g '!node_modules'
printf '%s\n' '--- test modules and snapshots mentioning source metadata ---'
rg -n -C 3 '#\[cfg\(test\)\]|#\[test\]|sources|rule source|RuleSource' crates/biome_analyze crates/biome_markdown_analyze \
-g '*.rs' -g '*.snap' -g '*.json'Repository: biomejs/biome
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- test attributes in relevant files ---'
rg -n -C 2 '#\[cfg\(test\)\]|#\[test\]|mod tests|insta::' \
crates/biome_analyze/src/rule.rs \
crates/biome_markdown_analyze/src/lint/nursery/use_consistent_header_level.rs || true
printf '%s\n' '--- exact MarkdownLint references ---'
rg -n -C 5 'MarkdownLint' . -g '*.rs' -g '*.snap' -g '*.json' -g '*.md' \
| rg -v 'sources:.*RuleSource::(?!MarkdownLint)' || true
printf '%s\n' '--- exact affected rule references ---'
rg -n -C 5 'useConsistentHeaderLevel|use_consistent_header_level|MD001|heading-increment' . \
-g '*.rs' -g '*.snap' -g '*.json' -g '*.md'
printf '%s\n' '--- relevant directory files ---'
find crates/biome_analyze crates/biome_markdown_analyze -maxdepth 4 -type f \
\( -name '*test*.rs' -o -name '*.snap' -o -name '*.json' \) | sort | \
rg 'biome_analyze|biome_markdown_analyze|rule|markdown|header'
printf '%s\n' '--- diff summary and changed paths ---'
git diff --stat
git status --shortRepository: biomejs/biome
Length of output: 17171
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- exact Markdownlint references ---'
rg -n -C 3 'MarkdownLint|markdownlint' . -g '*.rs' -g '*.snap' -g '*.json' -g '*.md' || true
printf '%s\n' '--- RuleSource methods ---'
sed -n '224,305p' crates/biome_analyze/src/rule.rs
sed -n '320,545p' crates/biome_analyze/src/rule.rs
printf '%s\n' '--- all Rust test modules in biome_analyze ---'
rg -l '#\[cfg\(test\)\]|#\[test\]' crates/biome_analyze -g '*.rs' | sort
printf '%s\n' '--- metadata-related tests across the repository ---'
rg -n -C 4 'RuleMetadata|RuleMeta|sources\(\)|metadata\(\)|RuleSourceWithKind|is_inspired|to_rule_url|as_rule_name' . \
-g '*.rs' -g '*.snap' -g '*.json' | head -n 1200Repository: biomejs/biome
Length of output: 50370
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- metadata API and test usage ---'
rg -n -C 4 '::METADATA|METADATA\.sources|metadata\(\).*sources|RuleMeta for|declare_lint_rule' \
crates xtask -g '*.rs' | head -n 1000
printf '%s\n' '--- markdown test harness ---'
sed -n '1,220p' crates/biome_markdown_analyze/tests/spec_tests.rs
sed -n '1,180p' crates/biome_markdown_analyze/tests/quick_test.rs
printf '%s\n' '--- static contract verifier ---'
python3 - <<'PY'
from pathlib import Path
import re
rule = Path("crates/biome_analyze/src/rule.rs").read_text()
affected = Path(
"crates/biome_markdown_analyze/src/lint/nursery/use_consistent_header_level.rs"
).read_text()
all_rs = "\n".join(
p.read_text(errors="replace")
for p in Path(".").rglob("*.rs")
if ".git" not in p.parts and "target" not in p.parts
)
assert 'MarkdownLint(&\'a str, &\'a str)' in rule
assert 'Self::MarkdownLint(_, _) => write!(f, "markdownlint")' in rule
assert 'Self::MarkdownLint(_, rule_name)' in rule
assert 'Self::MarkdownLint(_, _) => ""' in rule
assert 'Self::MarkdownLint(rule_id, _) => format!("https://github.com/DavidAnson/markdownlint/blob/main/doc/{rule_id}.md")' in rule
assert '| Self::MarkdownLint(_, _)' in rule
assert 'RuleSource::MarkdownLint("MD001", "heading-increment").same()' in affected
assert 'kind: RuleSourceKind::SameLogic' in rule
# No dedicated assertions or test module currently cover this new variant.
assert not re.search(r'(?s)#\[test\].{0,2000}MarkdownLint', all_rs)
print("MarkdownLint mapping and SameLogic construction are present.")
print("No dedicated MarkdownLint test assertion was found.")
PYRepository: biomejs/biome
Length of output: 50369
Cover the Markdownlint source contract with tests.
Test RuleSource::MarkdownLint("MD001", "heading-increment") for its display name, rule name, empty namespace, https://github.com/DavidAnson/markdownlint/blob/main/doc/MD001.md URL, and is_eslint_plugin() == false. Test that useConsistentHeaderLevel exposes this source with RuleSourceKind::SameLogic.
📍 Affects 2 files
crates/biome_analyze/src/rule.rs#L220-L221(this comment)crates/biome_markdown_analyze/src/lint/nursery/use_consistent_header_level.rs#L45-L45
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/biome_analyze/src/rule.rs` around lines 220 - 221, The MarkdownLint
source contract lacks coverage. In crates/biome_analyze/src/rule.rs around
RuleSource::MarkdownLint, add tests verifying the MD001 source’s display name,
rule name, empty namespace, documentation URL, and is_eslint_plugin() == false;
in crates/biome_markdown_analyze/src/lint/nursery/use_consistent_header_level.rs
around useConsistentHeaderLevel, add a test confirming it exposes this source
with RuleSourceKind::SameLogic.
Source: Coding guidelines
| match self { | ||
| Self::Clippy(rule_name) => format!("https://rust-lang.github.io/rust-clippy/master/#{rule_name}"), | ||
| Self::DenoLint(rule_name) => format!("https://lint.deno.land/rules/{rule_name}"), | ||
| Self::MarkdownLint(rule_id, _) => format!("https://github.com/DavidAnson/markdownlint/blob/main/doc/{rule_id}.md"), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- relevant source ---'
sed -n '430,470p' crates/biome_analyze/src/rule.rs
printf '%s\n' '--- MarkdownLint references ---'
rg -n -C 3 'MarkdownLint|markdownlint|MD001|to_ascii_lowercase' crates/biome_analyze
printf '%s\n' '--- documentation URL status ---'
for url in \
'https://github.com/DavidAnson/markdownlint/blob/main/doc/MD001.md' \
'https://github.com/DavidAnson/markdownlint/blob/main/doc/md001.md'
do
printf '%s ' "$url"
curl -L -sS -o /dev/null -w '%{http_code}\n' "$url"
doneRepository: biomejs/biome
Length of output: 6964
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- MarkdownLint construction sites ---'
rg -n -C 4 'RuleSource::MarkdownLint|MarkdownLint\(' --glob '*.rs' .
printf '%s\n' '--- identifier accessors and tests ---'
sed -n '350,405p' crates/biome_analyze/src/rule.rs
rg -n -C 5 'to_rule_url|to_namespaced_rule_name|as_rule_name' crates/biome_analyze --glob '*.rs'Repository: biomejs/biome
Length of output: 12602
Lower-case the Markdownlint rule ID in the documentation URL.
The repository uses doc/md001.md; the current MD001 path returns 404. Keep MD001 unchanged in the public rule name and lower-case it only when building the URL.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/biome_analyze/src/rule.rs` at line 458, Update the Self::MarkdownLint
URL construction in the rule formatting logic to lowercase rule_id only when
interpolating the documentation URL, while preserving the original uppercase
rule ID in the public rule name.
Source: MCP tools
✅ Organic activityNo automation signals detected in the analyzed events. This is an automated analysis by AgentScan |
Merging this PR will improve performance by 11.39%
Performance Changes
Tip Curious why this is faster? Comment Comparing Footnotes
|
Summary
Add plumbing for markdownlint rule source
Test Plan
Docs