To get a general Rule of thumb for this project, we will need to declare a set of rules we go by. Please reference this guide to get a consistent coding style going.
React components
- Create a folder with the Name of the component
- In this folder lives a index.js with the components code
- These live in the folder
/components
- React components end with
.jsx
, not.js
. This is better for DX.
Styled Components
- Create a file with the prefix
Styled
. - Leave out the suffix
.styled.
- These live in the folder
/design-system
in root. - Don't create folders for styled components.
Pages
- Reference the "Naming Conventions" Part
- What would make the most sense for the user to see? URLs are seen and shared by users!
- For every page (not
home
) we create a folder with an index.js in it
function NAME() {
// Your code
}
export default NAME;
- Use descriptive Names: Choose names that accurately describe the purpose or functionality of the component.
- Use PascalCase
- Avoid confusion: Make sure everyone understands what your component is doing.
- Prefix generic components: If you are using a component throughout the app, prefix it with App e.g. AppButton, AppList (but not for global components like Headers and Footers)
- No DOM Element Names: Avoid using names that include for example
div
,span
,input
- Functionality over Implementation: Base the name of the component based on what it does, not how its implemented. If its a Dropdown Menu, name it DropdownMenu instead of DropdownHandler
- Use Consistency
- Keep it simple, stupid.
Since our App is getting bigger and bigger it is hard to follow which styled Component does what. Since then we will put all our Styles into the folder /design-system
.
- Don't create folders for styled components. Assets belong to
/assets
in root. - Try to create a generic styling, rather than a very specific one, so we can reuse styles
- They are no Styles in the
/components
folder. These belong to/design-system
. The/components
folder belongs exclusively to React Components. - For our naming convention reference the "Naming Conventions" part.
- Styled Components files always start with
Styled
and dont end with.styled.
- No styling is living within React Components! This ensures clean code and seperation of concerns.
- Everyone needs to understand at a first glance, what kind of component or styled-component you created.
- Direct Commits in Main are a NO-GO! (Unless you are working on README.md)
- Always use imperative and start with a verb and first letter uppercase.
git commit -m "Add foobar"
- Main stays untouched. Branches are merged into main, not the other way around.
- Commits are made if you have a final decision about you code in that moment.
- Create commits by features and create one for every feature you code.
- Name your branches like this:
feat/US$
. If you split from these branches you name it like this:feat/US$-exampleFeature
- Create more branches, rather than less. Create a branch for every User Story you are implementing. If the user story is very big, split into multiple branches.
- One finished user story can be seen in the final branch. Don't forget to merge the features into this one final branch.
- When creating Pull Requests, start with
**What's changed:**
and then list the features the Pull Request is adding/removing/changing.
- Clean code is more important than pushing features fast/dirty.
- No repeating code! If it takes to refactor a little bit, we refactor a little bit.
- Try to keep a file's code as small as possible and try to split your code to multiple files if possible/needed
- Be always nice and respectful!
- If you're feeling overwhelmed/stressed/burnedout/irritated, go take a break.