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

no-unused-css ignores elements with structural directives #249

Closed
tmair opened this issue Feb 22, 2017 · 0 comments · Fixed by #250
Closed

no-unused-css ignores elements with structural directives #249

tmair opened this issue Feb 22, 2017 · 0 comments · Fixed by #250
Assignees
Labels

Comments

@tmair
Copy link
Contributor

tmair commented Feb 22, 2017

When a template contains a structural directive, the no-unused-css rule ignores the element.

The following example will report a Unused Style violation.

@Component({
  selector: 'hero-cmp',
  template: `
    <h1>Hello <div ><span></span>{{ her.name }}</div></h1>
  `,
  styles: [
    `
    h1 spam {
      color: red;
    }
    `
  ]
})
class Hero {
  private hero: Hero;

  test=true;

  ngOnInit() {
    console.log('Initialized');
  }
}

If we change the code slightly to the following, the violation is not present anymore.

@Component({
  selector: 'hero-cmp',
  template: `
    <h1>Hello <div *ngIf="test"><span></span>{{ her.name }}</div></h1>
  `,
  styles: [
    `
    h1 spam {
      color: red;
    }
    `
  ]
})
class Hero {
  private hero: Hero;

  test=true;

  ngOnInit() {
    console.log('Initialized');
  }
}
@mgechev mgechev self-assigned this Feb 22, 2017
@mgechev mgechev added this to the 2.1.0 - Cytinus milestone Feb 22, 2017
tmair added a commit to tmair/codelyzer that referenced this issue Feb 22, 2017
@mgechev mgechev assigned tmair and unassigned mgechev Feb 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants