Add lint to prevent (most) URLs
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:
exampleexample.comexample.netexample.orginvalidtest
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.
- Disallowed because:
-
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.
- Disallowed because:
-
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.
- Disallowed because:
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.
Hi @SamWilsn i want to work on this. Kindly assign me to this issue
Go for it!
i should add this lint functionality in the "lints/markdown" folder right? @SamWilsn
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!
okay so, basically what i am meant to do are:
- Create a lint functionality in the "eipw-lint/src/lints/markdown" folder.
- Update the 'markdown-rel-links' in the READme.
- Update the "docs/markdown-rel-links/index.html" in the docs.
Is this well stated?.
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!
i understand it better now. Thanks
Hi @SamWilsn i made a pull request here https://github.com/ethereum/eipw/pull/106
I've added a bit more detail to the initial issue. Hopefully that makes it more clear!
Hi @SamWilsn kindly help review. I made some changes.
https://github.com/ethereum/eipw/pull/106