Skip to content

Update a11y-link-in-text-block rule to include HTML anchor elements #345

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link

@Copilot Copilot AI commented May 19, 2025

This PR adds support for detecting HTML anchor elements (<a>) in text blocks to the existing a11y-link-in-text-block rule. The rule now recommends converting HTML anchors to Link components from @primer/react for consistent styling and accessibility.

Changes

  • Enhanced the rule to detect HTML anchor elements within text blocks
  • Added autofix functionality to automatically replace HTML anchors with Link components
  • Updated documentation to include information about the new HTML anchor check
  • Added tests to verify the HTML anchor detection and autofix functionality

Examples

Before (Flagged by this rule):

<p>Please <a href="https://github.com">visit our site</a> for more information.</p>

After autofix:

<p>Please <Link href="https://github.com">visit our site</Link> for more information.</p>

Similar to the existing check for Link components, the rule skips certain cases to avoid false positives:

  • Anchor elements with a className attribute
  • Anchor elements with JSX element children
  • Anchor elements in headings
  • Anchor elements where the only adjacent text is a period

Fixes #344.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copy link

changeset-bot bot commented May 19, 2025

⚠️ No Changeset found

Latest commit: 67629e9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Co-authored-by: TylerJDev <26746305+TylerJDev@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Update a11y-link-in-text-block rule to include HTML anchor elements Update a11y-link-in-text-block rule to include HTML anchor elements May 19, 2025
@Copilot Copilot AI requested a review from TylerJDev May 19, 2025 18:51
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.

Update a11y-link-in-text-block rule to include HTML anchor elements
2 participants