@oursky/tslint-oursky

0.12.0 • Public • Published

tslint-oursky

This is a tslint config that does 2 things.

  1. Include opinionated non-stylistic rules that prevent you from making mistakes.
  2. Include some custom useful rules.

Rule version

The included rules are as of tslint@v5.11.0

Example

{
  "extends": [
    "@oursky/tslint-oursky"
  ],
  "rules": {
    "oursky-ban-imports": [true, ["react-native", ["Text", "Image", "*", "default"]]]
  }
}

Custom rules

oursky-ban-imports

This rule allows you to ban imports from specific modules.

If you want to ban namespace import import * as a from "m";, use *.

If you want to ban default import import a from "m";, use default.

This rule is not enabled by default because we do not know what you want to ban.

For example,

"oursky-ban-imports": [true,
  ["react-native", ["Text", "Image", "*", "default"]],
  ["react", ["Component", "*", "default"]]
]

The above configuration bans Text and Image from react-native, Component from react.

oursky-no-inline-function-children

This rule disallows inline function as JSX children.

This rule is enabled by default.

oursky-no-enum

This rule disallows the usage of enum.

The rationale of banning enum is that enum is not a EMCAScript language feature. If you use this in your library, you need to be aware of what it compiles to and tell that to the users of your library. Instead of using enum, use union type to represent an enumeration. If you enable the strictest compiler options and use union type, you can have exhaustive switch statement.

Example Playground

You have to manually enable strictness options because the link does not remember selected options.

This rule is enabled by default.

oursky-no-static-literal

This rule disallows static non-primitive literals in JSX.

This rationale is that static non-primitive literals break React.PureComponent or React.pure

This rule is enabled by default.

Readme

Keywords

none

Package Sidebar

Install

npm i @oursky/tslint-oursky

Weekly Downloads

34

Version

0.12.0

License

Apache-2.0

Unpacked Size

36.3 kB

Total Files

8

Last publish

Collaborators

  • rickmak
  • louischan-oursky
  • cychiuae
  • kiootic