From 8fac1e10174d4cc6137f11ff2de57c516664a258 Mon Sep 17 00:00:00 2001 From: Erich Gamma Date: Thu, 14 Jan 2016 17:53:55 +0100 Subject: [PATCH] Integrated tslint --- .vscode/tasks.json | 19 +++++++++++++++++++ build/gulpfile.hygiene.js | 35 +++++++++++++++++++++++++++++++++++ package.json | 2 ++ tslint.json | 5 +++++ 4 files changed, 61 insertions(+) create mode 100644 tslint.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json index bdfc0cff0c6..78d287a1677 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -25,6 +25,25 @@ } } }, + { + "taskName": "tslint", + "args": [], + "problemMatcher": { + "owner": "tslint", + "fileLocation": [ + "relative", + "${workspaceRoot}" + ], + "severity": "warning", + "pattern": { + "regexp": "^\\[tslint\\] (.*):(\\d+):(\\d+):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "message": 4 + } + } + }, { "taskName": "test", "args": [ diff --git a/build/gulpfile.hygiene.js b/build/gulpfile.hygiene.js index 2d12721673f..fd9abab3bbc 100644 --- a/build/gulpfile.hygiene.js +++ b/build/gulpfile.hygiene.js @@ -7,6 +7,7 @@ var gulp = require('gulp'); var filter = require('gulp-filter'); var es = require('event-stream'); var path = require('path'); +var tslint = require("gulp-tslint"); var all = [ '*', @@ -138,6 +139,40 @@ gulp.task('hygiene', function () { return hygiene(); }); +var allTypeScript = [ + 'src/**/*.ts', + 'extensions/**/*.ts' +]; + +var tslintFilter = [ + '**', + '!**/*.d.ts', + '!**/typings/**', + '!**/*.test.ts', + '!src/vs/editor/standalone-languages/test/**' +]; + +const lintReporter = function (output, file, options) { + //emits: src/helloWorld.c:5:3: warning: implicit declaration of function ‘prinft’ + var relativeBase = file.base.substring(file.cwd.length + 1); + output.forEach(function(e) { + var message = relativeBase + e.name + ':' + (e.startPosition.line + 1) + ':' + (e.startPosition.character + 1) + ': ' + e.failure; + console.log('[tslint] ' + message); + }); +}; + +gulp.task('tslint', function () { + gulp.src(allTypeScript) + .pipe(filter(tslintFilter)) + .pipe(tslint({ + rulesDirectory: "node_modules/tslint-microsoft-contrib" + })) + .pipe(tslint.report(lintReporter, { + summarizeFailureOutput: false, + emitError: false + })) +}); + // this allows us to run this as a git pre-commit hook if (require.main === module) { var cp = require('child_process'); diff --git a/package.json b/package.json index a94f9838be4..0da39b9be63 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,8 @@ "gulp-util": "^3.0.6", "gulp-vinyl-zip": "^1.1.0", "gulp-watch": "^4.2.4", + "gulp-tslint": "^4.3.0", + "tslint-microsoft-contrib": "^2.0.0", "innosetup-compiler": "^5.5.60", "istanbul": "^0.3.17", "jsdom-no-contextify": "^3.1.0", diff --git a/tslint.json b/tslint.json new file mode 100644 index 00000000000..1092f728939 --- /dev/null +++ b/tslint.json @@ -0,0 +1,5 @@ +{ + "rules": { + "no-unused-variable": true + } +} \ No newline at end of file