From b536c15b1d3fcedea4d31205b388fa486888a75f Mon Sep 17 00:00:00 2001 From: Doug Fritz Date: Wed, 3 Sep 2014 18:25:36 -0700 Subject: [PATCH] switch to jscs and jshint with a google style flavor --- .jscsrc | 19 +++++++++++++++++++ .jshintrc | 13 +++++++++++++ gulpfile.js | 34 +++++++++++++++++++++------------- package.json | 7 ++++++- 4 files changed, 59 insertions(+), 14 deletions(-) create mode 100644 .jscsrc create mode 100644 .jshintrc diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 0000000..0a13d61 --- /dev/null +++ b/.jscsrc @@ -0,0 +1,19 @@ +{ + "preset": "google", + "fileExtensions": [ ".js" ], + + "requireParenthesesAroundIIFE": true, + "maximumLineLength": 120, + "validateLineBreaks": "LF", + "validateIndentation": 2, + + "disallowKeywords": ["with"], + "disallowSpacesInsideObjectBrackets": null, + "disallowImplicitTypeConversion": ["string"], + + "safeContextKeyword": "_this", + + "excludeFiles": [ + "test/data/**" + ] +} diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..804f8af --- /dev/null +++ b/.jshintrc @@ -0,0 +1,13 @@ +{ + "node": true, + "esnext": true, + "bitwise": true, + "camelcase": true, + "curly": true, + "immed": true, + "newcap": true, + "noarg": true, + "undef": true, + "unused": "vars", + "strict": true +} diff --git a/gulpfile.js b/gulpfile.js index e66e5bd..9440aa4 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,9 +1,11 @@ var gulp = require('gulp'), - $ = require('gulp-load-plugins')(), - nib = require('nib'), - fs = require('fs'), - marked = require('marked'), - karma = require('karma'); + $ = require('gulp-load-plugins')(), + nib = require('nib'), + fs = require('fs'), + marked = require('marked'), + karma = require('karma'), + browserSync = require('browser-sync'), + reload = browserSync.reload; gulp.task('default', ['docs', 'build']); @@ -18,7 +20,8 @@ gulp.task('watch', ['default'], function() { }); gulp.watch(['elements/**/*.styl', 'elements/**/*.html', - 'elements/**/*.js', 'gui.html'], ['build']); + 'elements/**/*.js', 'gui.html'], ['build']); + gulp.watch(['README.md', 'docs/*'], ['docs']); }); @@ -27,8 +30,8 @@ gulp.task('build', ['vulcanize'], function() { return gulp.src('build/gui.html') .pipe($.replace(/\\/g, '\\\\')) - .pipe($.replace(/'/g, "\\'")) - .pipe($.replace(/^(.*)$/gm, "'$1',")) + .pipe($.replace(/'/g, '\\\'')) + .pipe($.replace(/^(.*)$/gm, '\'$1\',')) .pipe($.insert.wrap('document.write([', '].join("\\n"))')) .pipe(rename('gui.js')) .pipe(gulp.dest('build')); @@ -42,16 +45,21 @@ gulp.task('vulcanize', ['css'], function() { dest: 'build', inline: true, strip: true - })); + })); }); +gulp.task('jscs', function() { + return gulp.src('elements/**/*.js') + .pipe($.jscs()); +}); + gulp.task('lint', function() { return gulp.src('elements/**/*.js') - //.pipe($.reload({stream: true, once: true})) - .pipe($.gjslint()) - .pipe($.gjslint.reporter('console', {})); - //.pipe($.if(!browserSync.active, $.gjslint.reporter('fail'))); + .pipe(reload({stream: true, once: true})) + .pipe($.jshint()) + .pipe($.jshint.reporter('jshint-stylish')) + .pipe($.if(!browserSync.active, $.jshint.reporter('fail'))); }); gulp.task('css', function() { diff --git a/package.json b/package.json index b2f944e..ec722de 100644 --- a/package.json +++ b/package.json @@ -2,17 +2,22 @@ "name": "dat.gui", "version": "0.0.0", "devDependencies": { + "browser-sync": "^1.3.6", "gulp": "^3.8.7", "gulp-clean": "^0.3.1", - "gulp-gjslint": "^0.1.2", + "gulp-if": "^1.2.4", "gulp-insert": "^0.4.0", + "gulp-jscs": "^1.1.2", + "gulp-jshint": "^1.8.4", "gulp-load-plugins": "^0.6.0", "gulp-plates": "0.0.5", + "gulp-reload": "0.0.4", "gulp-rename": "^1.2.0", "gulp-replace": "^0.4.0", "gulp-stylus": "^1.3.0", "gulp-vulcanize": "^1.0.0", "gulp-watch": "^0.6.9", + "jshint-stylish": "^0.4.0", "karma": "^0.12.23", "karma-chrome-launcher": "^0.1.4", "karma-jasmine": "^0.1.5",