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?
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
disallowedTextsand 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:
I think this could really improve MD059's utility. How would you feel about introducing this kind of change?