Please use the following settings for esLint:
.eslintrc |
|
Type Declarations
We always use explicit type declarations.
private readonly counter: number = 0;
Constructors
We use constructors with explicit field initialization.
The following code segment shows how we use constructors:
export class A {
data: string;
}
export class B extends A {
constructor(data: string){
this.data = data; // explicit initialization
}
}
The following code segment shows how not to do it:
export class A {
data: string;
}
export class B extends A {
constructor(readonly data: string){ // implicit initializaion
…
}
}
Fields
Fields are private and readonly if possible.
export class A {
private readonly data: string;
private isTrue: boolean = true;
constructor(data: string){
this.data = data;
}
}