From a9069adc3eef46e5d12a1c9ea2b4679c5baa3287 Mon Sep 17 00:00:00 2001 From: Jose Alfonso <92005826+JEAlfonsoP@users.noreply.github.com> Date: Sun, 26 Feb 2023 00:00:30 +0100 Subject: [PATCH] Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update test.yaml Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update Cargo.toml Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update test.yaml Update relative_links.rs Update test.yaml Update test.yaml Update test.yaml Update Cargo.toml Update test.yaml Update test.yaml Update test.yaml Update Cargo.toml Update test.yaml Update test.yaml Update test.yaml Update test.yaml Update test.yaml Update test.yaml Update Cargo.toml Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update Cargo.toml Update test.yaml Update test.yaml Update relative_links.rs Update Cargo.toml Update Cargo.toml Update test.yaml Update relative_links.rs Update test.yaml Update relative_links.rs Update test.yaml Update test.yaml Update relative_links.rs Update Cargo.toml Update Cargo.toml Update test.yaml Update relative_links.rs Update relative_links.rs Bit of work on implementation and more tests (#5) Update relative_links.rs Update lint_markdown_relative_links.rs Update relative_links.rs Update lint_markdown_relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs Update relative_links.rs --- .../tests/lint_markdown_relative_links.rs | 148 +++++++++++++++++- 1 file changed, 147 insertions(+), 1 deletion(-) diff --git a/eipw-lint/tests/lint_markdown_relative_links.rs b/eipw-lint/tests/lint_markdown_relative_links.rs index 64c66fb5..d3406440 100644 --- a/eipw-lint/tests/lint_markdown_relative_links.rs +++ b/eipw-lint/tests/lint_markdown_relative_links.rs @@ -1,7 +1,7 @@ /* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at https://mozilla.org/MPL/2.0/. + * file. You can obtain one at https://mozilla.org/MPL/2.0/. */ use eipw_lint::lints::markdown::RelativeLinks; @@ -69,6 +69,63 @@ header: value1 ); } +#[tokio::test] +async fn inline_link_with_scheme_to_eips_ethereum_org() { + let src = r#"--- +header: value1 +--- + +[hello](https://eips.ethereum.org/EIPS/eip-1234) +"#; + + let reports = Linter::>::default() + .clear_lints() + .deny("markdown-rel", RelativeLinks { exceptions: &[] }) + .check_slice(None, src) + .run() + .await + .unwrap() + .into_inner(); + + assert_eq!( + reports, + r#"error[markdown-rel]: non-relative link or image + | +5 | [hello](https://eips.ethereum.org/EIPS/eip-1234) + | + = help: use `./eip-1234.md` instead +"# + ); +} + +#[tokio::test] +async fn inline_link_with_scheme_and_numbers() { + let src = r#"--- +header: value1 +--- + +[hi](https://example.com/4444) +"#; + + let reports = Linter::>::default() + .clear_lints() + .deny("markdown-rel", RelativeLinks { exceptions: &[] }) + .check_slice(None, src) + .run() + .await + .unwrap() + .into_inner(); + + assert_eq!( + reports, + r#"error[markdown-rel]: non-relative link or image + | +5 | [hi](https://example.com/4444) + | +"# + ); +} + #[tokio::test] async fn inline_link_protocol_relative() { let src = r#"--- @@ -224,6 +281,37 @@ Hello [hi][hello]! assert_eq!(reports, ""); } +#[tokio::test] +async fn reference_link_with_scheme_to_eips_ethereum_org() { + let src = r#"--- +header: value1 +--- + +Hello [hi][hello]! + +[hello]: https://eips.ethereum.org/EIPS/eip-1234 +"#; + + let reports = Linter::>::default() + .clear_lints() + .deny("markdown-rel", RelativeLinks { exceptions: &[] }) + .check_slice(None, src) + .run() + .await + .unwrap() + .into_inner(); + + assert_eq!( + reports, + r#"error[markdown-rel]: non-relative link or image + | +5 | Hello [hi][hello]! + | + = help: use `./eip-1234.md` instead +"# + ); +} + #[tokio::test] async fn inline_autolink() { let src = r#"--- @@ -325,6 +413,35 @@ header: value1 ); } +#[tokio::test] +async fn anchor_link_protocol_relative_to_eips_ethereum_org() { + let src = r#"--- +header: value1 +--- + +example +"#; + + let reports = Linter::>::default() + .clear_lints() + .deny("markdown-rel", RelativeLinks { exceptions: &[] }) + .check_slice(None, src) + .run() + .await + .unwrap() + .into_inner(); + + assert_eq!( + reports, + r#"error[markdown-rel]: non-relative link or image + | +5 | example + | + = help: use `./eip-1234.md` instead +"# + ); +} + #[tokio::test] async fn anchor_link_relative_double_slash() { let src = r#"--- @@ -409,3 +526,32 @@ header: value1 "# ); } + +#[tokio::test] +async fn img_protocol_relative_to_eips_ethereum_org() { + let src = r#"--- +header: value1 +--- + + +"#; + + let reports = Linter::>::default() + .clear_lints() + .deny("markdown-rel", RelativeLinks { exceptions: &[] }) + .check_slice(None, src) + .run() + .await + .unwrap() + .into_inner(); + + assert_eq!( + reports, + r#"error[markdown-rel]: non-relative link or image + | +5 | + | + = help: use `../assets/eip-712/eth_sign.png` instead +"# + ); +}