I develop with Typescript in Visual Studio 2013 and always have my error list open on the bottom. TSLint tells me when my code is messy/incorrect as i\'m writing it. I don\'
You now have to this using gulp tasks to make this happen. It's a bit of a pain if you ask me, but it does work! This is how we do it:
cd C:\\path\to\projectnpm install gulp-tslint --save-devnpm install gulp-plumber --save-devOptional:
npm install gulp-newer --save-devnpm install gulp-watch --save-devNow everything is installed! Open Visual Studio and add a new gulpfile.js to your project root with the following contents:
///
//Node packages
var gulp = require("gulp");
var plumber = require("gulp-plumber");
var tslint = require("gulp-tslint");
//Only include these 2 packages if you've installed them
var newer = require("gulp-newer");
var watch = require("gulp-watch");
//Paths to include/exclude
var TYPE_SCRIPT_FILES = ["app/**/*.ts", "!app/core/Events.ts"];
//Our TSLint settings
var TYPE_SCRIPT_REPORT = tslint.report("prose", {
emitError: false,
reportLimit: 50
});
//The actual task to run
gulp.task("TSLint:All", function () {
return gulp.src(TYPE_SCRIPT_FILES)
.pipe(plumber())
.pipe(tslint())
.pipe(TYPE_SCRIPT_REPORT);
});
//===== ONly include the below code if needed
// File locations
var BIN = "bin";
// Listens for new (updated) typescript files and runs through TSlint
gulp.task("TSLint:Newer", [], function (done) {
return gulp.src(TYPE_SCRIPT_FILES)
.pipe(plumber())
.pipe(newer(BIN))
.pipe(tslint())
.pipe(TYPE_SCRIPT_REPORT)
.pipe(gulp.dest(BIN));
});
//This task runs when the project opens. When any file changes, it will be run through TSLint
gulp.task('TSLint:Watch', function () {
return gulp.src(TYPE_SCRIPT_FILES)
.pipe(watch(TYPE_SCRIPT_FILES))
.pipe(plumber())
.pipe(tslint())
.pipe(TYPE_SCRIPT_REPORT)
.pipe(gulp.dest(BIN));
});
Ok, now everything is ready to use! Now in Visual Studio open the Task Runner Explorer. The tasks should appear here.
Not that You can tell each task when to run. You can set this by right clicking on each task, and it just adds to the first line on the gulpfile.js
TSLint:All task will run TSLint on all the specified files.TSLint:Newer task will run TSLint on all files that have been changed since the last check.TSLint:Watch task will remain running and automatically check files as they get saved!