Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule contextual-life-cycle too aggressively scoped #545

Closed
ngiebel opened this issue Mar 21, 2018 · 1 comment · Fixed by #548
Closed

Rule contextual-life-cycle too aggressively scoped #545

ngiebel opened this issue Mar 21, 2018 · 1 comment · Fixed by #548

Comments

@ngiebel
Copy link

ngiebel commented Mar 21, 2018

When turning on the rule contextual-life-cycle, if an @Injectable is defined before a component/directive using lifecycle hooks the rule incorrectly flags a violation. Sample below as an adaptation of the main codelyzer demo, but it seems the demo does not have the rule activated.

@Injectable()
class Sample {
  public constructor() { }
}

@Component({
  selector: 'sg-hero-cmp',
  template: `
    <h1>Hello <span>{{ hero.name }}</span></h1>
  `,
  providers: [Sample]
})
class HeroComponent implements OnInit {
  public hero: Hero;

  public constructor(private sample: Sample) { }

  ngOnInit() {
    console.log('Initialized');
  }
}
@mgechev
Copy link
Owner

mgechev commented Mar 21, 2018

Thanks for reporting this issue! It should be fixed by the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants