mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
(Coding Convention) Fix indents to use 4 spaces (per the same guideline).
This commit is contained in:
@ -72,7 +72,7 @@ Your opening braces go on the same line as the statement.
|
|||||||
|
|
||||||
~~~ {.javascript}
|
~~~ {.javascript}
|
||||||
if (true) {
|
if (true) {
|
||||||
console.log('winning');
|
console.log('winning');
|
||||||
}
|
}
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ if (true) {
|
|||||||
~~~ {.javascript}
|
~~~ {.javascript}
|
||||||
if (true)
|
if (true)
|
||||||
{
|
{
|
||||||
console.log('losing');
|
console.log('losing');
|
||||||
}
|
}
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ Use the [strict comaprison operators][comparisonoperators]. The triple equality
|
|||||||
~~~ {.javascript}
|
~~~ {.javascript}
|
||||||
var a = 0;
|
var a = 0;
|
||||||
if (a === '') {
|
if (a === '') {
|
||||||
console.log('winning');
|
console.log('winning');
|
||||||
}
|
}
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
@ -277,7 +277,7 @@ if (a === '') {
|
|||||||
~~~ {.javascript}
|
~~~ {.javascript}
|
||||||
var a = 0;
|
var a = 0;
|
||||||
if (a == '') {
|
if (a == '') {
|
||||||
console.log('losing');
|
console.log('losing');
|
||||||
}
|
}
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
@ -309,7 +309,7 @@ Always use curly braces even in the cases of one line conditional operations.
|
|||||||
|
|
||||||
~~~ {.javascript}
|
~~~ {.javascript}
|
||||||
if (a) {
|
if (a) {
|
||||||
return 'winning';
|
return 'winning';
|
||||||
}
|
}
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
@ -319,7 +319,7 @@ if (a) {
|
|||||||
~~~ {.javascript}
|
~~~ {.javascript}
|
||||||
|
|
||||||
if (a)
|
if (a)
|
||||||
return 'winning';
|
return 'winning';
|
||||||
|
|
||||||
if (a) return 'winning';
|
if (a) return 'winning';
|
||||||
~~~
|
~~~
|
||||||
@ -332,11 +332,11 @@ if (a) return 'winning';
|
|||||||
~~~ {.javascript}
|
~~~ {.javascript}
|
||||||
|
|
||||||
if(condition) {
|
if(condition) {
|
||||||
console.log('winning');
|
console.log('winning');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!condition) {
|
if (!condition) {
|
||||||
console.log('winning');
|
console.log('winning');
|
||||||
}
|
}
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
@ -346,15 +346,15 @@ if (!condition) {
|
|||||||
~~~ {.javascript}
|
~~~ {.javascript}
|
||||||
|
|
||||||
if(condition === true) {
|
if(condition === true) {
|
||||||
console.log('losing');
|
console.log('losing');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(condition !== true) {
|
if(condition !== true) {
|
||||||
console.log('losing');
|
console.log('losing');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(condition !== false) {
|
if(condition !== false) {
|
||||||
console.log('losing');
|
console.log('losing');
|
||||||
}
|
}
|
||||||
|
|
||||||
~~~
|
~~~
|
||||||
@ -372,7 +372,7 @@ Do not use the **Yoda Conditions** when writing boolean expressions:
|
|||||||
~~~ {.javascript}
|
~~~ {.javascript}
|
||||||
var num;
|
var num;
|
||||||
if(num >= 0) {
|
if(num >= 0) {
|
||||||
console.log('winning');
|
console.log('winning');
|
||||||
}
|
}
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
@ -381,14 +381,14 @@ if(num >= 0) {
|
|||||||
~~~ {.javascript}
|
~~~ {.javascript}
|
||||||
var num;
|
var num;
|
||||||
if(0 <= num) {
|
if(0 <= num) {
|
||||||
console.log('losing');
|
console.log('losing');
|
||||||
}
|
}
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
**NOTE** It is OK to use constants on the left when comparing for a range.
|
**NOTE** It is OK to use constants on the left when comparing for a range.
|
||||||
~~~ {.javascript}
|
~~~ {.javascript}
|
||||||
if(0 <= num && num <= 100) {
|
if(0 <= num && num <= 100) {
|
||||||
console.log('winning');
|
console.log('winning');
|
||||||
}
|
}
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
@ -408,22 +408,22 @@ as possible. In certain routines, once you know the answer, you want to return i
|
|||||||
|
|
||||||
~~~ {.javascript}
|
~~~ {.javascript}
|
||||||
function getSomething(val) {
|
function getSomething(val) {
|
||||||
if (val < 0) {
|
if (val < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val > 100) {
|
if (val > 100) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var res1 = doOne();
|
var res1 = doOne();
|
||||||
var res2 = doTwo();
|
var res2 = doTwo();
|
||||||
var options = {
|
var options = {
|
||||||
a: 1,
|
a: 1,
|
||||||
b: 2
|
b: 2
|
||||||
};
|
};
|
||||||
var result = doThree(res1, res2, options);
|
var result = doThree(res1, res2, options);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user