tslint-strict-oop

1.0.1 • Public • Published

tslint-strict-oop

Usage

In tslint.json:

{
  "rulesDirectory": "node_modules/tslint-strict-oop/dist",
  "rules": {
    "one-class-per-file": true,
    "strict-unions": true,
    "class-filename": true,
    "only-classes-on-top": true
  },
}

Rules

one-class-per-file

  • File must contain only one class declaration.

only-classes-on-top

  • Only classes are allowed to be declared in the global scope.

class-filename

  • File name must match the name of the class it contains.

strict-unions

  • Explicit or implicit unions can contain only one type plus null and undefined.
    This is not allowed:
class Sample1 {
  someMethod() { // two types union for return type: boolean | string
    if (Math.random() > 0.5) {
      return true; // type one
    } else {
      return 'this is true'; // type two
    }
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i tslint-strict-oop

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

16.8 kB

Total Files

12

Last publish

Collaborators

  • vpetyukevich