node package manager


Leiningen logo


NPM version Build Status

TS-StyleCop provides value by enforcing a common set of style rules for TypeScript code. TS-StyleCop intend to be a single, consistent set of rules. Developers also will be able to implement their own rules.

Based on C# StyleCop.



npm install -g tscop


tscop hello.ts


  1. Having the following file (test.ts):
var Myvar = 1;
class class1 { }
class class2 { }
class anotherClass {
    public MyMethodName(): string{
        return null;
class Class3 { }
  1. Executing TS-StypeCop to this file:

     tscop test.ts
  2. The command output will be:

Suppressing rules

To suppress a rule you need to put a line comment with the following syntax:

// SuppressMessage -> SA1300:ElementMustBeginWithUpperCaseLetter 

With this the TS-StyleCop will ignore this rule validation to the first element after this comment. Example:

// SuppressMessage -> SA1300:ElementMustBeginWithUpperCaseLetter 
class className1 { 
    public Methid(){
// test... 
class className2 { }

The output will be:

  #1 [SA1301] Element must begin with lower case letter
         public Methid(){ // Line 3, Pos 12

  #2 [SA1300] Element must begin with upper case letter
     class className2 { } // Line 8, Pos 7

 [!] Failed - 2 violations found.

NOTE: The className1 validation was ignored


  1. Install Node if you haven't already (
  2. At the root folder run npm install
  3. Install grunt cli ( To do this, run npm install -g grunt-cli
  4. At the root folder run grunt

TS-StyleCop rules

The implemented rules until now are:

  • Naming Rules (SA13)* Rules which enforce naming requirements for members, types, and variables.
    • SA1300: The name of a TypeScript element does not begin with an upper-case letter.
    • SA1301: The name of a TypeScript element does not begin with an lower-case letter.

I'm working on porting and adapt all this rules: Rules.html


  • Add unit tests
  • Improving the interface to create rules
  • IMplement a set of rules
  • Refactor the code
  • Create a VisualStudio plugin
  • ...

Creating a custom rule