-
Use camelCase for variables, functions, methods, and instances.
-
Use PascalCase for classes and enums.
-
Use PascalCase for typescript types and interfaces.
-
Use PascalCase for zod specifications.
-
Use PascalCase for React components.
-
use camelCase for .ts filenames.
-
use PascalCase for .tsx filenames.
-
Use
<ComponentName>Propsfor React component props. -
Use kebab-case for project root folders.
-
code should be formatted correctly.
-
code should be type-checked.
-
code should pass all unit and integration tests.
-
code should pass all linting checks.
-
Make sure the absence of value is represented using the Option type.
-
Application-level code should throw exceptions, with exception handlers placed at strategic locations.
-
Make sure all recoverable errors are properly handled. The use of the Result type is encouraged and try/catch is discouraged.
-
Make sure all data from the external world, like user input, network requests, etc are fully validated. All validation must happen at boundaries.
-
Make sure invariants are in place. For eg: all arguments are validated. Make sure these errors are not usually handled as they are not recoverable.
-
Make sure all complex code has accompanying tests.
-
Make sure all user-facing code has integration tests.
-
Make sure all developer-facing code has unit tests.
-
Make sure the code is simple and there's no unnecessary complexity.
-
Make sure data is either immutable or not shared.
-
All global data should be immutable.
-
Mutability is handled through pointers.
-
Make sure the code is as strongly typed as possible. There are no uses of the 'top' type like 'any' or 'object'.
-
Make sure computations are pure functions. There are no side effects like mutating the global state or making network requests.
-
Make sure effect functions have no computation/logic.
-
Make sure reusable code is extracted into functions and modules.
-
Make sure reusable code is well-typed, well tested and well-documented. These functions usually should not include invariants. Use the result type to raise errors.
-
Create reusable best practices patterns in code. It should be simpler to follow best practices than not to follow them.
-
Make sure existing internal reusable libraries are used instead of duplicating code.
- Use a single ownership model or immutable data structures.
- Make sure there are no blocking functions.
- Make sure there is no shared mutable state.
- Make sure there are no locks. Unless it's very low-level code and it's local.
- Use simple Tasks where possible for asynchronous tasks(io or compute). Return Futures/Tasks/Promises.
- DO NOT create threads. Use Tasks(or thread pools) instead.
- Prefer channels or async enumerable if available.
- Make sure asynchronous code and parallel code are separated.
- Make sure there are no obvious performance concerns.
- Make sure algorithms with the right time complexity are used.
- Make sure immutability doesn't cause serious performance concerns.
Make sure code quality metrics are no worse. This includes things like
- code coverage,
- cyclomatic complexity
- code duplication
-
Are comments essential? Can the code be simplified instead?
-
Make sure third-party libraries included are essential. Discourage the use of libraries that are not essential.
-
If any configuration is needed, make sure it's well documented in README.
-
Avoid CSS class names and selectors in integration tests.
-
Test user-visible behavior. Use locators like
getByRole,getByText,getByLabeletc. -
Use
getByTestIdwhen nothing else works. -
Test complete user flows. Do not test individual components or pages.