1.0.1 • Published 1 year ago

tslint-strict-oop v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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
        }
      }
    }
1.0.1

1 year ago

1.0.0

1 year ago