A set of best practices for JavaScript projects

Vahid Panjganj
Aug 9, 2017 · 16 min read
Lego street art by Jan Vormann

Project Guidelines:

1. Git

1.1 Some Git rules

1.2 Git workflow

2. Documentation

3. Environments

3.1 Consistent dev environments:

3.2 Consistent dependencies:

4. Dependencies

5. Testing

6. Structure and Naming

// Bad
.
├── controllers
| ├── product.js
| └── user.js
├── models
| ├── product.js
| └── user.js
// Good
.
├── product
| ├── index.js
| ├── product.js
| └── product.test.js
├── user
| ├── index.js
| ├── user.js
| └── user.test.js

7. Code style

8. Logging

9. API

/students/245743
/airports/kjfk
GET /blogs/:blogId/posts/:postId/summary
/translate?text=Hallo
http://api.domain.com/v1/schools/3/students
{
"code": 1234,
"message" : "Something bad happened",
"description" : "More details"
}
GET /student?fields=id,name,age,class


Elsewhen

Thoughts from the team at Elsewhen

Vahid Panjganj

Written by

Front-end Engineer @elsewhen (http://www.elsewhen.co)

Elsewhen

Elsewhen

Thoughts from the team at Elsewhen