You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 366b425
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: CodingConvention.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -205,7 +205,7 @@ let b = {"good": "code"
205
205
206
206
## Equality operator
207
207
208
-
Use the [strict comparison operators][comparisonoperators]. The triple equality operator helps to maintain data type integrity throughout code.
208
+
Use the [strict comparison operators][comparisonoperators]. The triple equality operator helps to maintain data type integrity throughout the code.
209
209
210
210
*Right:*
211
211
@@ -341,8 +341,8 @@ the last row of a big room can comfortably read. So don't count on them having
341
341
perfect vision and limit yourself to 1/2 of your screen height per function (no screen rotation :).
342
342
343
343
## Return statements
344
-
There are few important considerations here:
345
-
+ To avoid deep nesting of if-statements, always return a functions value as early
344
+
There are a few important considerations here:
345
+
+ To avoid deep nesting of if-statements, always return a function's value as early
346
346
as possible. In certain routines, once you know the answer, you want to return it to the calling routine immediately. If the routine is defined in such a way that it doesn't require any cleanup, not returning immediately means that you have to write more code.
347
347
+ Minimize the number of returns in each routine. It's harder to understand a routine if, reading it at the bottom, you're unaware of the possibility that it *return*ed somewhere above.
348
348
@@ -396,7 +396,7 @@ function getSomething(val) {
396
396
397
397
## Arrow Functions
398
398
399
-
Use arrow functions over anonymous function expressions. Typescript will take care for`this`.
399
+
Use arrow functions over anonymous function expressions. Typescript will take care of`this`.
400
400
401
401
*Right:*
402
402
@@ -423,7 +423,7 @@ req.on("end", function () {
423
423
424
424
Use the [JSDoc][JSDOC] convention for comments. When writing a comment always think how understandable will be for somebody who is new to this code. Even if it may look simple to you think how a guy that just joined will understand it. Always comment in the following cases:
425
425
+ When there is some non-trivial logic.
426
-
+ Some "external" knowledge is needed which is missing in the context - workaround for driver, module bug, special 'hack' because of a bug and so on;
426
+
+ Some "external" knowledge is needed which is missing in the context - workaround for a driver, module bug, special 'hack' because of a bug and so on;
427
427
+ When you are creating a new class
428
428
+ Public methods - include all the arguments and if possible the types {String}, {Number}. Optional arguments should be marked too. Check the [@param tag][param]
429
429
@@ -432,7 +432,7 @@ Use the [JSDoc][JSDOC] convention for comments. When writing a comment always th
432
432
433
433
## File/module structure
434
434
435
-
Typical module should have the following structure:
435
+
A typical module should have the following structure:
436
436
437
437
1. required dependencies
438
438
2. module-private declarations - variables, functions, classes, etc.
@@ -442,7 +442,7 @@ Typical module should have the following structure:
442
442
For more information see [this file](https://github.com/telerik/xPlatCore/blob/master/JS/BCL/CreateNewModule.md)
443
443
444
444
## File naming
445
-
Use lower case for file names. Use dash to separate different words.
445
+
Use lower case for file names. Use a dash to separate different words.
446
446
447
447
*Right:*
448
448
file-system
@@ -451,7 +451,7 @@ file-system
451
451
FileSystem, fileSystem, file_system
452
452
453
453
## This, that, self
454
-
When you **need** to keep reference to **this** use **that** as the name of the variable. Additionally, if you use the TypeScript lambda support, the compiler will take care of this automatically.
454
+
When you **need** to keep a reference to **this** use **that** as the name of the variable. Additionally, if you use the TypeScript lambda support, the compiler will take care of this automatically.
455
455
456
456
*Right:*
457
457
```TypeScript
@@ -470,7 +470,7 @@ doSomething(function(){
470
470
```
471
471
472
472
## Private (hidden) variables and methods
473
-
Although there is the **private** keyword in TypeScript, it is only a syntax sugar. There is no such notation in JavaScript and everything is available to the users. Hence, always use underscore (**_**) to prefix private variables and methods. There are also methods which have the **public** visibility but they are meant to be used within our code ONLY. Such methods should also be prefixed with underscore.
473
+
Although there is the **private** keyword in TypeScript, it is only a syntax sugar. There is no such notation in JavaScript and everything is available to the users. Hence, always use underscore (**_**) to prefix private variables and methods. There are also methods which have the **public** visibility but they are meant to be used within our code ONLY. Such methods should also be prefixed with an underscore.
Copy file name to clipboardExpand all lines: WritingUnitTests.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
# Writing Unit Tests for NativeScript Core Modules
2
2
3
3
Unit tests for NativeScript Modules are written and executed with a custom lightweight test-runner and assertion framework.
4
-
The purpose of this document is to get you familiar with it, so that you can unit-test your contributions to the NativeScript framework.
4
+
The purpose of this document is to get you familiar with it so that you can unit-test your contributions to the NativeScript framework.
5
5
6
6
# Run Unit Tests Project
7
7
@@ -19,7 +19,7 @@ tns run ios
19
19
# Test Modules
20
20
21
21
All unit tests are organized into test modules(bundles).
22
-
By default the test app will run all the tests from all registered test modules. This happens in [`runTests()`](/tests/app/app/mainPage.ts#L26-L28) method in the main page of the test-app. By modifying this method, you can configure the app to:
22
+
By default, the test app will run all the tests from all registered test modules. This happens in [`runTests()`](/tests/app/app/mainPage.ts#L26-L28) method in the main page of the test-app. By modifying this method, you can configure the app to:
23
23
24
24
***Execute only the tests from a specific test module**:
25
25
@@ -50,8 +50,8 @@ The test modules are actually TypeScript modules which export unit tests and hoo
50
50
51
51
* All exported functions with a `test` prefix are unit-tests.
52
52
* The `setUpModule()` hook is called once - before all the tests in the module.
53
-
* The `setUp()` hook is called before each tests.
54
-
* The `tearDown()` hook called after each tests.
53
+
* The `setUp()` hook is called before each test.
54
+
* The `tearDown()` hook called after each test.
55
55
* The `tearDownModule()` hook is called once - after all the tests in the module.
56
56
57
57
# Asserting
@@ -85,4 +85,4 @@ export function test_getJSON(done) {
85
85
86
86
# Misc
87
87
88
-
When looking into the code of the existing tests, you might encounter strange comments looking like this `// >> animation-chaining`. These are markers for code snippets generated in the docs documetation. They are not related to testing so you don't need to add any of those in your tests.
88
+
When looking into the code of the existing tests, you might encounter strange comments looking like this `// >> animation-chaining`. These are markers for code snippets generated in the docs documentation. They are not related to testing so you don't need to add any of those in your tests.
0 commit comments