Skip to content

chore: markdownlint rule source - #11265

Merged
Netail merged 2 commits into
mainfrom
chore/markdown-rule-source
Aug 7, 2026
Merged

Netail merged 2 commits into
mainfrom
chore/markdown-rule-source

Conversation

@Netail

@Netail Netail commented Aug 6, 2026

Copy link
Copy Markdown
Member

Summary

Add plumbing for markdownlint rule source

Test Plan

Docs

@changeset-bot

changeset-bot Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1bd3200

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e8a15fc7-2d7f-496a-b5e3-80883798fc41

📥 Commits

Reviewing files that changed from the base of the PR and between 0e2dd46 and 1bd3200.

📒 Files selected for processing (1)
  • crates/biome_markdown_analyze/src/lint/nursery/use_consistent_header_level.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/biome_markdown_analyze/src/lint/nursery/use_consistent_header_level.rs

Walkthrough

Adds RuleSource::MarkdownLint with Markdownlint display, rule-name, namespace, documentation URL, and classification handling. Maps Markdownlint rule MD001 (heading-increment) to use_consistent_header_level.

Possibly related PRs

Suggested reviewers: dyc3, ematipico

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding the markdownlint rule source plumbing.
Description check ✅ Passed The description directly relates to the changeset and states that it adds plumbing for the markdownlint rule source.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/markdown-rule-source

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between ea9dd8a and 0e2dd46.

📒 Files selected for processing (2)
  • crates/biome_analyze/src/rule.rs
  • crates/biome_markdown_analyze/src/lint/nursery/use_consistent_header_level.rs

Comment on lines +220 to +221
/// Rules from [markdownlint](https://github.com/DavidAnson/markdownlint)
MarkdownLint(&'a str, &'a str),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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_analyze

Repository: 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 --short

Repository: 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 1200

Repository: 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.")
PY

Repository: 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"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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"
done

Repository: 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be important

@Netail Netail changed the title chore: markdown rule source chore: markdownlint rule source Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

✅ Organic activity

No automation signals detected in the analyzed events.

View full analysis →

This is an automated analysis by AgentScan

@github-actions github-actions Bot added A-Linter Area: linter L-Markdown Language: Markdown labels Aug 6, 2026
@codspeed

codspeed Bot commented Aug 6, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 11.39%

⚡ 29 improved benchmarks
✅ 181 untouched benchmarks
⏩ 69 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
⚡ spec/autolinks.md[cached] 938 µs 784.5 µs +19.56%
⚡ synthetic/long-paragraphs.md[cached] 1.3 ms 1.1 ms +15.93%
⚡ spec/emphasis.md[cached] 1.9 ms 1.6 ms +14.7%
⚡ synthetic/long-paragraphs.md[uncached] 1.3 ms 1.2 ms +14.58%
⚡ spec/autolinks.md[uncached] 957.5 µs 837.2 µs +14.37%
⚡ spec/blockquotes.md[uncached] 349.1 µs 305.5 µs +14.27%
⚡ spec/lists.md[cached] 3.9 ms 3.4 ms +14.22%
⚡ spec/emphasis.md[uncached] 1.9 ms 1.7 ms +13.68%
⚡ spec/lists.md[uncached] 3.9 ms 3.4 ms +13.53%
⚡ spec/inline-html.md[cached] 914.3 µs 806.6 µs +13.36%
⚡ spec/blockquotes.md[cached] 333.4 µs 296.9 µs +12.28%
⚡ real/blog-post.md[uncached] 2.1 ms 1.9 ms +12.15%
⚡ real/blog-post.md[cached] 2.1 ms 1.8 ms +12.03%
⚡ real/readme-style.md[cached] 1.7 ms 1.5 ms +11.57%
⚡ spec/links.md[cached] 4.4 ms 4 ms +11.1%
⚡ real/readme-style.md[uncached] 1.8 ms 1.6 ms +11.04%
⚡ synthetic/blockquotes-nested.md[cached] 1.8 ms 1.7 ms +10.86%
⚡ spec/inline-html.md[uncached] 962.6 µs 869.2 µs +10.75%
⚡ synthetic/nested-lists.md[cached] 3.3 ms 2.9 ms +10.61%
⚡ synthetic/blockquotes-nested.md[uncached] 1.9 ms 1.7 ms +10.52%
... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing chore/markdown-rule-source (1bd3200) with main (ca2e0d0)2

Open in CodSpeed

Footnotes

  1. 69 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (ea9dd8a) during the generation of this report, so ca2e0d0 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@Netail
Netail merged commit edacfc6 into main Aug 7, 2026
40 checks passed
@Netail
Netail deleted the chore/markdown-rule-source branch August 7, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-Markdown Language: Markdown

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants