Skip to content

Code Style

Eugenio Romano edited this page Oct 14, 2017 · 16 revisions

The code style is defined in the tslint.json and .editorconfig files.

Events name

  • Do name events without the prefix on.
  • Do name event handler methods with the prefix on followed by the event name
  • Do name events in camelcase.
  • All event names should be verbs and use the present tense. For example, cancel instead of canceled

inputs and outputs

  • Avoid aliasing inputs and outputs
  • Do name in camelcase.

Whitespaces

  • leave one whitespace character inside of the import statements' curly braces ("ES6 import/export braces" rule for IntelliJ IDEA)
  • leave one whitespace character after type reference colon ':' ("After type reference colon ':'" rule for IntelliJ IDEA)

File Name

  • All the Directive has to end with the suffix .directive
  • All the Component has to end with the suffix .component
  • All the Service has to end with the suffix .service
  • ALFRESCO|ACTIVITI|ADF prefix for file names are not allowed

Class Name

  • All the Directive class name has to end with the suffix Directive
  • All the Component class name has to end with the suffix Component
  • All the Service class name has to end with the suffix Service
  • ALFRESCO|ACTIVITI|ADF prefixes are not allowed

SCSS/CSS class

  • CSS files are deprecated in the project use only scss
  • All the style class has to start with ADF- prefix

i18n files

  • All the keys has to be uppercase and separated with underscore example : CAPITALIZED_WITH_UNDERSCORES
  • Not use concatenated keys

General

  • Extract templates and styles to their own files

Test

  • Class selector in all the test is not suggested. Element ID is preferred

More other styling rules to be cosidered as good to use are referenced here: Angular style guide

May you want to use our yeoman generator to create a new component Component generator