mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-26 18:15:48 +02:00
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
|
## General
|
||||||
* Indentation - 2 spaces
|
* Indentation: 2 spaces
|
||||||
* Line Length - 80 characters
|
* Line length: 80 characters
|
||||||
* [Required License in File Header](https://github.com/mozilla/pdf.js/wiki/License-Headers)
|
* Required license in header: see https://github.com/mozilla/pdf.js/blob/master/web/viewer.js#L1-L16
|
||||||
|
|
||||||
## Naming
|
## Naming
|
||||||
* Variables and functions - lowerCamelCase
|
* Variables and functions: lowerCamelCase
|
||||||
* Constructor-like functions - UpperCamelCase
|
* Constructor-like functions: UpperCamelCase
|
||||||
* Constants - ALL_UPPER_CASE_WITH_UNDERSCORES
|
* Constants: ALL_UPPER_CASE_WITH_UNDERSCORES
|
||||||
|
|
||||||
## Braces
|
## 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
|
```javascript
|
||||||
if (someVar) {
|
if (someVar) {
|
||||||
@ -19,15 +21,15 @@ if (someVar) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
## White Space
|
## White space
|
||||||
* Space after control statements (if, else, while, for, ...)
|
Keep one space after control statements (if, else, while, for, et cetera):
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
if (someVar) {
|
if (someVar) {
|
||||||
```
|
```
|
||||||
|
|
||||||
## Equalities
|
## Equalities
|
||||||
* Use only strict equalities (and inequalities), e.g.
|
Use only strict equalities (`===`) and inequalities (`!==`):
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
if (someVar === conditionA) {
|
if (someVar === conditionA) {
|
||||||
@ -38,8 +40,7 @@ if (someVar === conditionA) {
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Variables
|
## 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
|
## 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.
|
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