tldr-pages / tldr-lint

A linting tool to validate tldr pages
https://www.npmjs.com/package/tldr-lint
MIT License
35 stars 20 forks source link

New linter error if the link in more information isn’t reachable anymore #280

Open sebastiaanspeck opened 8 months ago

sebastiaanspeck commented 8 months ago

To keep the pages up-to-date, we could introduce an linter error if the link in “More information” isn’t working/reachable.

kbdharun commented 8 months ago

Can you explain a bit about how we could implement it in Linter?

Would you ping the page's links to check if it is reachable? Or is there something we can use natively?

sebastiaanspeck commented 8 months ago

We could use wget to do something like this:

LINK_OF_INTEREST=$(awk 'NR==3{print $3}' file.md)
TOTAL_TIME=$(wget --page-requisites --output-document /dev/null "$LINK_OF_INTEREST" 2>&1 | grep -oE 'Total wall clock time: [0-9.]+s' | grep -oE '[0-9.]+')

if [ "$(echo "$TOTAL_TIME < 1" | bc -l)" -eq 1 ]; then
    echo "Total time is below 1 second"
else
    echo "Total time is 1 second or more"
fi
owenvoke commented 8 months ago

I think that this shouldn't really be part of the linter. 🤔 Especially as the linter runs every time a new page is added (or a PR is merged), we might be spamming a lot of sites. 😬

sebastiaanspeck commented 8 months ago

I get that! Maybe we can create a script that run's once a month to report any broken links?

kbdharun commented 8 months ago

I think that this shouldn't really be part of the linter. 🤔 Especially as the linter runs every time a new page is added (or a PR is merged), we might be spamming a lot of sites. 😬

This is exactly what I thought too as we document lesser-known tools too, we might be stressing their servers by sending multiple requests at a time if it got included in the linter.

gutjuri commented 3 months ago

This issue may be closed by https://github.com/tldr-pages/tldr/pull/12506