Skip to content

Commit

Permalink
ignore link first check for images and added test
Browse files Browse the repository at this point in the history
  • Loading branch information
rutefig authored and SamWilsn committed Jun 20, 2024
1 parent db50295 commit 97e667a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
4 changes: 2 additions & 2 deletions eipw-lint/src/lints/markdown/link_first.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ impl<'a, 'b, 'c> tree::Visitor for Visitor<'a, 'b, 'c> {
Ok(())
}

fn enter_image(&mut self, ast: &Ast, link: &NodeLink) -> Result<Next, Self::Error> {
self.check(ast, &link.title)
fn enter_image(&mut self, _: &Ast, _: &NodeLink) -> Result<Next, Self::Error> {
Ok(Next::SkipChildren)
}

fn enter_footnote_reference(&mut self, ast: &Ast, refn: &str) -> Result<Next, Self::Error> {
Expand Down
22 changes: 22 additions & 0 deletions eipw-lint/tests/lint_markdown_link_first.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,25 @@ hello

assert_eq!(reports, "");
}

#[tokio::test]
async fn img_then_linked() {
let src = r#"---
header: value1
---
![ello](../assets/example.svg)
[ello](https://example.com/)
"#;

let reports = Linter::<Text<String>>::default()
.clear_lints()
.deny("markdown-link-first", LinkFirst("ello"))
.check_slice(None, src)
.run()
.await
.unwrap()
.into_inner();

assert_eq!(reports, "");
}

0 comments on commit 97e667a

Please sign in to comment.