Updates to make this easier to read and add a small introduction
parent
bbbd064b5d
commit
4d0633923d
@ -1,15 +1,17 @@
|
||||
This page outlines the style conventions that PDF.js follows to maintain a consistent codebase. We ask each contributor that creates a pull request to adhere to these conventions. Some of these conventions will also be checked automatically by a linting tool after each push to a branch of a pull request.
|
||||
|
||||
## General
|
||||
* Indentation - 2 spaces
|
||||
* Line Length - 80 characters
|
||||
* [Required License in File Header](https://github.com/mozilla/pdf.js/wiki/License-Headers)
|
||||
* Indentation: 2 spaces
|
||||
* Line length: 80 characters
|
||||
* Required license in header: see https://github.com/mozilla/pdf.js/blob/master/web/viewer.js#L1-L16
|
||||
|
||||
## Naming
|
||||
* Variables and functions - lowerCamelCase
|
||||
* Constructor-like functions - UpperCamelCase
|
||||
* Constants - ALL_UPPER_CASE_WITH_UNDERSCORES
|
||||
* Variables and functions: lowerCamelCase
|
||||
* Constructor-like functions: UpperCamelCase
|
||||
* Constants: ALL_UPPER_CASE_WITH_UNDERSCORES
|
||||
|
||||
## Braces
|
||||
* Always use braces and put them on same line, even for single line control statements.
|
||||
Always use braces and put them on same line, even for single line control statements:
|
||||
|
||||
```javascript
|
||||
if (someVar) {
|
||||
@ -19,15 +21,15 @@ if (someVar) {
|
||||
}
|
||||
```
|
||||
|
||||
## White Space
|
||||
* Space after control statements (if, else, while, for, ...)
|
||||
## White space
|
||||
Keep one space after control statements (if, else, while, for, et cetera):
|
||||
|
||||
```javascript
|
||||
if (someVar) {
|
||||
```
|
||||
|
||||
## Equalities
|
||||
* Use only strict equalities (and inequalities), e.g.
|
||||
Use only strict equalities (`===`) and inequalities (`!==`):
|
||||
|
||||
```javascript
|
||||
if (someVar === conditionA) {
|
||||
@ -38,8 +40,7 @@ if (someVar === conditionA) {
|
||||
```
|
||||
|
||||
## Variables
|
||||
|
||||
Variables must be defined only once within a function scope. Preferably at the top of the function.
|
||||
Variables must be defined only once within a function scope, preferably at the top of the function.
|
||||
|
||||
## Classes
|
||||
The standard way of creating classes in PDF.js is the following. Please note that by class we mean an object that is class-like. Also, note the naming of all anonymous functions.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user