Codelyzer: component-selector stopped working in Angular v6

Created on 10 May 2018  Â·  10Comments  Â·  Source: mgechev/codelyzer

I have the config:

"component-selector": [true, "element", "sg", "kebab-case"],

and this component:

@Component({
  selector: 'sg-cmp' 
})
class AppCmp {}

Now I'm getting a warning

[tslint] The selector of the component "AppCmp" should have prefix "app" (https://angular.io/styleguide#style-02-07) (component-selector)

It used to working before upgrade.

ng -v:

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / â–³ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.0.0
Node: 9.10.1
OS: linux x64
Angular: 6.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.0
@angular-devkit/build-angular     0.6.0
@angular-devkit/build-optimizer   0.6.0
@angular-devkit/core              0.6.0
@angular-devkit/schematics        0.6.0
@ngtools/webpack                  6.0.0
@schematics/angular               0.6.0
@schematics/update                0.6.0
rxjs                              6.1.0
typescript                        2.7.2
webpack                           4.6.0

Most helpful comment

@rafaelss95 thanks you, I realized that the src/tslint.json (Angular Generated) overwritten my global ( tslint.json )custom rules.

All 10 comments

When you say "before upgrade", what are you talking about ? Angular, Angular CLI, Codelyzer or the both ?

I've upgraded everything.

Before all @angular related stuff was in 5.2.10 and Codelyzer 4.2.1. After upgrading I'm getting these warnings.

Are you sure about your tslint.json , maybe have you more than one component-selector entry in your file.
Can you push one repro in Github ?

Without further informations, I close this issue for the moment.

@wKoza The issue should be open, the problem persist.
Typescript File
image
Tslint config
image

I think you confound the type (element or attribute) and the list of prefixes. You have an error because you have set prefixes app and page. You should therefore change your selector name with app-login-main or page-login-main.

@wKoza You are right, but still not working.
captura de pantalla 2018-06-01 a la s 9 57 42 a m

Are you sure that your config are not being overwritten in <your-project>/src/tslint.json? It's a new file that came in angular-cli v6 and maybe you didn't notice that.

@rafaelss95 thanks you, I realized that the src/tslint.json (Angular Generated) overwritten my global ( tslint.json )custom rules.

insert line
@Component({
// tslint:disable-next-line:component-selector
selector: 'vtc-temp',

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Umayalmuthupalaniappan picture Umayalmuthupalaniappan  Â·  5Comments

snebjorn picture snebjorn  Â·  5Comments

fabioemoutinho picture fabioemoutinho  Â·  5Comments

KKrisu picture KKrisu  Â·  5Comments

davidanaya picture davidanaya  Â·  4Comments