Skip to main content

Ditsmod coding style guide

Here is the recommended format in the form of a pair "file name" - "class name":

  • hello-world.module.ts - HelloWorldModule;
  • hello-world.controller.ts - HelloWorldController;
  • hello-world.service.ts - HelloWorldService;
  • auth.guard.ts - AuthGuard.

That is,

  1. the names of any files must contain only lowercase letters;
  2. if there are several words in the file name, you should separate them with a hyphen;
  3. class roles must precede the extension and must be preceded by a dot (*.module.ts, *.controller.ts, *.service.ts, *.guard.ts);
  4. class names must start with a capital letter, and contain exactly the same words as in the name of their files, but in the style of CamelCase.

It is recommended to call the root module - AppModule.

When importing, it is recommended not to mix import from local files and import from node_modules. At the top are imports from node_modules, and then retreating one line are local imports:

import { injectable } from '@ditsmod/core';
import { CanActivate, Status } from '@ditsmod/core';

import { AuthService } from './auth.service.js';
import { Permission } from './permission.js';

Extension group token names must end in _EXTENSIONS, such as MY_EXTENSIONS.