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

Add Guidelines for components #70

Merged
merged 9 commits into from
Jun 3, 2022
Merged

Add Guidelines for components #70

merged 9 commits into from
Jun 3, 2022

Conversation

akshaaatt
Copy link
Member

A proper guideline for adding components has been added.

guidelines/component-usage.md Outdated Show resolved Hide resolved
guidelines/component-usage.md Outdated Show resolved Hide resolved
guidelines/component-usage.md Show resolved Hide resolved
guidelines/component-usage.md Outdated Show resolved Hide resolved
guidelines/component-usage.md Show resolved Hide resolved
akshaaatt added 2 commits June 2, 2022 22:03
- This will be automatically handled by eslint and prettier now.
Copy link
Member

@reosarevok reosarevok left a comment

Choose a reason for hiding this comment

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

Seems sensible enough, I guess :) Left a few small suggestions

1. #### Naming Style **[⬆](#table-of-content)**

* Always use the `.js` extension.
* Use UpperCamelCase as a components name.
Copy link
Member

Choose a reason for hiding this comment

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

component's I guess? or "for component names", to match "for prop names" below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right

* Use UpperCamelCase as a components name.
* Use lowerCamelCase for prop names.
* Component name should be the same as the file name. This means that the use of `index` files is forbidden for components. It's easier to find components by filename rather than by folder name.
* Component filenames should be in UpperCamelCase. It's allowed to use dots (`.`) to explicitly mention type of component: `Dashboard.component.js`.
Copy link
Member

Choose a reason for hiding this comment

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

What's the point of the dot notation? Also, you already say "Use UpperCamelCase as a components name" and "[The] Component name should be the same as the file name", so isn't this redundant?

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense. Removed

* Always use the `.js` extension.
* Use UpperCamelCase as a components name.
* Use lowerCamelCase for prop names.
* Component name should be the same as the file name. This means that the use of `index` files is forbidden for components. It's easier to find components by filename rather than by folder name.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe "The component name"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Right

* Component name should be the same as the file name. This means that the use of `index` files is forbidden for components. It's easier to find components by filename rather than by folder name.
* Component filenames should be in UpperCamelCase. It's allowed to use dots (`.`) to explicitly mention type of component: `Dashboard.component.js`.
* Props and state interface definitions shouldn't be prefixed with `I`. Use UpperCamelCase instead.
* Exported props or state types should have a descriptive name and a `Props` or `State` suffix: `ProgressBarProps`, `EntityDialogState`. Non-exported types are recommended to be named `Props` and `State` respectively.
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add "If more than one non-exported set of props is needed, give all but the main one a name matching their component"? At least in MB we have several cases where there's a main Props and then something like SmallComponentProps for a SmallComponent defined and used only on that same file.

@akshaaatt akshaaatt merged commit b83e226 into master Jun 3, 2022
@akshaaatt akshaaatt deleted the components branch June 3, 2022 14:50
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.

3 participants