eipw icon indicating copy to clipboard operation
eipw copied to clipboard

Add lint to prevent (most) URLs

Open SamWilsn opened this issue 1 year ago • 10 comments

Summary

Many authors attempt to bypass markdown-rel-links by putting their URL in backticks:

Check out `https://google.com`.

We should add a lint to make sure that all HTTP(S) URLs that are not hyperlinked (so in code fences, backticks, plain text, etc.) use example domains. Specifically, the following (and any subdomains thereof) would be allowed:

  • example
  • example.com
  • example.net
  • example.org
  • invalid
  • test

Examples

Disallowed

The following snippets should trigger this lint:

  • Check out `https://google.com/hello`.
    
    • Disallowed because:
      • the domain is not on the list above; and
      • the URL is not in a link.
  • With the following command:
    
    ```
    curl https://google.com/hello
    ```
    
    • Disallowed because:
      • the domain is not on the list above; and
      • the URL is not in a link.
  • Here is an unhyperlinked link http://google.com
    
    • Disallowed because:
      • the domain is not on the list above; and
      • the URL is not in a link.

Allowed

While the following should not trigger this lint:

  • Check out `https://example.com/hello`.
    
    • Allowed because the domain is on the approved list above.
  • With the following command:
    
    ```
    curl https://google.com.invalid/hello
    ```
    
    • Allowed because the domain is on the approved list above.
  • <https://google.com>
    
    • Allowed because the URL appears in a link.
  • [boop](https://google.com)
    
    • Allowed because the URL appears in a link.
  • [boop]
    [boop]: https://google.com
    
    • Allowed because the URL appears in a link.

SamWilsn avatar Aug 14 '24 21:08 SamWilsn

Hi @SamWilsn i want to work on this. Kindly assign me to this issue

KoxyG avatar Sep 04 '24 08:09 KoxyG

Go for it!

SamWilsn avatar Sep 04 '24 14:09 SamWilsn

i should add this lint functionality in the "lints/markdown" folder right? @SamWilsn

KoxyG avatar Sep 04 '24 16:09 KoxyG

Yep! And if you wouldn't mind adding a row to the readme, and an HTML file in the docs folder, I'd appreciate it!

SamWilsn avatar Sep 04 '24 17:09 SamWilsn

okay so, basically what i am meant to do are:

  1. Create a lint functionality in the "eipw-lint/src/lints/markdown" folder.
  2. Update the 'markdown-rel-links' in the READme.
  3. Update the "docs/markdown-rel-links/index.html" in the docs.

Is this well stated?.

KoxyG avatar Sep 04 '24 17:09 KoxyG

This should be a separate lint from markdown-rel-links. Maybe it could be markdown-must-hyperlink or something? The name isn't too important.

So the full scope of work is:

  • Add the new lint in eipw-lint/src/lints/markdown/something.rs
  • Add it to DefaultLints
  • Add a default configuration in eipw-lint/src/lib.rs
  • Write some tests. I usually do a few normal tests (example.) You can also write an end-to-end test (example) but that's probably overkill for this lint.
  • Add a row to README.md.
  • Add a new directory and HTML file in docs/. Note that the directory name has to match the lint name.

Hopefully I haven't missed anything!

SamWilsn avatar Sep 04 '24 17:09 SamWilsn

i understand it better now. Thanks

KoxyG avatar Sep 04 '24 17:09 KoxyG

Hi @SamWilsn i made a pull request here https://github.com/ethereum/eipw/pull/106

KoxyG avatar Sep 05 '24 08:09 KoxyG

I've added a bit more detail to the initial issue. Hopefully that makes it more clear!

SamWilsn avatar Sep 05 '24 13:09 SamWilsn

Hi @SamWilsn kindly help review. I made some changes.

https://github.com/ethereum/eipw/pull/106

KoxyG avatar Sep 09 '24 05:09 KoxyG