Skip to content
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

Update AriaLabelIsWellFormatted logic #66

Merged
merged 1 commit into from
Apr 17, 2023
Merged

Update AriaLabelIsWellFormatted logic #66

merged 1 commit into from
Apr 17, 2023

Conversation

khiga8
Copy link
Collaborator

@khiga8 khiga8 commented Apr 17, 2023

When I was working on the update in our app (staff-only: https://github.com/github/github/pull/269682), I noticed there were some scenarios that were being flagged that shouldn't be.

I am updating the logic of AriaLabelIsWellFormatted to make sure it's not flagging what it's not supposed to. I am also cleaning up the logic to separate the starts with lowercase check + includes newline check. In addition, I added a test to make sure that excepting interpolated string works.

<button aria-label="11 open" ></button>
HTML
def test_does_not_warn_with_string_interpolation
@file = '<button aria-label="Add a cat <%= "or dog " if dog_allowed? %>pet"></button>'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This aria-label value wasn't being parsed correctly in possible_attribute_values.

possible_attribute_values(tag, "aria-label") was returning or dog, which is causing it to be flagged. This appears to because basic_conditional_code_check is trying to parse the conditional, but it's not working very well. This basic_conditional_code_check was introduced long before we pulled this into this library, and I never examined closely what it was doing. It doesn't seem to be doing what it's supposed to do so I'm removing it.

HTML
@linter.config.exceptions = ["hello"]
@linter.config.exceptions = ["hello", "git checkout <%= some_branch %>"]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing to see if more "complex" exceptions using string interpolation can be made.

@khiga8 khiga8 marked this pull request as ready for review April 17, 2023 15:30
@khiga8 khiga8 requested a review from a team as a code owner April 17, 2023 15:30
@accessibility-bot
Copy link

👋 Hello and thanks for pinging us! An accessibility first responder will review this soon.

  • 💻 On PRs for our review: please provide a review environment with steps to validate, screenshots (with alt text), or videos demonstrating functionality we should be checking. This will help speed up our review and feedback cycle.
  • ⚠️ If this is urgent, please visit us in #accessibility on Slack and tag the first responder(s) listed in the channel topic.

@khiga8 khiga8 merged commit c0259fd into main Apr 17, 2023
@khiga8 khiga8 deleted the kh-fix-linter-logic branch April 17, 2023 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants