I generated my project using angular-cli which version is 1.0.0-beta.28.3
.
I write in the terminal a command ng lint
and get big amount errors:
I haven't any ideas why I get such amount errors after running ng lint
.
Below code of machines.component.ts
:
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { DialogService } from 'ng2-bootstrap-modal';
import { ModalComponent } from '../modal/modal.component';
import { MachineService } from '../services/machine.service';
import { Machine } from '../models/machine.model';
import { BoxService } from '../services/box.service';
import { Box } from '../models/box.model';
import { AppConfig } from '../app.config';
@Component({
selector: 'app-machines',
templateUrl: './machines.component.html',
styleUrls: ['./machines.component.scss']
})
export class MachinesComponent implements OnInit, OnDestroy {
private display: boolean;
private alive: boolean;
private timer: Observable<number>;
machines: Machine [];
box: Box;
constructor(
private dialogService: DialogService,
private boxService: BoxService,
private machineService: MachineService,
private appConfig: AppConfig) {
this.display = false;
this.alive = true;
this.timer = Observable.timer(0, this.appConfig.interval_requests);
}
ngOnInit() {
this.timer
.takeWhile(() => this.alive)
.subscribe(() => {
this.machineService.getStatesMachines().subscribe(
(res: Response) => {
this.machines = res.json();
if (!this.display) {
this.display = true;
}
}
);
}
);
}
ngOnDestroy() {
this.alive = false;
}
getBox(device_name: string) {
this.boxService.getBox(device_name).subscribe(
(res: Response) => {
const box = res.json();
this.box = box;
this.dialogService.addDialog(ModalComponent, {
device_name: this.box.device_name + '`s info',
name: this.box.name,
timestamp: this.box.timestamp,
ip_address: this.box.ip_address
}, {closeByClickingOutside: true});
}
);
}
}
When project was generated I didn't change any properties in tslint.json
. Default, "no-use-before-declare": true
.
I searched the answers at Github and at Stackoverflow, but didn't find. Perhaps, I searched it badly if so far didn't find.
Please, help me.
you can set
"no-use-before-declare": false
This rule is primarily useful when using the
var
keyword - the compiler will detect if alet
andconst
variable is used before it is declared