What exactly does this rule effectuate?
"use-life-cycle-interface": true,
What exactly does this rule effectuate?
"use-life-cycle-interface": true,
It's not a built-in tslint
rule. It's a rule that's defined by codelyzer.
The GitHub repo has a video (that I've not watched), but little documentation. Fortunately, the author has implemented tests, so it's possible to infer what the use-life-cycle-interface
rule does from its test descriptions:
it(`should fail, when a life cycle hook is used without implementing it's interface`, ...
it(`should fail, when life cycle hooks are used without implementing their interfaces`, ...
it(`should fail, when some of the life cycle hooks are used without implementing their interfaces`, ...
it simply means that you have to add the implements keyword for every lifecycle hook you use,
while this is not necessary for angular to recognize and use the hooks, it is much better for code clarity and maintenance.
example:
// don't forget the import
import { AfterViewInit } from '@angular/core';
// you have to have this implements statement
export class YourComponent implements AfterViewInit {
// if you want to use this hook
ngAfterViewInit() {
// your code...
}
}
It's not a built-in tslint
rule. It's a rule that's defined by codelyzer.
The GitHub repo has a video (that I've not watched), but little documentation. Fortunately, the author has implemented tests, so it's possible to infer what the use-life-cycle-interface
rule does from its test descriptions:
it(`should fail, when a life cycle hook is used without implementing it's interface`, ...
it(`should fail, when life cycle hooks are used without implementing their interfaces`, ...
it(`should fail, when some of the life cycle hooks are used without implementing their interfaces`, ...
© 2022 - 2024 — McMap. All rights reserved.