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

Relax requirement for label extraction - containing functions dont have to be PascalCased anymore #1805

Merged
merged 1 commit into from
Mar 16, 2020

Conversation

Andarist
Copy link
Member

It IMHO makes sense to relax this, otherwise styles from functions calling css dont receive labels.

@Andarist Andarist requested a review from emmatown March 14, 2020 15:23
@changeset-bot
Copy link

changeset-bot bot commented Mar 14, 2020

🦋 Changeset is good to go

Latest commit: 9bddf18

We got this.

This PR includes changesets to release 8 packages
Name Type
@emotion/babel-plugin Major
@emotion/server Major
@emotion/react Major
@emotion/jest Major
@emotion/primitives-core Major
@emotion/styled Major
@emotion/native Major
@emotion/primitives Major

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Mar 14, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 9bddf18:

Sandbox Source
Emotion Configuration

@Andarist Andarist force-pushed the relax-pascalcase-requirement branch 2 times, most recently from e51e5b7 to 61d7160 Compare March 14, 2020 17:37
@codecov
Copy link

codecov bot commented Mar 14, 2020

Codecov Report

Merging #1805 into next will decrease coverage by <.01%.
The diff coverage is 100%.

Impacted Files Coverage Δ
...ugin/src/utils/transform-expression-with-styles.js 95.83% <100%> (ø) ⬆️
packages/babel-plugin/src/utils/label.js 97.82% <100%> (-0.29%) ⬇️

Copy link
Member

@emmatown emmatown left a comment

Choose a reason for hiding this comment

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

Not sure this is good - labels are largely intended to be a way to find which component corresponds to which class name and this means if you have a helper function, it would show up all over the place and therefore make labels less helpful

@Andarist
Copy link
Member Author

This only gives a label based on a function if there is no intermediate declaration, etc, in the ancestors' chain. Right now this gets a label:

const foo = css`color: green;`

but this doesnt

const foo = () => css`color: green;`

This is surprising for some (had a couple of questions regarding this on Slack and here on GitHub).

I don't see much difference between a "partial" styles (exhibit one) and a helper function creating such (exhibit two). Could you maybe prepare a case where you think this would become problematic?

Copy link
Member

@emmatown emmatown left a comment

Choose a reason for hiding this comment

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

Okay sure. Could you check that that any valid variable name is also valid in a class name or otherwise, remove the bad characters or something? Other than that, LGTM

@Andarist Andarist force-pushed the relax-pascalcase-requirement branch from 61d7160 to 9bddf18 Compare March 16, 2020 23:15
@Andarist
Copy link
Member Author

@mitchellhamilton all "locals" are being sanitized when actually generating labels:

if (!labelFormat) return sanitizeLabelPart(identifierName)
, so it's already covered

@Andarist Andarist merged commit 5c7ec85 into next Mar 16, 2020
@Andarist Andarist deleted the relax-pascalcase-requirement branch March 16, 2020 23:23
louisgv pushed a commit to louisgv/emotion that referenced this pull request Sep 6, 2020
@github-actions github-actions bot mentioned this pull request Nov 10, 2020
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