tldr-lint icon indicating copy to clipboard operation
tldr-lint copied to clipboard

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

Open sebastiaanspeck opened this issue 2 years ago • 6 comments

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

sebastiaanspeck avatar Oct 19 '23 23:10 sebastiaanspeck

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?

kbdharun avatar Oct 20 '23 04:10 kbdharun

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

sebastiaanspeck avatar Oct 20 '23 04:10 sebastiaanspeck

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. 😬

owenvoke avatar Oct 20 '23 08:10 owenvoke

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

sebastiaanspeck avatar Oct 20 '23 09:10 sebastiaanspeck

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.

kbdharun avatar Oct 20 '23 12:10 kbdharun

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

gutjuri avatar Mar 18 '24 19:03 gutjuri

Closing this since we use Lychee in github.com/tldr-pages/tldr-maintenance

sebastiaanspeck avatar Oct 04 '24 21:10 sebastiaanspeck