simplr-tslint
A set of TSLint rules used in SimplrJS projects.
Last updated 2 years ago by simplrjs-admin .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install simplr-tslint 
SYNC missed versions from official npm registry.

simplr-tslint

A set of TSLint rules used in SimplrJS projects.

Get started

npm install simplr-tslint --save-dev

How to use?

Add this line in your tslint.json file:

{
    "extends": "simplr-tslint"
}

Or:

{
    "extends": ["simplr-tslint"]
}

Custom rules

class-members-name

????Has Fixer ⚠️Requires Type info

Enforces consistent naming style in interface and class declarations.

Format rule

Name Type Optional Default
kind "method", "property" Required
modifier "public", "private", "protected" Optional "public"
format "none", "camel-case", "pascal-case", "constant-case", "snake-case" Optional "none"
isStatic boolean Optional false
prefix string Optional

Config examples

Enforces all members naming to camel-case format.

"class-members-name": true

Enforces all members naming to pascal-case format.

"class-members-name": [true, "pascal-case"]

Enforces all members naming to pascal-case format. Skips origin checking in heritage. Useful when migrating coding style.

"class-members-name": [true, "pascal-case", "skip-origin-checking"]

C# coding style example.

"class-members-name": [
    true,
    [
        { "kind": "method", "modifier": "public", "format": "pascal-case" },
        { "kind": "method", "modifier": "protected", "format": "pascal-case" },
        { "kind": "method", "modifier": "private", "format": "camel-case" },
        { "kind": "property", "modifier": "public", "format": "pascal-case" },
        { "kind": "property", "modifier": "protected", "format": "pascal-case" },
        { "kind": "property", "modifier": "private", "format": "camel-case" }
    ]
]

Private with leading underscore and Protected with leading two underscores.

"class-members-name": [
    true,
    [
        { "kind": "method", "modifier": "public", "format": "camel-case" },
        { "kind": "method", "modifier": "protected", "format": "camel-case", "prefix": "__" },
        { "kind": "method", "modifier": "private", "format": "camel-case", "prefix": "_" },
        { "kind": "property", "modifier": "public", "format": "camel-case" },
        { "kind": "property", "modifier": "protected", "format": "camel-case", "prefix": "__" },
        { "kind": "property", "modifier": "private", "format": "camel-case", "prefix": "_" }
    ]
]

const-variable-name

????Has Fixer ⚠️Requires Type info

Const variables in source file or in module must have constant-case.

Examples

export const FOO_FOO = "Hello World!";

export const fooBar = "Hello World!";
//   ~~~~~~                    [Const variables in source file or in module declaration must have (constant-case) format.]

export namespace FooNamespace {
    export const PACKAGE_VERSION: string = "v1.0.0";

    export function test(): void {
        const variableInFunctionScope: string = "Hello.";
    }
}

Config example

"const-variable-name": true

This rule only will be applied to constants that has primitive value (e.g. string, boolean).

"const-variable-name": [true, "only-primitives"]

exported-namespace-member

????Has Fixer

All module members must be exported.

Config example

"exported-namespace-member": true

type-parameter-name

????Has Fixer

Type parameter's name must start with "T" prefix.

Example

export type Foo<Value> = [string, Value];
//  ~~~~~                      [Type parameter's name must start with "T" prefix.]

export type Bar<TValue> = [string, TValue];

Config example

"type-parameter-name": true

License

Released under the MIT license.

Current Tags

  • 1.0.0-alpha.14                                ...           latest (2 years ago)
  • 1.0.0-alpha.14                                ...           next (2 years ago)

14 Versions

  • 1.0.0-alpha.14                                ...           2 years ago
  • 1.0.0-alpha.13                                ...           2 years ago
  • 1.0.0-alpha.12                                ...           2 years ago
  • 1.0.0-alpha.11                                ...           2 years ago
  • 1.0.0-alpha.10                                ...           2 years ago
  • 1.0.0-alpha.9                                ...           2 years ago
  • 1.0.0-alpha.8                                ...           2 years ago
  • 1.0.0-alpha.7                                ...           2 years ago
  • 1.0.0-alpha.6                                ...           2 years ago
  • 1.0.0-alpha.5                                ...           2 years ago
  • 1.0.0-alpha.4                                ...           2 years ago
  • 1.0.0-alpha.2                                ...           2 years ago
  • 1.0.0-alpha                                ...           2 years ago
  • 0.0.1                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 6
Last Day 0
Last Week 4
Last Month 15
Dependencies (1)
Dev Dependencies (8)

Copyright 2014 - 2016 © taobao.org |