Skip to content

Commit

Permalink
Merge pull request #222 from sherlyfebrianti96/update-contribution-gu…
Browse files Browse the repository at this point in the history
…ide-for-standardization

Adding the Coding Convention into contribution guide
  • Loading branch information
ageddesi committed Oct 16, 2022
2 parents e1caada + 77ec38f commit b6dfe9a
Showing 1 changed file with 146 additions and 10 deletions.
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

0 comments on commit b6dfe9a

Please sign in to comment.