You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For all new codebases, both eslint and prettier must be installed and strictly adhered to. Most formatting and linting issues discussed here can be solved by simply formatting your files automatically using your IDE.
1.1.1. Formatting
Always use double quotes for strings "hi!"
Always terminate all statements with a semicolon
Always use 2 spaces per indentation/tab
Always prefer braces
// Always thisif(ok){console.log("hello");}// Over thisif(ok)console.log("hello");
1.1.2. Names
Types: use PascalCase
Classes: use PascalCase
Enums: use PascalCase for names, but SCREAMING_SNAKE_CASE for values
Always prefer const over let if the variable is not mutable (an array can be mutable but if the reference to said array is not mutable, const should be used)
Never use var — NEVER
Avoid global variables unless strictly necessary
1.1.6. Imports
Import statements should be separated into two different sections, library imports and local imports, with exactly one new line between
// library imports including our own library (if any) always at the topimport{ ... }from"axios";import{ ... }from"lodash";import{ ... }from"ourLib";// local imports always after library importsimport{ ... }from"../logic";import{ ... }from"src/constants";
Unused imports should be removed or at the very least commented out (if taking something out temporarily)
1.1.7. Paradigm
Prefer OOP for backend and internal services especially if they are non-trivial pieces of software (ie. more than 1k loc)
Titles should give a brief description of the main task (you may, but not necessarily, follow the same conventions as commit messages)
ie. for a bug fix: fix input sometimes not working
Provide suitable descriptions of all changes if need be
Make a PR as soon as you make your first commit and label the PR as status: doing
This allows any reviewer to immediately understand where you are at and help if need be
Push to the PR as soon as you make new commits so as to ensure that the remote branch is as updated as possible to prevent losing your work
PRs should have at least one approval by the codeowner before being merged to main
Always choose the “squash and merge” option when merging a PR (❗: TO CONFIRM WITH PROFS)
For documentation purposes, DON'T delete any branches after merging
2.4. Reviews
Requesting for reviews:
Ensure all changed files have been properly formatted (Refer to 1.1.1. Formatting)
Ensure all changed files are strictly necessary and for your PR only and revert the unnecessary changes
ie. if working on an isolated feature, try not to have formatting changes to files that you didn’t even touch in the first place → a new refactor PR for such files should be created)
Merge the main branch into the PR first (ie. git pull origin main)
Label the PR as status: done
Request a review from the codeowner or other team members with experience
(Optional) Ping the reviewer if need be
2.5. Configurations
2.5.1. Logs
Sorry Blake 😭
To get a better git log experience, we can alias git lg to the following (note that we use lg and not log in case you still want the inferior experience):
For internal use only
Table of Content
Sadly the links aren't working
1. Coding Convention
1.1. TypeScript
For all new codebases, both
eslint
andprettier
must be installed and strictly adhered to. Most formatting and linting issues discussed here can be solved by simply formatting your files automatically using your IDE.1.1.1. Formatting
Always use double quotes for strings
"hi!"
Always terminate all statements with a semicolon
Always use 2 spaces per indentation/tab
Always prefer braces
1.1.2. Names
Types: use
PascalCase
Classes: use
PascalCase
Enums: use
PascalCase
for names, butSCREAMING_SNAKE_CASE
for valuesVariables and functions: use
camelCase
Object property names: use
camelCase
Prefer whole words when possible
1.1.3. Types
Strongly prefer types over interfaces (only use interfaces when describing an interface of an OOP class)
Prefer combinations of unions and
Pick
/Omit
over copy pasting a previously defined typePrefer type annotations (
: Foo
) over type assertions (as Foo
) whenever possible to allow easier detection of bugs when types change1.1.4. Functions
Always use arrow functions over anonymous function expressions
Prefer pure functions unless performance is necessary
1.1.5. Variables
const
overlet
if the variable is not mutable (an array can be mutable but if the reference to said array is not mutable,const
should be used)var
— NEVER1.1.6. Imports
Import statements should be separated into two different sections, library imports and local imports, with exactly one new line between
Unused imports should be removed or at the very least commented out (if taking something out temporarily)
1.1.7. Paradigm
map
/reduce
/filter
) over a generalfor
loop (for better readability and maintainability)1.1.8. Comments
2. Git & GitHub
2.1. Branches and Workflow
All branches should follow this convention:
2.2. Commits
feat: add subscribe buttons
2.3. Pull Requests
fix input sometimes not working
status: doing
main
2.4. Reviews
Requesting for reviews:
main
branch into the PR first (ie.git pull origin main
)status: done
2.5. Configurations
2.5.1. Logs
Sorry Blake 😭
To get a better
git log
experience, we can aliasgit lg
to the following (note that we uselg
and notlog
in case you still want the inferior experience):git config --global alias.lg "log --pretty=format:'%C(magenta)%h%Creset -%C(red)%d%Creset %s %C(green)(%cr) [%an]' --abbrev-commit -30"
2.5.2 Tree
Similarly you can view the tree and history
git config --global alias.tree "log --graph --abbrev-commit --decorate --format=format:'%C(magenta)%h%C(reset) - %C(green)%aD%C(reset) %C(dim green)(%ar)%C(reset)%C(brightred)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all"
3. IDE
3.1. Visual Studio Code (VSC)
3.1.1. Extensions
Add more if necessary
TODO
The text was updated successfully, but these errors were encountered: