-
Notifications
You must be signed in to change notification settings - Fork 0
Style Guide
This section goes over how to style GitHub related items such as:
- branches
- commit messages
- issues
Standardizing these guidelines will help us achieve maximum productivity when managing tasks on the site.
Branch names should be named after the issue you want to solve. They should be named using kebab case.
ex. An issue named "Setup Electron" would have a corresponding branch name of setup-electron
.
Reference this blog post
Rules for a great git commit message
- Separate subject from body with a blank line
- Limit the subject line to 50 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line
- Wrap the body at 72 characters
- Use the body to explain what and why vs. how
This section goes over how one should style their code. It is very important to introduce an agreed upon standard for your team and to use good practices. To work on a team, members need to be able to collaborate and read each other's code. If a team cannot read another's code because of the styling then that team will suffer in productivity.
This section goes over:
- file structure
- naming conventions
- code organization
src/
index.ts
types.d.ts
controllers/ (business logic)
index.ts
userController.ts
…
models/ (database logic, if necessary)
index.ts
user.ts
…
routes/ (connects controller with routes)
index.ts
userRoutes.ts
Todo
Avoid using default exports as much as possible. Use normal ES6 exports.
Use index files to simplify imports.
Example
// errors/index.ts
import { FieldError } from './FieldError';
import { FormError } from './FormError';
import { Error } from './Error';
export { FieldError, FormError, Error };
// account.ts
import { Account } from '../entities';
import { FieldError, FormError } from '../errors';
interface AccountResponse {
data?: Account;
error?: FieldError | FormError;
}
Using index files allows for a centralized module of a common theme to export from. You can actually import a function from a directory without specifying which file it is - this is the power of index files.
Component names should be pascal case.
Hooks should be in the “hooks” directory. They should be named with the prefix “use”. For example:
useAuth
useContext
useState