mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-17 11:50:22 +08:00
Adding a bunch of gulp utilities
This should allow a developer to write a gulpfile in TypeScript to compile a TypeScript project.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
/// <reference path="./gulp-tslint.d.ts"/>
|
||||
/// <reference path="../gulp/gulp.d.ts"/>
|
||||
/// <reference path="../vinyl/vinyl.d.ts"/>
|
||||
import gulp = require("gulp");
|
||||
import tslint = require("gulp-tslint");
|
||||
import vinyl = require("vinyl");
|
||||
|
||||
gulp.task('tslint', function(){
|
||||
gulp.src('source.ts')
|
||||
.pipe(tslint())
|
||||
.pipe(tslint.report('verbose'));
|
||||
});
|
||||
|
||||
/* Output is in the following form:
|
||||
* [{
|
||||
* "name": "invalid.ts",
|
||||
* "failure": "missing whitespace",
|
||||
* // Lines and characters start from 0
|
||||
* "startPosition": {"position": 8, "line": 0, "character": 8},
|
||||
* "endPosition": {"position": 9, "line": 0, "character": 9},
|
||||
* "ruleName": "one-line"
|
||||
* }]
|
||||
*/
|
||||
var testReporter = function (output: tslint.Output[], file: vinyl, options: tslint.Options) {
|
||||
// file is a reference to the vinyl File object
|
||||
console.log("Found " + output.length + " errors in " + file.path);
|
||||
// options is a reference to the reporter options, e.g. options.emitError
|
||||
};
|
||||
|
||||
gulp.task('invalid-custom', function(){
|
||||
gulp.src('invalid.ts')
|
||||
.pipe(tslint())
|
||||
.pipe(tslint.report(testReporter));
|
||||
});
|
||||
|
||||
gulp.task('tslint-json', function(){
|
||||
gulp.src('invalid.ts')
|
||||
.pipe(tslint({
|
||||
configuration: {
|
||||
rules: {
|
||||
"class-name": true
|
||||
// ...
|
||||
}
|
||||
}
|
||||
}))
|
||||
.pipe(tslint.report('prose'));;
|
||||
});
|
||||
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
// Type definitions for gulp-tslint
|
||||
// Project: https://github.com/panuhorsmalahti/gulp-tslint
|
||||
// Definitions by: Asana <https://asana.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts"/>
|
||||
/// <reference path="../vinyl/vinyl.d.ts"/>
|
||||
|
||||
declare module "gulp-tslint" {
|
||||
import vinyl = require("vinyl");
|
||||
|
||||
function GulpTsLint(opts?: GulpTsLint.Options): NodeJS.ReadWriteStream;
|
||||
|
||||
module GulpTsLint {
|
||||
interface Options {
|
||||
configuration?: Object;
|
||||
rulesDirectory?: string;
|
||||
emitError?: boolean;
|
||||
}
|
||||
|
||||
interface Position {
|
||||
position: number;
|
||||
line: number;
|
||||
character: number;
|
||||
}
|
||||
|
||||
interface Output {
|
||||
name: string;
|
||||
failure: string;
|
||||
startPosition: Position;
|
||||
endPosition: Position;
|
||||
ruleName: string;
|
||||
}
|
||||
|
||||
export function report(reporter?: string): NodeJS.ReadWriteStream;
|
||||
export function report(reporter?: (output: Output[], file: vinyl, options: Options) => any): NodeJS.ReadWriteStream;
|
||||
|
||||
}
|
||||
|
||||
export = GulpTsLint;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user