Skip to content

MD059: Identify bad link texts using "non-descriptive words" rather than "disallowed texts"? #1904

Description

@benblank

MD059 will always be prone to false negatives just because of the nature of trying to translate the idea of "descriptive" into code/config. But I was looking at the list of default disallowedTexts and thought there might be an alternate way of checking for descriptive link text which at least reduces false negatives without introducing false positives.

Basically, instead of having the rule act as a simple "disallow list" for complete link texts, perhaps it could keep a list of words which are known to be "non-descriptive" and ensure link texts contain at least one word not on that list. The configuration would then contain a nonDescriptiveWords (or some such) array containing words like "click", "for", "here", "link", "more", "on", "the", "this", etc. It still wouldn't be perfect, of course, but I think the idea of changing from "these phrases aren't descriptive" to "these words don't make a phrase descriptive" more closely matches the problem with non-descriptive links.

MD059 already normalizes the link text in a way which would simplify the change. The test at its heart is prohibitedTexts.has(normalize(text)); changing it to e.g. !normalize(text).split(" ").some((word) => !nonDescriptiveWords.has(word)) would give the rule the ability to catch additional link texts without requiring that each full link text be added to the config.

Some examples:

link text v0.40.0 proposed
click [here] ⚠️ ⚠️
[click here] ⚠️ ⚠️
click this [link] ⚠️ ⚠️
[click this link] ⚠️
[click here for more] ⚠️
[click here for more info]

I think this could really improve MD059's utility. How would you feel about introducing this kind of change?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions