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: Ensure class names conform to PascalCase #5716

Merged
merged 14 commits into from
Mar 4, 2025

Conversation

hussam-i-am
Copy link
Contributor

Closes https://github.com/github/primer/issues/4250

Changelog

New

Changed

  • Adds selector-class-pattern rule to check casing of class names
  • Updates classes that did not conform to casing
  • Wraps focus-visible and :popover-open classes with :global and make them exceptions to the rule

Removed

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

Merge checklist

@hussam-i-am hussam-i-am self-assigned this Feb 20, 2025
@hussam-i-am hussam-i-am requested a review from a team as a code owner February 20, 2025 16:15
Copy link

changeset-bot bot commented Feb 20, 2025

🦋 Changeset detected

Latest commit: fc925ea

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/react Minor

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

Copy link
Contributor

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Feb 20, 2025
& > .ItemLabel {
font-weight: var(--base-text-weight-semibold);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@langermank I did not see any usage of this class anywhere, so I removed it. Can you confirm?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh weird, it is used in Item

AL item

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I meant ActionListContent--hasActiveSubItem. I didn't see an explicit reference to it, or a concatenation of hasActiveSubItem

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah! Yes, that doesn't appear to be used.

Copy link
Member

Choose a reason for hiding this comment

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

Would be cool to setup something that would check for unused CSS

[tabindex='0']:focus:not(:focus-visible):not(.focus-visible),
details-dialog:focus:not(:focus-visible):not(.focus-visible) {
[tabindex='0']:focus:not(:focus-visible):not(:global(.focus-visible)),
details-dialog:focus:not(:focus-visible):not(:global(.focus-visible)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jonrohan I noticed that these did not have the :global wrapper, which I assume are needed for it to behave as expected.

Copy link
Member

Choose a reason for hiding this comment

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

🤷🏻 I guess so, but this change might need to be verified

Copy link
Member

Choose a reason for hiding this comment

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

This is going in on the next release, anything specific that needs to be validated UI-wise before landing this? @jonrohan @hussam-i-am

Copy link
Member

Choose a reason for hiding this comment

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

Not sure how to recreate this selector in the dom. Maybe drop a focus-visible class on a details-dialog element

Copy link
Member

Choose a reason for hiding this comment

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

Double checked, doesn't look like it breaks anything. We have some duplicate styles for this in primer/css that's already being imported

Copy link
Contributor

github-actions bot commented Feb 20, 2025

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 105.96 KB (-0.14% 🔽)
packages/react/dist/browser.umd.js 106.31 KB (-0.19% 🔽)

&.\\:popover-open,
&.\\:popover-open::before {
/* stylelint-disable-next-line selector-class-pattern */
&.\\:popover-open, &:global(.\\:popover-open)::before {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@github-actions github-actions bot requested a deployment to storybook-preview-5716 February 20, 2025 16:26 Abandoned
Copy link
Member

@joshblack joshblack left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to put this together! Just left one comment but otherwise 100% down to give this a try 👍

})}
/>
) : null}
{direction === SortDirection.DESC ? (
<SortDescIcon
className={clsx('TableSortIcon', 'TableSortIcon--descending', {
[classes.TableSortIcon]: enabled,
[classes['TableSortIcon--descending']]: enabled,
Copy link
Member

Choose a reason for hiding this comment

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

For this style I think it'd be helpful to preserve the original convention from BEM until we can update it to use our preferred approach with data attributes. Having -descending ends up as a weird hybrid between the two and I think it can lose the modifier meaning because of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense, updated

@hussam-i-am hussam-i-am requested a review from jonrohan March 3, 2025 20:03
@hussam-i-am hussam-i-am disabled auto-merge March 3, 2025 20:04
& > .ItemLabel {
font-weight: var(--base-text-weight-semibold);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Would be cool to setup something that would check for unused CSS

[tabindex='0']:focus:not(:focus-visible):not(.focus-visible),
details-dialog:focus:not(:focus-visible):not(.focus-visible) {
[tabindex='0']:focus:not(:focus-visible):not(:global(.focus-visible)),
details-dialog:focus:not(:focus-visible):not(:global(.focus-visible)) {
Copy link
Member

Choose a reason for hiding this comment

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

🤷🏻 I guess so, but this change might need to be verified

@hussam-i-am
Copy link
Contributor Author

Would be cool to setup something that would check for unused CSS

Yeah, I thought we already had something that checks, but I guess not in primer

@hussam-i-am
Copy link
Contributor Author

@jonrohan I added the package typed-css-modules, which will generate type definition files and at least ensure we are using class names that do exist. Couldn't find a clear solution for ensuring that any classes within the css file are being used.

Copy link
Member

@jonrohan jonrohan left a comment

Choose a reason for hiding this comment

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

Nice actually found some typos and incorrectly capitalized classes

@github-actions github-actions bot requested a deployment to storybook-preview-5716 March 4, 2025 18:20 Abandoned
@hussam-i-am hussam-i-am added this pull request to the merge queue Mar 4, 2025
Merged via the queue into main with commit d62a494 Mar 4, 2025
44 checks passed
@hussam-i-am hussam-i-am deleted the hussam-i-am/stylelint-pascal branch March 4, 2025 19:25
@primer primer bot mentioned this pull request Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants