ethereum / eipw

Mozilla Public License 2.0
28 stars 27 forks source link

Fix regular expression for compactability #92

Closed IjayAbby closed 1 month ago

IjayAbby commented 6 months ago

The expected issue was fixed using the explanation below

Error

The Fix

SamWilsn commented 6 months ago

What issue is this associated with?

IjayAbby commented 6 months ago

This one https://github.com/ethereum/eipw/issues/91

SamWilsn commented 6 months ago

Ah. For this one, you'll want to make a change somewhere around here:

https://github.com/ethereum/eipw/blob/93266e615fcc32fef89d703aaad1357cbe229463/eipw-lint/src/lints/markdown/regex.rs#L136-L138

The easiest solution (and the one I'd recommend) is skipping the self.check(...) call if link.url == link.title.

IjayAbby commented 6 months ago

So when am pushing I should reverse the other files to their original state?

SamWilsn commented 6 months ago

Yep! If you can add a test with an autolink to show that your change works as expected, that'd be great too.

IjayAbby commented 6 months ago

Quick question: If I run npm install it should be able to set up my local environment? My test should be in this file https://github.com/ethereum/eipw/blob/93266e615fcc32fef89d703aaad1357cbe229463/eipw-lint/tests/lint_markdown_regex.rs ?

SamWilsn commented 6 months ago

You'll need to setup Rust, and use cargo (not npm.)

See https://doc.rust-lang.org/book/ch01-00-getting-started.html

IjayAbby commented 6 months ago

Hello @SamWilsn, I have set up my project on my local and I would love to mimic the error from the issue above but anytime I run cargo test on regex.rs file all the test are passing. Do you have any idea of where am going wrong. Rather any documentation I can use to replicate the tests?

SamWilsn commented 6 months ago

There is no test yet for this issue, so there's nothing to fail.

A test might look something like:

#[tokio::test]
async fn excludes_autolink() {
    let src = r#"---
header: value1
---

A link <https://example.com>.
"#;

    let reports = Linter::<Text<String>>::default()
        .clear_lints()
        .deny(
            "markdown-re",
            Regex {
                message: "boop",
                mode: Mode::Excludes,
                pattern: "example",
            },
        )
        .check_slice(None, src)
        .run()
        .await
        .unwrap()
        .into_inner();

    assert_eq!(
        reports,
        ""
    );
}

I haven't tried the above, so you might need to tweak it a bit. This should live in lint_markdown_regex.rs

IjayAbby commented 6 months ago

Thank you, will consider this.

IjayAbby commented 6 months ago

Ah. For this one, you'll want to make a change somewhere around here:

https://github.com/ethereum/eipw/blob/93266e615fcc32fef89d703aaad1357cbe229463/eipw-lint/src/lints/markdown/regex.rs#L136-L138

The easiest solution (and the one I'd recommend) is skipping the self.check(...) call if link.url == link.title.

Hello am trying to wrap my head around the meaning of this ast: &Ast

IjayAbby commented 1 month ago

Am having this error after pulling the recent changes Screenshot from 2024-10-18 16-10-51