Rules and Conventions
In order to enforce a consistent code style and avoid common issues in the codebase, we have a set of rules and conventions that we follow and enforce through the starter.
This starter uses TypeScript to provide type safety and avoid common bugs in the codebase. The project configuration is based on Expo config with some updates to support absolute imports.
If you are not familiar with Typescript, you can check this article to learn more about it : Typescript for React Developers
You can find more information about it here.
We follow kabab-case for naming files and folders as we think it’s the most readable and consistent way to name files and folders in large projects and it’s the most common way to name files and folders in the react native community.
Example of kabab-case naming:
For naming variables, functions, classes, interfaces, and enums, we follow camelCase as it’s the most common way to name variables in the React community. It is enforced by the linter, as you cannot create a function component without using camelCase.
Here is the complete ESLint configuration file:
Git Hooks with Husky
The starter comes with a set of git hooks that help us to enforce rules and conventions. Those hooks are configured using Husky. and here is the complete list of the hooks:
As the name suggest, this hook will run before each commit and it will make sure you are not committing directly on the main branch and it will run the linter and typescript checking on the staged files.
As the name suggest, this hook will run after each merge and it will check if there is any changed in pnpm-lock.yaml and if there is any, it will run
pnpm install to make sure the dependencies are up to date.
This hook will check if the commit message is following the conventional commit format. If it’s not, the commit will be aborted and will show you what going wrong with your commit message.
We are using commitlint to check if the commit message is following the conventional commit format.
In general, your commit message should follow this format:
Real world examples can look like this:
type should be one of the following: build, chore, ci ,docs,feat,fix, perf, refactor, revert, style or test.