Skip to content

Coding Style

JinGyeong Jeong edited this page Aug 30, 2018 · 10 revisions

Table of contents

  1. TypeScript Styles
  2. Namings
    1. File name
    2. Class name
    3. Variable/Method name
  3. Module export
  4. Tools
    1. VS Code Plugins
    2. TypeScript Formatter

TypeScript Styles

  • Refer to tsconfig.json and tslint.json

Namings

File name

  • Use snake_case for non-class component file (e.g. src/utils.ts)
  • Use the class name for class component file (e.g. src/primitives/Block.ts)

Class name

Use PascalCase, except for SDK class

Variable/Method name

  • Use UPPERCASE for variables for constant value
  • Use camelCase for others (e.g. signEcdsa)
  • Except JSON (e.g. getTransactionFromJSON)

Module export

  • Use export only. Do not use export default

Tools

VS Code Plugins

  • EditorConfig for VS Code
  • Prettier - Code formatter
  • TSLint

TypeScript Formatter

  1. install dependencies by running yarn
  2. run yarn fmt