Codelyzer: Support template directives

Created on 12 Oct 2016  路  3Comments  路  Source: mgechev/codelyzer

I am using directives with selector of the form template[myPrefixDirectiveName] in my app, ala what ng-bootstrap does currently (see the documentation for the modal for example and the note on the <template ngbModalContainer> usage), and get warning messages like

The selector of the directive "Foo" should be used as attribute (https://goo.gl/QS8kEs)
The selector of the directive "Foo" should have prefix `my` (https://goo.gl/uacjKR)

This should be supported by Codelyzer IMO.

Most helpful comment

@phil123456 this should work:

@Directive({
  /* tslint:disable-next-line:directive-selector */
  selector: 'card-row'
})

All 3 comments

We're working on improving the selector-related rules so [prefixRest].bar and [prefixBar][foo] will work for directives with default settings and prefix being the "prefix".

The selector of the template directives doesn't have to include element so most likely even after the improvements your selector is going to fail for directive-selector-type.

Btw, this is an issue which should be moved to angular/angular.io but in general if you believe that your directive should include an element selector you can disable the rule like:

@Component({
  /* tslint:disable-next-line:component-selector-prefix component-selector-name */
  selector: 'fooBar',
  template: '<h1>{{ hero.name }}</h1>'
})
class HeroDetailsComponent { }

does not work for my directives

@Directive({
    /* tslint:disable-next-line:component-selector-prefix component-selector-name */
    selector: '[erTable]'
})
export class ERTableDirective {

@phil123456 this should work:

@Directive({
  /* tslint:disable-next-line:directive-selector */
  selector: 'card-row'
})
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Martin-Wegner picture Martin-Wegner  路  6Comments

damsorian picture damsorian  路  3Comments

fabioemoutinho picture fabioemoutinho  路  5Comments

rolandjitsu picture rolandjitsu  路  5Comments

lazarljubenovic picture lazarljubenovic  路  4Comments