@oursky/tslint-oursky
v0.12.0
Published
This is a tslint config that does 2 things.
Downloads
8
Keywords
Readme
tslint-oursky
This is a tslint config that does 2 things.
- Include opinionated non-stylistic rules that prevent you from making mistakes.
- Include some custom useful rules.
Rule version
The included rules are as of [email protected]
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.
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.