Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the Coding Convention into contribution guide #222

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 146 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ All types of contributions are encouraged and valued. See the [Table of Contents
<!-- omit in toc -->
## Table of Contents

- [I Have a Question](#i-have-a-question)
- [I Want To Contribute](#i-want-to-contribute)
- [Reporting Bugs](#reporting-bugs)
- [Suggesting Enhancements](#suggesting-enhancements)
- [Your First Code Contribution](#your-first-code-contribution)
- [Improving The Documentation](#improving-the-documentation)
- [Styleguides](#styleguides)
- [Commit Messages](#commit-messages)
- [Join The Project Team](#join-the-project-team)
- [I Have a Question](#i-have-a-question)
- [I Want To Contribute](#i-want-to-contribute)
- [Reporting Bugs](#reporting-bugs)
- [Suggesting Enhancements](#suggesting-enhancements)
- [Your First Code Contribution](#your-first-code-contribution)
- [Improving The Documentation](#improving-the-documentation)
- [Coding Conventions](#Coding-Conventions)
- [Commit Messages](#commit-messages)
- [Join The Project Team](#join-the-project-team)



Expand Down Expand Up @@ -138,8 +138,144 @@ include Setup of env, IDE and typical getting started instructions?
Updating, improving and correcting the documentation
-->
## Coding Conventions

This is all about standardization :blush:

### Folders and Files Naming

All of the folders and files should use `kebab-case`.

> The `kebab-case` usage (in package, folder and file names) will make us easier when it's time to extract them into itsown package in the future.
>
> [Here is the related discussion](https://github.com/ageddesi/Mocked-API/issues/121#issuecomment-1273622574).
### File Extensions

This is all about the files and the clear definition of their usage :

- APIs
- `*.routes.ts`
- This file located right inside the feature's folder
- Data
- `*.ts`
- This file located under `data` folder of the feature's folder (e.g. `data/*.ts`)
- This `data` folder is used to store the static data used in APIs (not your mock data)
- Interfaces/Types
- `*.types.ts`
- This file located under `models` folder of the feature's folder (e.g. `models/*.types.ts`)
- Utilities
- `*.ts`
- This file located under `utils` folder of the feature's folder (e.g. `utils/*.ts`)
- Tests
- `*.test.ts`
- This file located under `tests` folder of the feature's folder (e.g. `tests/*.test.ts`)
- This `tests` folder should follow the feature's folder structure, e.g. :
- `tests/*.test.ts` -> test file for the APIs
- `tests/utils/*.test.ts` -> test file for the APIs

### File Structures

The file structures in this repository should look like this :

Mocked-API
│ README.md
│ package.json
│ ...
└───middleware
│ │
│ └───rate-limiter
│ │ rate-limiter.ts
│ │
│ └───models
│ │
│ └───rate-limiter-response.ts
└───modules
│ │
│ └───feature-sample-1
│ │ │ feature-sample-1.routes.ts
│ │ │
│ │ └───data
│ │ │ │ data-1.ts
│ │ │ │ data-2.ts
│ │ │ │ ...
│ │ │
│ │ └───models
│ │ │ │ address.types.ts
│ │ │ │ country.types.ts
│ │ │ │ ...
│ │ │
│ │ └───utils
│ │ │ │ util-1.ts
│ │ │ │ util-2.ts
│ │ │ │ ...
│ │ │
│ │ └───tests /* Should have the same structure with `feature-sample-1` folder */
│ │ │ feature-sample-1.test.ts /* Test for `feature-sample-1.routes.ts` */
│ │ │
│ │ └───utils
│ │ │ util-1.test.ts
│ │ │ util-2.test.ts
│ │ │ ...
│ │
│ └───feature-sample-2
│ │ │ *.routes.ts
│ │ │
│ │ └───data
│ │ │ │
│ │ │ └─── *.ts
│ │ │
│ │ └───models
│ │ │ │
│ │ │ └─── *.types.ts
│ │ │
│ │ └───utils
│ │ │ │
│ │ │ └─── *.ts
│ │ │
│ │ └───tests /* Should have the same structure with `feature-sample-2` folder */
│ │ │ *.test.ts
│ │ │
│ │ └───utils
│ │ │
│ │ └─── *.ts
│ │
│ └───feature-sample-3
│ │ *.routes.ts
│ │
│ └───data
│ │ │
│ │ └─── *.ts
│ │
│ └───models
│ │ │
│ │ └─── *.types.ts
│ │
│ └───utils
│ │ │
│ │ └─── *.ts
│ │
│ └───tests /* Should have the same structure with `feature-sample-3` folder */
│ │ *.test.ts
│ │
│ └───utils
│ │
│ └─── *.ts
└───utils
│ │ file-utils-1.ts
│ │ file-utils-2.ts
│ │ ...
│ │
│ └───tests
│ │ file-utils-1.test.ts
│ │ file-utils-2.test.ts
│ │ ...
└───another-folders

## Styleguides
### Commit Messages
<!-- TODO
Expand Down