-
Notifications
You must be signed in to change notification settings - Fork 9
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 eslint-plugin-primer-react
#67
Conversation
🦋 Changeset detectedLatest commit: 2572099 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 |
@@ -15,10 +15,12 @@ const isUsingAsProp = elem => { | |||
|
|||
const isValidAsUsage = value => validHeadings.includes(value.toLowerCase()) | |||
const isInvalid = elem => { | |||
if (elem.attributes.length === 1 && elem.attributes[0].type === 'JSXSpreadAttribute') return; |
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 noticed a bug when <Heading>
was used with spread props ({...args}
), or when passing a variable withas
(<Heading as={as}>
).
If the spread is the only attribute present on the component, the checks will skip it. Similarly, if the component is using a variable for the as
prop, checks will also skip it.
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.
nice catch!!
src/configs/recommended.js
Outdated
Button: 'button', | ||
IconButton: 'button' | ||
} | ||
components: require('./components') |
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 created an individual file for component mapping (components.js
). This allows us to consolidate all the mappings we want in one place. It also introduces a custom structure that is currently a proof of concept which should allow us to easily map composable components. The alternative would be adding the object back into recommended.js
instead of separating the two.
Would love additional 👀 on this!
const path = require('path') | ||
|
||
module.exports = ({id}) => { | ||
const url = new URL(homepage) |
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.
Added this handy tool from eslint-plugin-github
that resolves the url path for documentation. This will allow us to use the docs
option easily.
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.
This is nicely coming together!!! Good catch with the bug!!
If you haven't already, I'd recommend running this against a dotcom branch -- I think we'll want to especially make sure that none of the component mappings result in false positives being thrown.
@@ -15,10 +15,12 @@ const isUsingAsProp = elem => { | |||
|
|||
const isValidAsUsage = value => validHeadings.includes(value.toLowerCase()) | |||
const isInvalid = elem => { | |||
if (elem.attributes.length === 1 && elem.attributes[0].type === 'JSXSpreadAttribute') return; |
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.
nice catch!!
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.
One minor suggestion, but otherwise LGTM!
I recommend making sure nothing unexpected is flagged by pointing a dotcom branch against these new updates in eslint-plugin-primer-react
.
I created a draft PR in dotcom that shows this branch working as expected! |
This PR provides the following updates:
eslint-plugin-jsx-a11y
andeslint-plugin-github
github
mappingjsx-a11y
component mappinga11y-explicit-heading
when using spread props, or variable foras
docs
option toa11y-explicit-heading