-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add no-generic-link-text rule #10
Conversation
👋 Hello and thanks for pinging us! An accessibility first responder will review this soon.
|
I am finally revisiting this as downtime work during FR and following the steps outlined in: https://github.com/github/markdownlint-github#development to try running this rule. However, I'm finding that the custom rules aren't running at all. I thought that this was a problem with my branch, but I'm seeing that the published package might be broken too. In the accessibility repo, I introduced a violation but that isn't being flagged... Update: It seemed to be an issue with the config in accessibility repo! Proceeding! |
- We don't want anything to break when link is blank. - Tests should account for links with punctuation text.
I made some updates because when I tested this against the I made additional updates by peeking at a link text related rules in I additionally pulled the I also added support so consumers can configure additional banned texts like so in addition to the default ones we have:
I opened a separate issue to add docs for each rule: #12. I am hoping to cut a new release after this! |
function: function GH002(params, onError) { | ||
// markdown syntax | ||
const allBannedLinkTexts = bannedLinkText.concat( | ||
params.config.additional_banned_texts || [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm using snake case to follow the convention set in markdownlint
for how rule configs are set.
const allBannedLinkTexts = bannedLinkText.concat( | ||
params.config.additional_banned_texts || [] | ||
); | ||
const inlineTokens = params.tokens.filter((t) => t.type === "inline"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found markdown-it demo and using the debug
functionality helpful for understanding how markdown is parsed.
Additionally, I referenced: md042.
I want to see this rule running in our projects successfully. Then I plan to upstream it to |
expect(results[0].errorDetail).toBe("For link: Click here"); | ||
}); | ||
|
||
test("additional words can be configured", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💖
@@ -0,0 +1,50 @@ | |||
const { stripAndDowncaseText } = require("./helpers/strip-and-downcase-text"); | |||
|
|||
const bannedLinkText = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible or worth making this work for various languages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This plugin doesn't currently have i18n support, but I added support so people can additionally configure text so they can through that!
Related: #10 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we will want to address i18n in a separate issue! I'll make an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Giving markdownlint rule-making a go 💪
no-generic-link-text
. This follows a similar rule we have in erblint-github. Seems like this would be a common violation in markdown.For now this rule only handles inline links because I wanted to avoid the complexities around determining link text of a link tag, especially since different markdown parsers have different levels of ARIA support.