From b6f843b802a61c40a953f099ff2d7ec3c4207793 Mon Sep 17 00:00:00 2001 From: tkqubo Date: Tue, 8 Sep 2015 05:20:46 +0900 Subject: [PATCH] Add gulp-coffeelint --- gulp-coffeelint/gulp-coffeelint-tests.ts | 57 ++++++++++++++++++++++++ gulp-coffeelint/gulp-coffeelint.d.ts | 26 +++++++++++ 2 files changed, 83 insertions(+) create mode 100644 gulp-coffeelint/gulp-coffeelint-tests.ts create mode 100644 gulp-coffeelint/gulp-coffeelint.d.ts diff --git a/gulp-coffeelint/gulp-coffeelint-tests.ts b/gulp-coffeelint/gulp-coffeelint-tests.ts new file mode 100644 index 000000000..0022f9888 --- /dev/null +++ b/gulp-coffeelint/gulp-coffeelint-tests.ts @@ -0,0 +1,57 @@ +/// +/// + +import coffeelint = require('gulp-coffeelint'); +import gulp = require('gulp'); + + +gulp.task('lint', function () { + gulp.src('./src/*.coffee') + .pipe(coffeelint()) + .pipe(coffeelint.reporter()) +}); + +gulp.src('./src/*.coffee') + .pipe(coffeelint()) + .pipe(coffeelint.reporter('csv')); + + +declare var stylish: Function; + +gulp.src('./src/*.coffee') + .pipe(coffeelint()) + .pipe(coffeelint.reporter(stylish)); + +gulp.src('./src/*.coffee') + .pipe(coffeelint()) + .pipe(coffeelint.reporter('coffelint-stylish')); + +gulp.src('./src/*.coffee') + .pipe(coffeelint()) + .pipe(coffeelint.reporter('coffeelint-stylish')) + .pipe(coffeelint.reporter('fail')); + +var myReporter = (function() { + function MyReporter(errorReport: any) { + this.errorReport = errorReport; + } + + MyReporter.prototype.publish = function() { + var hasError = this.errorReport.hasError(); + if (hasError) { + return console.log('Oh no!'); + } + return console.log('Oh yeah!'); + }; + + return MyReporter; +})(); + +gulp.task('lint', function() { + return gulp.src('./src/*.coffee') + .pipe(coffeelint()) + .pipe(coffeelint.reporter(myReporter)); +}); + + + diff --git a/gulp-coffeelint/gulp-coffeelint.d.ts b/gulp-coffeelint/gulp-coffeelint.d.ts new file mode 100644 index 000000000..2b686574c --- /dev/null +++ b/gulp-coffeelint/gulp-coffeelint.d.ts @@ -0,0 +1,26 @@ +// Type definitions for gulp-coffeelint +// Project: https://github.com/janraasch/gulp-coffeelint +// Definitions by: Qubo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "gulp-coffeelint" { + namespace coffeelint { + interface Coffeelint { + /** + * @param optFile Absolute path of a json file containing options for coffeelint. + * @param opt Options you wish to send to coffeelint. If optFile is given, this will be ignored. + * @param literate Are we dealing with Literate CoffeeScript? + * @param rules Add custom rules to coffeelint. + */ + (optFile?: string, opt?: any, literate?: boolean, rules?: Function[]): NodeJS.ReadWriteStream; + reporter(reporter?: string|Function): NodeJS.ReadWriteStream; + } + } + + var coffeelint: coffeelint.Coffeelint; + + export = coffeelint; +} +