Skip to content

Commit 9b4b0e0

Browse files
Allow users to pass in a custom linting configuration (#61)
* Allow users to pass in a custom linting configuration * Add experimental custom linting configuration section more information * clean up message for custom config * Apply suggestions from code review Co-authored-by: Joyce Zhu <[email protected]> --------- Co-authored-by: Joyce Zhu <[email protected]>
1 parent 645a5ab commit 9b4b0e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+17101
-4275
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,27 @@ This makes sure you stay on a stable version of this action.
6868
6969
Replace the ref value with any commit hash.
7070
71+
### Experimental: Adding a custom linting configuration
72+
73+
If you would like to include more linting rules from the [markdownlint](https://github.com/DavidAnson/markdownlint) or [markdownlint-github](https://github.com/github/markdownlint-github) rulesets, pass a `config` object to the `github/accessibility-alt-text-bot` action.
74+
75+
76+
⚠ Consider adding new rules sparingly, as excessive rules could make the bot too noisy and overwhelm users.
77+
78+
⚠ This feature is experimental and may be removed in the future. We acknowledge that some repositories may want to implement more accessibility checks and aim to evaluate how users this feature before making it generally available.
79+
80+
```yml
81+
steps:
82+
- name: Check alt text
83+
uses: github/[email protected]
84+
with:
85+
config: |
86+
no-default-alt-text: true,
87+
no-alt-text: true,
88+
no-empty-alt-text: true,
89+
no-generic-link-text: true,
90+
```
91+
7192
## License
7293

7394
This project is licensed under the terms of the MIT open source license.

action.yml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ description: "This action will check a repos issue, discussion, or PR for correc
33
branding:
44
icon: "eye"
55
color: "purple"
6+
inputs:
7+
config:
8+
description: "A custom linting configuration"
9+
required: false
610
runs:
711
using: "composite"
812
steps:
@@ -61,7 +65,16 @@ runs:
6165
bot_comment_id=$(gh api repos/${{ github.repository }}/discussions/${{ github.event.discussion.number }}/comments | jq -r '.[] | select(.user.login == "github-actions[bot]") | select(.body | test("<div alt-text-bot-id=\"${{ github.event.discussion.id }}\"")) | .node_id')
6266
fi
6367
fi
64-
flag=$(node ${{ github.action_path }}/src/index.js "$content")
68+
69+
flag=$(node ${{ github.action_path }}/src/index.js "$content" "$CONFIG")
70+
71+
custom_config_message="<div alt-text-bot-id=\"$target_id\" /> Uh oh! @$user, your markdown has a few linting errors. Check $target to fix the following violations:
72+
73+
$flag
74+
75+
> 🤖 Beep boop! This comment was added automatically by [github/accessibility-alt-text-bot](https://github.com/github/accessibility-alt-text-bot).
76+
"
77+
6578
message="<div alt-text-bot-id=\"$target_id\" /> Uh oh! @$user, at least one image you shared is missing helpful alt text. Check $target to fix the following violations:
6679

6780
$flag
@@ -73,7 +86,12 @@ runs:
7386
> 🤖 Beep boop! This comment was added automatically by [github/accessibility-alt-text-bot](https://github.com/github/accessibility-alt-text-bot).
7487
"
7588
76-
echo "Detected bad alt text: ${flag}"
89+
echo "Config: $CONFIG"
90+
if [ "$CONFIG" ]; then
91+
message=$custom_config_message
92+
fi
93+
94+
echo "Detected errors: ${flag}"
7795
echo "Event type: $type"
7896
if [[ $flag && ${{ github.event.action }} != 'deleted' ]]; then
7997
if [ $bot_comment_id ]; then
@@ -115,3 +133,4 @@ runs:
115133
ISSUE_BODY: ${{ github.event.issue.body }}
116134
PR_BODY: ${{ github.event.pull_request.body }}
117135
DISCUSSION_BODY: ${{ github.event.discussion.body }}
136+
CONFIG: ${{ inputs.config }}

node_modules/.package-lock.json

Lines changed: 36 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@istanbuljs/load-nyc-config/node_modules/.bin/js-yaml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@istanbuljs/load-nyc-config/node_modules/argparse/CHANGELOG.md

Lines changed: 185 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@istanbuljs/load-nyc-config/node_modules/argparse/LICENSE

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)