Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 1.45 KB

coding-guidelines.md

File metadata and controls

52 lines (38 loc) · 1.45 KB

Coding styles

General guidelines on how to code for this probject

Libraries

Those will be run automatically by the CI and if any error is found will fail the build.

  • tslint for typescript styling. With vscode install the tslint extension to have live warning.
  • stylelint for scss. With vscode install the stylelint extension to have live warning.

Other

Imports

Use 2 group for import(TSLint will then make sure they are sorted alpha in each group):

  1. For npm import
  2. For local import

e.g.

import { Component } from "@angular/core";
import { FormBuilder, FormGroup, Validators } from "@angular/forms";
import { autobind } from "@batch-flask/core";
import { Observable } from "rxjs";

import { NotificationService } from "@batch-flask/ui/notifications";
import { SidebarRef } from "@batch-flask/ui/sidebar";

// Code goes here

Relative import

Try to use absolute import whenever possible(From the root of the project - start with `"app/...") Only use a relative import for

// Good
import {Some} from "app/components/folder/file"
import {Some} from "./file"
import {Some} from "./folder/file"

// Ok
import {Some} from "../folder/file"

// Bad
import {Some} from "../../folder/file"
import {Some} from "../../../folder/file"

Component template

Use templateUrl: "abc.html" instead of template: require("abc.html"). Try to only use template: "<inline-template></inline-template>" for simple templates.