A linter for the TypeScript language.
bitwise
disallows bitwise operators.classname
enforces PascalCased class and interface names.curly
enforces braces forif
/for
/do
/while
statements.debug
disallowsdebugger
statements.dupkey
disallows duplicate keys in object literals.eofline
enforces the file to end with a newline.eqeqeq
enforces === and !== in favor of == and !=.evil
disallowseval
function invocations.forin
enforces afor ... in
statement to be filtered with anif
statement.*indent
enforces consistent indentation levels for the whole file.labelpos
enforces labels only on sensible statements.maxlen
sets the maximum length of a line.noarg
disallows access toarguments.callee
.noconsole
disallows access to the specified properties onconsole
. Property configurations are comma-delimited. For example, the configuration "noconsole: log, debug, warn" disablesconsole.log
,console.debug
andconsole.warn
.noconstruct
disallows access to the constructors ofString
,Number
, andBoolean
.noempty
disallows empty blocks.oneline
enforces an opening brace to be on the same line as the expression preceding it.quotemark
enforces consistent single or double quoted string literals.radix
enforces the radix parameter ofparseInt
semicolon
enforces semicolons at the end of every statement.sub
disallows object access via string literals.trailing
disallows trailing whitespace at the end of a line.varname
allows only camelCased or UPPER_CASED variable names.whitespace
enforces whitespace between a keyword and a conditional, surrounding an operator, and enclosing "=" within variable declarations and import/export statements.
sudo npm install tslint -g
npm install tslint
Please first ensure that the TypeScript source files compile correctly.
usage: tslint
Options:
-c, --config configuration file
-f, --file file to lint [required]
-o, --out output file
-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.
var options = {
formatter: "json",
configuration: configuration
};
var Linter = require("tslint");
var ll = new Linter(fileName, contents, options);
var result = ll.lint();
git clone [email protected]:palantir/tslint.git
cd tslint
git submodule init
git submodule update
npm install
grunt
- Add more rules from jshint
- Disallow variables referenced outside of their scope definition
- Disallow unused variables
- Support external formatters