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

chore: add a new eslint rule prevent using margin #17024

Merged
merged 5 commits into from
Dec 20, 2024

Conversation

koji
Copy link
Contributor

@koji koji commented Dec 3, 2024

Overview

add a new eslint rule prevent using margin
The new rules will show warnings when you use margins (inline & css-in-js).

why do we need this?

when we work on responsiveness, margins make things difficult.

https://mxstbr.com/thoughts/margin
https://www.joshwcomeau.com/css/rules-of-margin-collapse/

In addition, generally the design team doesn't use margins since they use Figma's Auto layout that uses padding and gap to create a layout.

bad cases

# inline case1
<StyledText marginLeft={SPACING.spacing4}>{'test'}</StyledText>

# inline case2
<Flex style={{ marginBottom: '1rem' }}>
  <StyledText>{'test'}</StyledText>
  <StyledText>{'test'}</StyledText>
</Flex>

# css-in-js case
const BAD_STYLE = css`
  margin-top: 1rem;
  margin-left: 1rem;
`

VSCode
https://opentrons.slack.com/archives/CSCLVUW3C/p1733182307004269

This pr cannot detect the following case

<Flex css={css`margin: ${SPACING.spacing8}`}></Flex>

I think we should avoid using the above implementation without any specific reason since that implementation makes code messy.

related thread
https://opentrons.slack.com/archives/CSCLVUW3C/p1733347927634689

close AUTH-1141

Test Plan and Hands on Testing

Changelog

  • add js files for the new custom eslint rules

Review requests

Risk assessment

low

add a new eslint rule prevent using margin

close AUTH-
@koji koji marked this pull request as ready for review December 12, 2024 21:44
@koji koji requested a review from a team as a code owner December 12, 2024 21:44
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

Let's do it!

@koji koji merged commit 3f10621 into edge Dec 20, 2024
20 checks passed
@koji koji deleted the chore_add-new-eslint-rule-avoid-margin branch December 20, 2024 14:21
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.

2 participants