Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Rule: check for broken links #319

Open
1 task
fibo opened this issue Feb 23, 2025 · 2 comments
Open
1 task

New Rule: check for broken links #319

fibo opened this issue Feb 23, 2025 · 2 comments
Labels

Comments

@fibo
Copy link

fibo commented Feb 23, 2025

Rule details

A set of rules that check links, for example internal links in a markdown file or cross links from between two markdown files would be a huge value added. I am already using those rules via markdownlint and they are so useful. I saw many projects where the links in the markdown docs are broken. I am excited about using ESLint to lint also JSON, CSS, markdown etc. and having rules to check for broken links is the main criteria that would convince me to adopt ESLint for markdown.

What type of rule is this?

Warns about a potential problem

Example code

The same feature is implemented by the following packages as markdownlint custom rules:

- markdownlint-rule-github-internal-links
- markdownlint-rule-relative-links

Participation

  • I am willing to submit a pull request to implement this rule.

Additional comments

No response

@fibo fibo added the feature label Feb 23, 2025
@eslintbot eslintbot added this to Triage Feb 23, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Feb 23, 2025
@nzakas
Copy link
Member

nzakas commented Feb 24, 2025

Can you please explain exactly what you mean by "check for broken links"?

What is considered a "broken link"?

@nzakas nzakas moved this from Needs Triage to Triaging in Triage Feb 24, 2025
@fibo
Copy link
Author

fibo commented Feb 25, 2025

Sure @nzakas , thanks for you answer!!

Examples

Internal links

First of all, there are internal links.

# My project

[Installation](#installation) | [Usage](#usaage) | [Lincense](#license)

## Installation

    npm install my-project

## Usage

The link to this section in the Table of contents is broken.

## License

MIT

Cross links

Then there are links across different documents.

For example here the second link is broken.

# ESLint markdown

Rules:

- [`fenced-code-language`](docs/rules/fenced-code-language.md)
- [`heading-increment`](docs/rules/heading-increement.md)

Furthermore you can also have broken links cause one section was renamed or removed like

Install Node with proper version, see [requirements here](docs/requirements.md#node)

Counter example

On the other side, checking for external links within a tool like ESLint does not make sense to me. First of all because it depends a network connection. But also because there is no easy way to determine if a link is actually broken.

Conclusion and feedback

I hope it is clear, otherwise feel free to ping me.
I am really looking forward to use ESLint for Markdown as well as for CSS.
I am already experimenting with ESLint stylistic to replace prettier.
Also there, it is a tool not ready yet (especially for TypeScript) but very promising.
But the non plus ultra IMO would be an HTML linter that takes advantage of CSS, JS and possibly other linters to check mixed code in a page.
Sorry, I diverged.

I am also available to help implementing or testing the "broken links" rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Triaging
Development

No branches or pull requests

2 participants