提交 cb0588a4 编写于 作者: J Joao Moreno

Merge branch 'enable-tslint'

......@@ -12,5 +12,6 @@
".build/**": true,
"out*/**": true,
"extensions/**/out/**": true
}
},
"tslint.rulesDirectory": "node_modules/tslint-microsoft-contrib"
}
\ No newline at end of file
......@@ -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": [
......
......@@ -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 = [
'*',
......@@ -55,7 +56,7 @@ var indentationFilter = [
'!extensions/**/themes/**',
];
var copyrightFilterList = [
var copyrightFilter = [
'**',
'!**/*.json',
'!**/*.html',
......@@ -69,6 +70,15 @@ var copyrightFilterList = [
'!src/vs/editor/standalone-languages/swift.ts',
];
var tslintFilter = [
'src/**/*.ts',
'extensions/**/*.ts',
'!**/*.d.ts',
'!**/typings/**',
'!**/*.test.ts',
'!src/vs/editor/standalone-languages/test/**'
];
var copyrightHeader = [
'/*---------------------------------------------------------------------------------------------',
' * Copyright (c) Microsoft Corporation. All rights reserved.',
......@@ -76,6 +86,28 @@ var copyrightHeader = [
' *--------------------------------------------------------------------------------------------*/'
].join('\n');
/**
* Reports tslint erros in the format:
* src/helloWorld.c:5:3: warning: implicit declaration of function ‘prinft’
*/
var lintReporter = function (output, file, options) {
var relativeBase = file.base.substring(file.cwd.length + 1).replace('\\', '/');
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 () {
return gulp.src(all, { base: '.' })
.pipe(filter(tslintFilter))
.pipe(tslint({ rulesDirectory: 'node_modules/tslint-microsoft-contrib' }))
.pipe(tslint.report(lintReporter, {
summarizeFailureOutput: false,
emitError: false
}));
});
var hygiene = exports.hygiene = function (some) {
var errorCount = 0;
......@@ -92,7 +124,7 @@ var hygiene = exports.hygiene = function (some) {
file.contents
.toString('utf8')
.split(/\r\n|\r|\n/)
.forEach(function(line, i) {
.forEach(function (line, i) {
if (/^\s*$/.test(line)) {
// empty or whitespace lines are OK
} else if (/^[\t]*[^\s]/.test(line)) {
......@@ -123,7 +155,7 @@ var hygiene = exports.hygiene = function (some) {
.pipe(eol)
.pipe(filter(indentationFilter))
.pipe(indentation)
.pipe(filter(copyrightFilterList))
.pipe(filter(copyrightFilter))
.pipe(copyrights)
.pipe(es.through(null, function () {
if (errorCount > 0) {
......
{
"rules": {
"no-unused-expression": true,
"no-unreachable": true,
"no-duplicate-variable": true
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册