Skip to content

Commit b703c42

Browse files
authored
Merge pull request #2504 from ZeroX-DG/pr-template
Added PR Template and update docs
2 parents a26d4fb + 4550d88 commit b703c42

File tree

3 files changed

+133
-3
lines changed

3 files changed

+133
-3
lines changed

PULL_REQUEST_TEMPLATE.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!--
2+
Before submitting this PR, please make sure that:
3+
- You have read and understand the contributing.md
4+
- You have checked docs/code_style.md for information on code style
5+
-->
6+
## Description
7+
<!--
8+
Tell us what your PR does.
9+
Please attach a screenshot/ video/gif image describing your PR if possible.
10+
-->
11+
12+
## Issue fixed
13+
<!--
14+
Please list out all issue fixed with this PR here.
15+
-->
16+
17+
<!--
18+
Please make sure you fill in these checkboxes,
19+
your PR will be reviewed faster if we know exactly what it does.
20+
21+
Change :white_circle: to :radio_button: in all the options that apply
22+
-->
23+
## Type of changes
24+
25+
- :white_circle: Bug fix (Change that fixed an issue)
26+
- :white_circle: Breaking change (Change that can cause existing functionality to change)
27+
- :white_circle: Improvement (Change that improves the code. Maybe performance or development improvement)
28+
- :white_circle: Feature (Change that adds new functionality)
29+
- :white_circle: Documentation change (Change that modifies documentation. Maybe typo fixes)
30+
31+
## Checklist:
32+
33+
- :white_circle: My code follows [the project code style](docs/code_style.md)
34+
- :white_circle: I have written test for my code and it has been tested
35+
- :white_circle: All existing tests have been passed
36+
- :white_circle: I have attached a screenshot/video to visualize my change if possible

contributing.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
# Contributing to Boostnote (English)
22

33
### When you open an issue or a bug report
4-
There is no issue template, but there is a request.
5-
6-
**Please paste screenshots of Boostnote with the developer tool open**
4+
There is an issue template for you to follow. Please provide as much information as you can according to the template.
75

86
Thank you in advance for your help.
97

8+
### When you open a pull request
9+
There is a pull request template for your to follow. Please fill in the template before submitting your code. Your pull request will be reviewed faster if we know exactly what it does.
10+
11+
Make sure that you have:
12+
- Checked [`code_style.md`](docs/code_style.md) for information on code style
13+
- Write tests for your code and run test with the following command
14+
```
15+
npm run test
16+
```
17+
- Lint your code using the following command
18+
```
19+
npm run lint
20+
```
21+
1022
### Concerning Copyright
1123

1224
By making a pull request you agree to transfer ownership of your code to BoostIO.

docs/code_style.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Boostnote Code Style
2+
When submitting your PR, please make sure that your code is well tested and follow the code style of Boostnote.
3+
4+
The code style of Boostnote is listed in [`.eslintrc`](.eslintrc). We also have additional code styles that is not mentioned in that file.
5+
6+
## Additional code styles
7+
### Use ES6 Object Destructing
8+
9+
Please use Object Destructing whenever it's possible.
10+
11+
**Example**: Importing from library
12+
13+
```js
14+
15+
// BAD
16+
import Code from 'library'
17+
const subCode = Code.subCode
18+
subCode()
19+
20+
// GOOD
21+
import { subCode } from 'library'
22+
subCode()
23+
```
24+
25+
**Example**: Extract data from react component state
26+
27+
```
28+
// BAD
29+
<h1>{this.state.name}</h1>
30+
31+
// GOOD
32+
const { name } = this.state
33+
<h1>{name}</h1>
34+
```
35+
36+
### Use meaningful name
37+
This is actually not a "code style" but rather a requirement in every projects. Please name your variables carefully.
38+
39+
**Example**: Naming callback function for event
40+
41+
```js
42+
// BAD
43+
<h1 onclick={onClick}>Name</h1>
44+
45+
// GOOD
46+
<h1 onclick={onNameClick}>Name</h1>
47+
```
48+
49+
### Don't write long conditional statement
50+
When writing a conditional statement, if it's too long, cut it into small meaningful variables.
51+
52+
```js
53+
// BAD
54+
if (note.type == 'markdown' && note.index == 2 && note.content.indexOf('string') != -1)
55+
56+
// GOOD
57+
const isSecondMarkdownNote = note.type == 'markdown' && note.index == 2
58+
const isNoteHasString = note.content.indexOf('string') != -1
59+
if (isSecondMarkdownNote && isNoteHasString)
60+
```
61+
62+
### Use class property instead of class methods
63+
When writing React components, try to use class property instead of class methods. The reason for this is explained perfectly here:
64+
https://codeburst.io/use-class-properties-to-clean-up-your-classes-and-react-components-93185879f688
65+
66+
**Example**:
67+
68+
```js
69+
// BAD
70+
class MyComponent extends React.Component {
71+
myMethod () {
72+
// code goes here...
73+
}
74+
}
75+
76+
// GOOD
77+
class MyComponent extends React.Component {
78+
myMethod = () => {
79+
// code goes here...
80+
}
81+
}
82+
```

0 commit comments

Comments
 (0)