Style Guide
This style guide outlines the conventions and best practices to follow when contributing code to Composable UI.
General
- Write code in English only.
- Use two spaces for indentation.
- Use Unix line endings (\n) for text files and Windows line endings (\r\n) for files that need to be compatible with Windows.
- Use descriptive variable names and avoid abbreviations when possible.
- Avoid commenting out code. Instead, remove it or use version control to keep track of changes.
- Ensure there is no degradation of performance or accessibility by comparing LightHouse v10 score between your branch and the main branch
TypeScript
- Use pascal case for type names.
- Use camel case for variable and function names.
- Use interfacefor types, unlesstypeis required.
- Use constfor properties that must not be modified.
- Use unknowninstead ofanywhen the type is not known.
- Avoid using type assertions, unless required.
Next.js
- Use importandexportstatements instead of CommonJS-stylerequire.
- Use getStaticPropsandgetServerSidePropsfor data fetching instead of making API calls in the client, when possible.
- Use useRouterto access router information or navigational needs.
- Use NextLinkfrom the Next.jsnext/linkmodule for client-side navigation by passing it using theasprop to the ChakraUILink,Button, etc component. More information
- Use next/imagemodule for optimizing images.
CSS
- Use the Chakra UI theme to maintain your theme CSS values.
- Group Chakra UI theme tokens into different files based on their type, such as typography, borders, or colors.
- Use Chakra UI theme tokens to apply styles, instead of hardcoding CSS values directly in style props.
Git
- Use present tense for commit messages.
- Use imperative mood for commit messages.
- Keep each commit small and focused on a single change.
- Use meaningful commit messages that describe the change.
- Make all changes in a branch and submit it as a pull request. You must prefix branches with one of the following:- fix/for bug fixes
- feat/for features
- docs/for documentation changes
 
- Rebase your feature branch onto the latest main branch before submitting a pull request.
- Use pull requests for code reviews.