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

Components: add "Naming conventions" section #63714

Merged
merged 13 commits into from
Aug 8, 2024

Conversation

ciampo
Copy link
Contributor

@ciampo ciampo commented Jul 18, 2024

What?

Closes #63242

Tweak the contributing guidelines, updating a few out of date parts and adding a new "Naming Conventions" section based on the conversation happening in #63242

Why?

As we introduce more compound components in the package, we need a recommended naming conventions for both monolithic and compound components going forward.

@ciampo ciampo self-assigned this Jul 18, 2024
@ciampo ciampo added the [Type] Developer Documentation Documentation for developers label Jul 18, 2024
@ciampo ciampo requested a review from a team July 18, 2024 15:30
@ciampo
Copy link
Contributor Author

ciampo commented Jul 18, 2024

@WordPress/gutenberg-components I took an initial stab at updating the contributing guidelines.

Also cc @diegohaz in case you have any feedback.

@ciampo ciampo marked this pull request as ready for review July 18, 2024 15:31
@ciampo ciampo requested a review from ajitbohra as a code owner July 18, 2024 15:31
Copy link

github-actions bot commented Jul 18, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ciampo <[email protected]>
Co-authored-by: tyxla <[email protected]>
Co-authored-by: mirka <[email protected]>
Co-authored-by: DaniGuardiola <[email protected]>
Co-authored-by: diegohaz <[email protected]>
Co-authored-by: youknowriad <[email protected]>
Co-authored-by: ntsekouras <[email protected]>
Co-authored-by: aaronrobertshaw <[email protected]>
Co-authored-by: noisysocks <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@ciampo ciampo changed the title Components: update contributing guidelines and add "Naming conventions" section Components: add "Naming conventions" section Jul 18, 2024
- [README example](#README-example)
- [Folder structure](#folder-structure)
- [Component versioning](#component-versioning)
- [Introducing new components](#introducing-new-components)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

My IDE insists on auto-formatting this file. I've put all the auto-formatting changes in one single commit, but if you think they're too distracting / they don't belong to this PR I'm happy to remove and potentially apply them in a separate PR.

Copy link
Member

Choose a reason for hiding this comment

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

👍

It's also easier to review the PR with white-spacing disabled:

Screenshot 2024-08-01 at 14 05 08

Comment on lines +98 to +104
When adding new components or new props to existing components, it's recommended to create a [private version](/packages/private-apis/README.md)) of the component until the changes are stable enough to be exposed as part of the public API.

### Learn more

- [How to preserve backward compatibility for a React Component](/docs/contributors/code/backward-compatibility.md#how-to-preserve-backward-compatibility-for-a-react-component)
- [Experimental and Unstable APIs](/docs/contributors/code/coding-guidelines.md#experimental-and-unstable-apis)
- [Deprecating styles](#deprecating-styles)
- [How to preserve backward compatibility for a React Component](/docs/contributors/code/backward-compatibility.md#how-to-preserve-backward-compatibility-for-a-react-component)
- [Experimental and Unstable APIs](/docs/contributors/code/coding-guidelines.md#legacy-experimental-apis-plugin-only-apis-and-private-apis)
- [Deprecating styles](#deprecating-styles)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated this section to reflect the new "private APIs" policy

Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

This is more or less looking good, but still has some debatable elements (the Component.Root dot notation mostly) that still needs a stronger consensus in the #63242 discussion at this time.

packages/components/CONTRIBUTING.md Show resolved Hide resolved
packages/components/CONTRIBUTING.md Outdated Show resolved Hide resolved
packages/components/CONTRIBUTING.md Outdated Show resolved Hide resolved
packages/components/CONTRIBUTING.md Outdated Show resolved Hide resolved
Copy link
Contributor

@DaniGuardiola DaniGuardiola left a comment

Choose a reason for hiding this comment

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

Looks good so far, though it seems like we're switching to an "overloaded" API?

@mirka
Copy link
Member

mirka commented Jul 30, 2024

@DaniGuardiola and I were discussing some potential TypeScript problems with overloading when forwardRef() is involved.

It's a bit finicky where you need to place your JSDocs and .displayNames, but I can confirm that this approach with Object.assign is working as expected for IntelliSense and the Storybook docgen.

@ciampo
Copy link
Contributor Author

ciampo commented Jul 31, 2024

I've updated the PR suggesting the "overloaded" naming convention and refreshing the code examples.

Could y'all take a new look?

(as I'm going to be AFK for a week, feel free to push updates and/or merge in case in my absence)

Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

This is looking great 👍

I've left some minor things mostly, I'll let @mirka and @DaniGuardiola take a look and share their feedback before we ship it.

packages/components/CONTRIBUTING.md Outdated Show resolved Hide resolved
const Context = createContext();

/** The top-level component's JSDoc. */
export const Component = Object.assign(
Copy link
Member

Choose a reason for hiding this comment

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

Could be a good opportunity to explain the purpose behind using Object.assign() here.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, and it might be useful to state what exactly we need to look for:

  • When consuming the component/subcomponent, the JSDocs must appear correctly in IntelliSense.
  • The main component JSDoc must appear in the Storybook docs page.
  • The component/subcomponent prop types must appear correctly in the Storybook props table.

Copy link
Contributor Author

@ciampo ciampo Aug 8, 2024

Choose a reason for hiding this comment

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

Added a couple of paragraphs explaining requirements and related recommended best practices: 432635b

This way the only comments in the code are related to the JSDocs

packages/components/CONTRIBUTING.md Outdated Show resolved Hide resolved
packages/components/CONTRIBUTING.md Outdated Show resolved Hide resolved
- [README example](#README-example)
- [Folder structure](#folder-structure)
- [Component versioning](#component-versioning)
- [Introducing new components](#introducing-new-components)
Copy link
Member

Choose a reason for hiding this comment

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

👍

It's also easier to review the PR with white-spacing disabled:

Screenshot 2024-08-01 at 14 05 08

Copy link
Member

@mirka mirka left a comment

Choose a reason for hiding this comment

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

Thank you for the update! I had a few notes on top of @tyxla's review, but otherwise this looks great 👍

@ciampo ciampo force-pushed the docs/components-contributing-guidelines-compound-naming branch from 737dbb6 to 432635b Compare August 8, 2024 07:34
@ciampo
Copy link
Contributor Author

ciampo commented Aug 8, 2024

All feedback should be addressed

@ciampo ciampo requested review from mirka and tyxla August 8, 2024 07:37
Copy link
Member

@tyxla tyxla left a comment

Choose a reason for hiding this comment

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

Good to go from my perspective. Thanks @ciampo 🚀

packages/components/CONTRIBUTING.md Outdated Show resolved Hide resolved
@ciampo ciampo enabled auto-merge (squash) August 8, 2024 09:31
Copy link

github-actions bot commented Aug 8, 2024

Flaky tests detected in cb6485c.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/10299502863
📝 Reported issues:

@ciampo ciampo merged commit 236250e into trunk Aug 8, 2024
60 of 61 checks passed
@ciampo ciampo deleted the docs/components-contributing-guidelines-compound-naming branch August 8, 2024 09:59
@github-actions github-actions bot added this to the Gutenberg 19.1 milestone Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Developer Documentation Documentation for developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

@wordpress/components: agree on a naming convention for compound (sub) components
5 participants