-
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
Create a lint rule that enforces appropriate usage of Box
#55
Comments
Thanks for the suggestion @khiga8! This seems like a good idea for a component like |
as
as
as
for Box
as
for Box
as
for Box
Another thing that I noticed is that there's a ton of usage of <Box as="li"></Box> when one could simply render It appears this serves no utility, makes code harder to read, and additionally contributes to performance issues. |
as
for Box
Box
Additional questions around validity of |
@langermank brought up that there's an opportunity to flag migration from So far, there's quite a few "practices" we can enforce with
These probably should be separate rules. |
Problem statement
Primer React provides a couple of low-level utility components such as
<Box>
,<Text>
, and<Heading>
.In particular,
<Box>
seems to be used in all sorts of ways, outside of what the doc describes:For example, there's
<Box as="h1">
,<Box as="button">
, when people could be rendering<Heading>
or<h1>
, or<Button>
instead. Box usage outside of "wrapper-y" elements (e.g.div
,section
) feel like code smells.There is an opportunity to create a linter that suggests a more appropriate element or component based on the
as
prop.This isn't directly tied to accessibility, but components being used in a predictable manner is important.
<Box>
rendered withoutsx
are unnecessarily verbose and might as well just be semantic HTML elements. This will not only improve readability, but it would also apparently improve performance.Related slack thread
Acceptance criteria
Box
and/or auto-fixes it.The text was updated successfully, but these errors were encountered: