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

@ -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() {

View File

@ -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",