switch to jscs and jshint with a google style flavor

This commit is contained in:
Doug Fritz 2014-09-03 18:25:36 -07:00
parent 6a017031c6
commit b536c15b1d
4 changed files with 59 additions and 14 deletions

19
.jscsrc Normal file
View File

@ -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/**"
]
}

13
.jshintrc Normal file
View File

@ -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
}

View File

@ -3,7 +3,9 @@ var gulp = require('gulp'),
nib = require('nib'), nib = require('nib'),
fs = require('fs'), fs = require('fs'),
marked = require('marked'), marked = require('marked'),
karma = require('karma'); karma = require('karma'),
browserSync = require('browser-sync'),
reload = browserSync.reload;
gulp.task('default', ['docs', 'build']); gulp.task('default', ['docs', 'build']);
@ -19,6 +21,7 @@ gulp.task('watch', ['default'], function() {
gulp.watch(['elements/**/*.styl', 'elements/**/*.html', gulp.watch(['elements/**/*.styl', 'elements/**/*.html',
'elements/**/*.js', 'gui.html'], ['build']); 'elements/**/*.js', 'gui.html'], ['build']);
gulp.watch(['README.md', 'docs/*'], ['docs']); gulp.watch(['README.md', 'docs/*'], ['docs']);
}); });
@ -27,8 +30,8 @@ gulp.task('build', ['vulcanize'], function() {
return gulp.src('build/gui.html') return gulp.src('build/gui.html')
.pipe($.replace(/\\/g, '\\\\')) .pipe($.replace(/\\/g, '\\\\'))
.pipe($.replace(/'/g, "\\'")) .pipe($.replace(/'/g, '\\\''))
.pipe($.replace(/^(.*)$/gm, "'$1',")) .pipe($.replace(/^(.*)$/gm, '\'$1\','))
.pipe($.insert.wrap('document.write([', '].join("\\n"))')) .pipe($.insert.wrap('document.write([', '].join("\\n"))'))
.pipe(rename('gui.js')) .pipe(rename('gui.js'))
.pipe(gulp.dest('build')); .pipe(gulp.dest('build'));
@ -46,12 +49,17 @@ gulp.task('vulcanize', ['css'], function() {
}); });
gulp.task('jscs', function() {
return gulp.src('elements/**/*.js')
.pipe($.jscs());
});
gulp.task('lint', function() { gulp.task('lint', function() {
return gulp.src('elements/**/*.js') return gulp.src('elements/**/*.js')
//.pipe($.reload({stream: true, once: true})) .pipe(reload({stream: true, once: true}))
.pipe($.gjslint()) .pipe($.jshint())
.pipe($.gjslint.reporter('console', {})); .pipe($.jshint.reporter('jshint-stylish'))
//.pipe($.if(!browserSync.active, $.gjslint.reporter('fail'))); .pipe($.if(!browserSync.active, $.jshint.reporter('fail')));
}); });
gulp.task('css', function() { gulp.task('css', function() {

View File

@ -2,17 +2,22 @@
"name": "dat.gui", "name": "dat.gui",
"version": "0.0.0", "version": "0.0.0",
"devDependencies": { "devDependencies": {
"browser-sync": "^1.3.6",
"gulp": "^3.8.7", "gulp": "^3.8.7",
"gulp-clean": "^0.3.1", "gulp-clean": "^0.3.1",
"gulp-gjslint": "^0.1.2", "gulp-if": "^1.2.4",
"gulp-insert": "^0.4.0", "gulp-insert": "^0.4.0",
"gulp-jscs": "^1.1.2",
"gulp-jshint": "^1.8.4",
"gulp-load-plugins": "^0.6.0", "gulp-load-plugins": "^0.6.0",
"gulp-plates": "0.0.5", "gulp-plates": "0.0.5",
"gulp-reload": "0.0.4",
"gulp-rename": "^1.2.0", "gulp-rename": "^1.2.0",
"gulp-replace": "^0.4.0", "gulp-replace": "^0.4.0",
"gulp-stylus": "^1.3.0", "gulp-stylus": "^1.3.0",
"gulp-vulcanize": "^1.0.0", "gulp-vulcanize": "^1.0.0",
"gulp-watch": "^0.6.9", "gulp-watch": "^0.6.9",
"jshint-stylish": "^0.4.0",
"karma": "^0.12.23", "karma": "^0.12.23",
"karma-chrome-launcher": "^0.1.4", "karma-chrome-launcher": "^0.1.4",
"karma-jasmine": "^0.1.5", "karma-jasmine": "^0.1.5",