Skip to content

Files

Latest commit

 

History

History
84 lines (66 loc) · 1.73 KB

component-class-suffix.md

File metadata and controls

84 lines (66 loc) · 1.73 KB

Pattern: Malformed component suffix

Issue: -

Description

This rule follows the recommendation from the Angular styleguide.

Examples of incorrect code for this rule (with default configuration):

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
class App {}

Example of correct code for this rule:

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
class AppComponent {}

Options

By default, the suffix will be Component. You may pass an array of suffixes, for example:

{
  "@angular-eslint/component-class-suffix": [
    "error",
    {
      "suffixes": ["Component", "Comp"]
    }
  ]
}

Examples of incorrect code with the above options:

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
export class AppCompe {}

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
export class App {}

Example of correct code with the above options:

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
export class AppComp {}

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
export class AppComponent {}

Further Reading