- 
                Notifications
    
You must be signed in to change notification settings  - Fork 156
 
General Naming and Coding Guidelines for Ignite UI for Angular
        Damyan Petev edited this page Mar 22, 2024 
        ·
        1 revision
      
    | Version | User | Date | Notes | 
|---|---|---|---|
| 0.1 | Zdravko Kolev | June 10, 2019 | Initial version | 
| 0.2 | Nadia Robakova | January 10, 2020 | Move tests guidelines to new file | 
| 0.3 | Konstantin Dinev | January 27, 2021 | Updating guidelines | 
- Radoslav Karaivanov | Date:
 - Konstantin Dinev | Date: 01/27/2021
 
- Use 
upper camel case (PascalCase)when namingclassesandinterfaces(exceptionServicetoExceptionService) - Use 
camelCaseformethods,propertiesandlocal variables. - Use 
capitalizedenums. Different in TypeScript guidelines. - Use 
underscoreforprivate properties(private _size: string). Different in TypeScript guidelines. - Use 
underscoreforprivate events(private _onOpening(event: OverlayCancelableEventArgs)) - Use "I" as a prefix for 
Interface names. Different in TypeScript guidelines. - Explicitly set the type of a returned element. Example with 
HTMLElementbelow: 
public get element(): HTMLElement {
    return this.elementRef.nativeElement;
}- Use 
@hiddentag to hide classes, methods, properties, and events from the API documentation: 
/**
 * @hidden
 */
public toggleRowEditingOverlay(show) { .. }- Provide detailed descriptions to classes, properties, methods and events. This is mandatory for 
publicand optional forprivateandprotectedmembers: 
/**
 * An @Input property that autogenerates the `IgxGridComponent` columns.
 * The default value is false.
 * ```html
 * <igx-grid [data]="Data" [autoGenerate]="true"></igx-grid>
 * ```
 * @memberof IgxGridBaseDirective
 */
@Input()
public autoGenerate = false;- Using of 
Anonymous objectsis not a good practice. Instead of having an anonymous object type define a specificInterfacethat can be referenced by our code. - Use whole words in names when possible.
 - Strive for Cyclomatic Complexity not higher than 7
 - Use PascalCase 
enumnaming. - 
ViewChild,ViewChildren,ContentChild,ContentChildrenshould haveprivateaccessibility in components, unless the component can be inherited and you want to reuse it's view/content children, in which case the accessibility should beprotected. If you want to access view/content childrent in tests, then cast the component toanytype and access the private member this way. - When fixing a bug or making a change with a very specific reason you need to leave a comment above the code block change with the following format:
 
Leave a comment above your change in the format <initials> <date> <Issue Number|Issue Link> <Comment for the change>
e.g. K.D. June 28th, 2021 #1234 Adding this comment as an example
e.g. K.D. June 28th, 2021 https://github.com/IgniteUI/ignite-ui/issues/1234 Adding this comment as an example
- Use upper camel case for class names 
export class IgxAvatar - Add 'Igx' prefix to class names 
export class IgxAvatar - Do use consistent names for all pipes, named after their feature
 - Don't name events with the prefix on. Angular guideline.
 - Use attribute directives when you have presentation logic without a template.
 - Use dashes to separate words in the descriptive name (Separate File Names with Dots and Dashes)
 - File names, do give the filename the conventional suffix (such as 
.component.ts,.directive.ts,.module.ts,.pipe.ts, or.service.ts) for a file of that type. Follow a pattern that describes the symbol's feature then its type.Example: The recommended pattern isfeature.type.ts(badge.component.ts) - Do name test specification files the same as the component they test (with a suffix of 
.spec;Example:badge.component.spec.ts) - Extract templates and styles into a separate file, when more than 3 lines. Name the template file 
[component-name].component.html, where[component-name]is the component name the style file with[component-name].component.css. - Do define small functions and consider limiting to no more than 75 lines.
 - Component selectors - Use 
igxas a selector prefix anddashed-caseorkebab-casefor naming the element selectors of components. - Component styling follows the BEM methodology
 
@Component({
selector: 'igx-badge',
templateUrl: 'badge.component.html'
})
export class IgxBadgeComponent {}- Directive selector - Use 
igxas a selector prefix and lower camel case for naming the selectors of directives. 
@Directive({
selector: '[igxAutocomplete]'
})
export class IgxAutocompleteDirective