Skip to content

Commit 371f619

Browse files
ekropotinclaude
andauthored
feat: implement MD034 no-bare-urls rule with comprehensive validation (#50)
Add complete implementation of MD034 rule that detects bare URLs and email addresses that should be properly formatted with angle brackets or markdown links. Key Features: - Uses linkify crate for robust URL/email detection - Handles complex edge cases: mailto: schemes, URLs in link text, code spans - Perfect parity with original markdownlint (27/27 violations match) - Comprehensive test suite with 16 unit tests including edge cases - International domain and email support - Single-pass O(n) performance optimized algorithm Implementation Details: - Processes paragraph nodes to find bare URLs within markdown text - Excludes properly formatted contexts: <url>, [text](url), `code`, HTML attributes - Enhanced markdown link detection for both link text and targets - Sophisticated pattern matching for scheme prefixes (mailto:, ftp:, etc.) Files Added: - crates/quickmark_linter/src/rules/md034.rs (504 lines) - docs/rules/md034.md (rule documentation) - test-samples/test_md034_*.md (comprehensive test cases) Dependencies Added: - linkify 0.10 for accurate URL/email detection Progress: 8/48 rules implemented (16.7%) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9cafa36 commit 371f619

11 files changed

Lines changed: 837 additions & 5 deletions

File tree

.github/workflows/rust.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ permissions:
55

66
on:
77
push:
8-
branches: [ "main" ]
8+
branches: [ "main", "development" ]
99
pull_request:
10-
branches: [ "main" ]
10+
branches: [ "main", "development" ]
1111

1212
env:
1313
CARGO_TERM_COLOR: always
@@ -26,7 +26,7 @@ jobs:
2626

2727
fmt:
2828
runs-on: ubuntu-latest
29-
29+
3030
steps:
3131
- uses: actions/checkout@v4
3232
- name: Check formatting

Cargo.lock

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ ignored_definitions = ["//"]
8585

8686
## Rules
8787

88-
**Implementation Progress: 7/48 rules completed (14.6%)**
88+
**Implementation Progress: 8/48 rules completed (16.7%)**
8989

9090
- [x] **[MD001](docs/rules/md001.md)** *heading-increment* - Heading levels should only increment by one level at a time
9191
- [x] **[MD003](docs/rules/md003.md)** *heading-style* - Consistent heading styles
@@ -115,7 +115,7 @@ ignored_definitions = ["//"]
115115
- [ ] **MD031** *blanks-around-fences* - Fenced code blocks surrounded by blank lines
116116
- [ ] **MD032** *blanks-around-lists* - Lists surrounded by blank lines
117117
- [ ] **MD033** *no-inline-html* - Inline HTML usage
118-
- [ ] **MD034** *no-bare-urls* - Bare URLs without proper formatting
118+
- [x] **[MD034](docs/rules/md034.md)** *no-bare-urls* - Bare URLs without proper formatting
119119
- [ ] **MD035** *hr-style* - Horizontal rule style consistency
120120
- [ ] **MD036** *no-emphasis-as-heading* - Emphasis used instead of heading
121121
- [ ] **MD037** *no-space-in-emphasis* - Spaces inside emphasis markers

crates/quickmark_config/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ mod tests {
294294
heading-increment = 'warn'
295295
heading-style = 'err'
296296
line-length = 'err'
297+
no-bare-urls = 'err'
297298
no-duplicate-heading = 'err'
298299
link-fragments = 'warn'
299300
reference-links-images = 'err'
@@ -343,6 +344,10 @@ mod tests {
343344
RuleSeverity::Error,
344345
*parsed.linters.severity.get("line-length").unwrap()
345346
);
347+
assert_eq!(
348+
RuleSeverity::Error,
349+
*parsed.linters.severity.get("no-bare-urls").unwrap()
350+
);
346351
assert_eq!(
347352
RuleSeverity::Error,
348353
*parsed.linters.severity.get("no-duplicate-heading").unwrap()

crates/quickmark_linter/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ edition = "2021"
55

66
[dependencies]
77
anyhow = "1.0.86"
8+
linkify = "0.10"
89
once_cell = "1.19"
910
regex = "1.0"
1011
tree-sitter = "0.25.6"

0 commit comments

Comments
 (0)