-
Notifications
You must be signed in to change notification settings - Fork 10
Introduce a new rule to flag Link in text blocks without inline
#183
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
Conversation
🦋 Changeset detectedLatest commit: 5a27eea The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
9c1e307
to
c859fa0
Compare
48aa412
to
fbe6078
Compare
inline
I'm still in the process of getting feedback to make sure there's nothing unexpected with the instances flagged by this rule via PRs in dotcom but want to open this up for early review! |
Makes sense to me on a theoretical level, hard to review without testing it. Can we run this once on gh/gh to see if it catches any false positives? Update: Just saw you are already doing that ❤️ |
inline
inline
Co-authored-by: Siddharth Kshetrapal <[email protected]>
All PRs in dotcom have been reviewed and merged without any issues! |
src/configs/recommended.js
Outdated
@@ -16,6 +16,7 @@ module.exports = { | |||
'primer-react/new-color-css-vars': 'error', | |||
'primer-react/a11y-explicit-heading': 'error', | |||
'primer-react/no-deprecated-props': 'warn', | |||
'primer-react/a11y-link-in-text-block': 'error', |
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.
Given that inline
is specific to dotcom's setup, maybe this should not be turned on by default. would love to hear what others think!
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.
True, we shouldn't turn it on by default
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.
LGTM!
Relates to:
inline
prop for<Link>
s in text block #182What
This PR introduces a new accessibility lint rule to ensure that links inside of a text block have the
inline
prop.Why
The current recommendation in dotcom is to add
inline
prop on allLink
s that appear within a text block to ensure that a user’s accessibility link underline setting is respected.However, there are currently no automated tools to enforce that developers actually set this prop on their links. As a result, developers continue to add Links to text blocks contributing to 1.4.1: Use of Color accessibility issues.
By having this lint rule in place, we can proactively surface to developers when they should set the
inline
prop.Implementation details
The logic essentially treats any
Link
that appears with a string literal on either side of it as a link within a text block. It checks for the presence ofinline
orinline={true}
.For example, the following will be flagged:
In addition, this lint rule aims to minimize false positives and will skip Links even if adjacent text is detected for the following scenarios:
<Link sx={{fontWeight:...}}>
or<Link sx={{fontFamily:...}}>
- these technically may provide sufficient distinguishing styling.<Link>
where the only adjacent text is a period - these can't really be considered a text block.<Link>
where the children is a JSX component, rather than a string literal - this is because the JSX component may be an icon link, in which case it may be sufficient to distinguish.<Link>
that are nested inside of headings - these feel safer to skip...Testing / Validation
I've tested this branch against dotcom to make sure there's nothing unexpected! This flagged around 140
Link
missing inline in dotcom. I've gone ahead and opened fixes for whatever was flagged by this rule across 8 PRs.I broke this up into reviewable chunks so that codeowners can make sure to minimize false positives raised by this rule. (Related: https://github.com/github/accessibility/issues/6434)
Reviewers 📣
recommended.js
or is this only relevant to dotcom?<Link underline>
even though technicallyunderline
does provide sufficient styling. I decided to flagunderline
because I noticed it is deprecated so maybe this is an opportunity for consumers to migrate toinline
. Let me know if you think we shouldn't flagunderline
!