-
Notifications
You must be signed in to change notification settings - Fork 3
Introduce rule documentation #26
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
89ac0f7
Update library structure
khiga8 e8fc30d
Add docs folder
khiga8 3d9e55c
Update information link
khiga8 fcd460b
Update docs/rules/GH002-no-generic-link-text.md
khiga8 d69622f
Update docs/rules/GH002-no-generic-link-text.md
khiga8 17b4370
Merge branch 'main' into kh-introduce-docs-folder
khiga8 98c0983
Update GH001-no-default-alt-text.md
khiga8 bd8b984
Update docs/rules/GH001-no-default-alt-text.md
khiga8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# GH001 No default alt text | ||
|
||
## Rule details | ||
|
||
Images should not use the macOS default screenshot filename as alternate text (alt text) which does not convey any meaningful information. | ||
|
||
Alternative text should concisely describe what is conveyed in the image. If the image is decorative, the alternative text should be set to an empty string (`alt=""`). | ||
|
||
Learn more at [Primer: Alternative text for images](https://primer.style/design/accessibility/alternative-text-for-images). | ||
|
||
## Examples | ||
|
||
### Incorrect 👎 | ||
|
||
```md | ||
 | ||
``` | ||
|
||
```md | ||
<img alt="Screen Shot 2022-06-26 at 7 41 30 PM" src="https://user-images.githubusercontent.com/abcdef.png"> | ||
``` | ||
|
||
### Correct 👍 | ||
|
||
```md | ||
<!-- Mark decorative images with an empty string --> | ||
|
||
 | ||
``` | ||
|
||
```md | ||
<img alt="A fluffy, orange kitten plays with a ball of yarn" src="https://user-images.githubusercontent.com/defgh.png"> | ||
``` | ||
|
||
```md | ||
<img alt="A GitHub Discussion page with the heading structure visually surfaced with a text overlay" src="https://user-images.githubusercontent.com/xyz.png"> | ||
``` | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# GH002 No generic link text | ||
|
||
## Rule details | ||
|
||
Avoid setting generic link text like, "Click here", "Read more", and "Learn more" which do not make sense when read out of context. | ||
|
||
Screen reader users often tab through links on a page to quickly find content without needing to listen to the full page. When link text does not clearly describe the actual linked content, it becomes difficult to quickly identify whether it's worth following the link. | ||
|
||
Ensure that your link text is descriptive and the purpose of the link is clear even when read without the context provided by surrounding text. | ||
|
||
Learn more about how to write descriptive link text at [Access Guide: Write descriptive link text](https://www.accessguide.io/guide/descriptive-link-text). | ||
|
||
**Note**: For now, this rule only flags inline markdown implementation of links given the complexities of determining the accessible name of an HTML anchor tag, | ||
|
||
## Configuration | ||
|
||
You can configure additional link texts to flag by setting the rule configuration like the following: | ||
|
||
```.js | ||
{ | ||
"no-generic-link-text": { | ||
"additional_banned_texts": ["Something", "Go here"] | ||
} | ||
} | ||
``` | ||
## Examples | ||
|
||
### Incorrect 👎 | ||
|
||
```md | ||
Go [here](https://github.com/) | ||
``` | ||
|
||
```md | ||
[Learn more](https://docs.github.com) | ||
``` | ||
|
||
```md | ||
[Click here](https://github.com/new) to create a new repository. | ||
``` | ||
|
||
### Correct 👍 | ||
|
||
```md | ||
[GitHub](https://github.com/) | ||
``` | ||
|
||
```md | ||
[GitHub Docs](https://docs.github.com) | ||
``` | ||
|
||
```md | ||
[Create a new repository](https://github.com/new) | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
"scripts": { | ||
"publish": "npm publish --access public --@github:registry=https://registry.npmjs.org", | ||
"test": "npm run lint && jest", | ||
"lint": "markdownlint-cli2 \"**/*.{md,mdx}\" \"!node_modules\" \"!test/example.md\" && eslint .", | ||
"lint": "markdownlint-cli2 \"**/*.{md,mdx}\" \"!node_modules\" \"!docs/rules\" \"!test/example.md\" && eslint .", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am excluding our docs because I don't want it to flag our "incorrect' usecase rules. 😅 |
||
"lint:fix": "npm run lint -- --fix" | ||
}, | ||
"dependencies": { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 really like how you provided examples of both Markdown and HTML techniques!