mirror of
https://github.com/nasa/openmct.git
synced 2025-05-13 22:13:18 +00:00
Fixed formatting issues, removed outdated example code.
This commit is contained in:
parent
32c892fe98
commit
da2ecbbcad
119
CONTRIBUTING.md
119
CONTRIBUTING.md
@ -148,18 +148,18 @@ JavaScript sources in Open MCT should:
|
|||||||
and/or their inclusion makes sense within the flow of the code
|
and/or their inclusion makes sense within the flow of the code
|
||||||
(e.g. as arguments to a forEach call).
|
(e.g. as arguments to a forEach call).
|
||||||
1. Named functions are preferred over functions assigned to variables.
|
1. Named functions are preferred over functions assigned to variables.
|
||||||
eg.
|
eg.
|
||||||
```JavaScript
|
```JavaScript
|
||||||
function renameObject(object, newName) {
|
function renameObject(object, newName) {
|
||||||
Object.name = newName;
|
Object.name = newName;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
is preferable to
|
is preferable to
|
||||||
```JavaScript
|
```JavaScript
|
||||||
const rename = (object, newName) => {
|
const rename = (object, newName) => {
|
||||||
Object.name = newName;
|
Object.name = newName;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
1. Avoid deep nesting (especially of functions), except where necessary
|
1. Avoid deep nesting (especially of functions), except where necessary
|
||||||
(e.g. due to closure scope).
|
(e.g. due to closure scope).
|
||||||
1. End with a single new-line character.
|
1. End with a single new-line character.
|
||||||
@ -183,78 +183,35 @@ const rename = (object, newName) => {
|
|||||||
1. Don’t use the ternary operator. Yes it's terse, but there's probably a clearer way of writing it.
|
1. Don’t use the ternary operator. Yes it's terse, but there's probably a clearer way of writing it.
|
||||||
1. Test specs should reside alongside the source code they test, not in a separate directory.
|
1. Test specs should reside alongside the source code they test, not in a separate directory.
|
||||||
1. Organize code by feature, not by type.
|
1. Organize code by feature, not by type.
|
||||||
eg.
|
eg.
|
||||||
```
|
```
|
||||||
- telemetryTable
|
- telemetryTable
|
||||||
- row
|
- row
|
||||||
TableRow.js
|
TableRow.js
|
||||||
TableRowCollection.js
|
TableRowCollection.js
|
||||||
TableRow.vue
|
TableRow.vue
|
||||||
- column
|
- column
|
||||||
TableColumn.js
|
TableColumn.js
|
||||||
TableColumn.vue
|
TableColumn.vue
|
||||||
plugin.js
|
plugin.js
|
||||||
pluginSpec.js
|
pluginSpec.js
|
||||||
```
|
```
|
||||||
is preferable to
|
is preferable to
|
||||||
```
|
```
|
||||||
- telemetryTable
|
- telemetryTable
|
||||||
- components
|
- components
|
||||||
TableRow.vue
|
TableRow.vue
|
||||||
TableColumn.vue
|
TableColumn.vue
|
||||||
- collections
|
- collections
|
||||||
TableRowCollection.js
|
TableRowCollection.js
|
||||||
TableColumn.js
|
TableColumn.js
|
||||||
TableRow.js
|
TableRow.js
|
||||||
plugin.js
|
plugin.js
|
||||||
pluginSpec.js
|
pluginSpec.js
|
||||||
```
|
```
|
||||||
Deviations from Open MCT code style guidelines require two-party agreement,
|
Deviations from Open MCT code style guidelines require two-party agreement,
|
||||||
typically from the author of the change and its reviewer.
|
typically from the author of the change and its reviewer.
|
||||||
|
|
||||||
#### Code Example
|
|
||||||
|
|
||||||
```js
|
|
||||||
/*global define*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Bundles should declare themselves as namespaces in whichever source
|
|
||||||
* file is most like the "main point of entry" to the bundle.
|
|
||||||
* @namespace some/bundle
|
|
||||||
*/
|
|
||||||
define(
|
|
||||||
['./OtherClass'],
|
|
||||||
function (OtherClass) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A summary of how to use this class goes here.
|
|
||||||
*
|
|
||||||
* @constructor
|
|
||||||
* @memberof some/bundle
|
|
||||||
*/
|
|
||||||
function ExampleClass() {
|
|
||||||
}
|
|
||||||
|
|
||||||
// Methods which are not intended for external use should
|
|
||||||
// not have JSDoc (or should be marked @private)
|
|
||||||
ExampleClass.prototype.privateMethod = function () {
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A summary of this method goes here.
|
|
||||||
* @param {number} n a parameter
|
|
||||||
* @returns {number} a return value
|
|
||||||
*/
|
|
||||||
ExampleClass.prototype.publicMethod = function (n) {
|
|
||||||
return n * 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ExampleClass;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
### Test Standards
|
### Test Standards
|
||||||
|
|
||||||
Automated testing shall occur whenever changes are merged into the main
|
Automated testing shall occur whenever changes are merged into the main
|
||||||
|
Loading…
x
Reference in New Issue
Block a user