Package Exports
- tslint
- tslint/bin/tslint
- tslint/lib/tslint
- tslint/package.json
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tslint) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
tslint

A linter for the TypeScript language.
Supported Rules
class-name
enforces PascalCased class and interface names.curly
enforces braces forif
/for
/do
/while
statements.eofline
enforces the file to end with a newline.forin
enforces afor ... in
statement to be filtered with anif
statement.*indent
enforces consistent indentation levels (currently disabled).label-position
enforces labels only on sensible statements.label-undefined
checks that labels are defined before usage.max-line-length
sets the maximum length of a line.no-arg
disallows access toarguments.callee
.no-bitwise
disallows bitwise operators.no-console
disallows access to the specified properties onconsole
. Rule options are properties to ban on the console variable.no-construct
disallows access to the constructors ofString
,Number
, andBoolean
.no-debugger
disallowsdebugger
statements.no-duplicate-key
disallows duplicate keys in object literals.no-duplicate-variable
disallows duplicate variable declarations.no-empty
disallows empty blocks.no-eval
disallowseval
function invocations.no-string-literal
disallows object access via string literals.no-trailing-whitespace
disallows trailing whitespace at the end of a line.no-unreachable
disallows unreachable code afterbreak
,catch
,throw
, andreturn
statements.one-line
enforces the specified tokens to be on the same line as the expression preceding it. Rule options:"check-catch"
checks thatcatch
is on the same line as the closing brace fortry
"check-else"
checks thatelse
is on the same line as the closing brace forif
"check-open-brace"
checks that an open brace falls on the same line as its preceding expression."check-whitespace"
checks preceding whitespace for the specified tokens.
quotemark
enforces consistent single or double quoted string literals.radix
enforces the radix parameter ofparseInt
semicolon
enforces semicolons at the end of every statement.triple-equals
enforces === and !== in favor of == and !=.variable-name
allows only camelCased or UPPER_CASED variable names. Rule options:"allow-leading-underscore"
allows underscores at the beginnning.
whitespace
enforces spacing whitespace. Rule options:"check-branch"
checks branching statements (if
/else
/for
/while
) are followed by whitespace"check-decl"
checks that variable declarations have whitespace around the equals token"check-operator"
checks for whitespace around operator tokens"check-separator"
checks for whitespace after separator tokens (,
/;
)"check-type"
checks for whitespace before a variable type specification
Installation
CLI
sudo npm install tslint -g
Library
npm install tslint
Usage
Please first ensure that the TypeScript source files compile correctly.
CLI
usage: tslint
Options:
-c, --config configuration file
-f, --file file to lint [required]
-o, --out output file
-r, --rules-dir rules directory
-s, --formatters-dir formatters directory
-t, --format output format (prose, json) [default: "prose"]
By default, configuration is loaded from .tslintrc
or tslint.json
, if either exists in the current path.
Library
var options = {
formatter: "json",
configuration: configuration,
rulesDirectory: "customRules/",
formattersDirectory: "customFormatters/"
};
var Linter = require("tslint");
var ll = new Linter(fileName, contents, options);
var result = ll.lint();
Development
Setup
git clone git@github.com:palantir/tslint.git
cd tslint
git submodule init
git submodule update
Build
npm install
grunt
TODO
- Add more rules from jshint
- Disallow variables referenced outside of their scope definition
- Disallow unused variables
- Support pluggable formatters