Skip to content

Code Contribution Guideline

jmarkowski edited this page Feb 5, 2020 · 21 revisions

Methods and Variables naming

  • public: lowerCamelCase. Example: firstName, addProductToShopCart()
  • private: lowerCamelCase with _ prefix. Example: _firstName, _addProductToShopCart()
  • Properties/Decorators: variable declaration should starts from newline from decorator. Example
/** Bad Usage */
@Input() disabled: boolean = false;

/** Good Usage */
@Input()
disabled: boolean = false;

Comments

  • Comments should be consistent, for methods and variables in *.ts files, we should add comments, directly above the commented property.
/** Example of 1 line comment */
public firstName: string = '';

/** 
 * Example of comment with 
 * text longer than 1 line
 */
public firstName: string = '';
/** 
 * @hidden
 * Example of comment for cycle method, that requires some comment
 */
private _removeList(): void {}

/** @hidden */
private _propertyWithoutComment: string;

Angular

  • All components should have changeDetectionStrategy.OnPush. It improves the performance of library.
Clone this wiki locally