Skip to content

Commit

Permalink
feat(jshint): major jshint improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
meriadec committed Mar 5, 2015
1 parent 12b55b2 commit 3623e9b
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 52 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* **NO** support for outdated browsers — *Working for IE users? Too bad.*
* **NO** pre-install for Google Analytics — *Wanna track people? Do it yourself.*
* **Livereload** on changes in client / server — *You don't have time to waste.*
* **JSHint** integration — *Write clean code, for purpose.*
* **JSHint** & **JSCS** integration — *Write clean code, for purpose.*
* **Sass** support — *Because CSS is a mess.*
* **Fast build***You do faster? Let's see that.*

Expand Down Expand Up @@ -57,7 +57,7 @@ Launch client and server tests, using Karma and Mocha, both by default.

gulp control

Validate the app through JSHint.
Validate the app through [JSHint](http://jshint.com/) and [JSCS](http://jscs.info/).

gulp bump [--major || --minor || --patch]

Expand Down
61 changes: 61 additions & 0 deletions app/templates/#.jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"disallowEmptyBlocks": true,
"disallowKeywords": ["with"],
"disallowMixedSpacesAndTabs": true,
"disallowMultipleLineBreaks": true,
"disallowOperatorBeforeLineBreak": ["+", "."],
"disallowQuotedKeysInObjects": true,
"disallowSpaceAfterObjectKeys": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowSpaceBeforePostfixUnaryOperators": true,
"disallowSpacesInCallExpression": true,
"disallowSpacesInsideParentheses": true,
"disallowTrailingComma": true,
"disallowTrailingWhitespace": true,
"disallowYodaConditions": true,
"requireBlocksOnNewline": 1,
"requireCommaBeforeLineBreak": true,
"requireCurlyBraces": true,
"requireDotNotation": true,
"requireLineBreakAfterVariableAssignment": true,
"requireLineFeedAtFileEnd": true,
"requireParenthesesAroundIIFE": true,
"requireSpaceAfterBinaryOperators": true,
"requireSpaceAfterKeywords": true,
"requireSpaceAfterLineComment": true,
"requireSpaceBeforeBinaryOperators": true,
"requireSpaceBeforeBlockStatements": true,
"requireSpaceBeforeKeywords": [
"else",
"while",
"catch"
],
"requireSpaceBeforeObjectValues": true,
"requireSpaceBetweenArguments": true,
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInConditionalExpression": true,
"requireSpacesInForStatement": true,
"requireSpacesInFunctionDeclaration": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInFunction": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true,
"beforeOpeningCurlyBrace": true
},
"requireSpacesInsideObjectBrackets": "all",
"validateIndentation": 2,
"validateParameterSeparator": ", ",
"validateQuoteMarks": "'"
}
15 changes: 15 additions & 0 deletions app/templates/#.jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"bitwise": true,
"eqeqeq": true,
"forin": true,
"freeze": true,
"globalstrict": true,
"latedef": true,
"laxbreak": true,
"maxdepth": 3,
"nonbsp": true,
"nonew": false,
"strict": true,
"undef": true,
"unused": true
}
42 changes: 0 additions & 42 deletions app/templates/.jshintrc

This file was deleted.

19 changes: 19 additions & 0 deletions app/templates/client/.jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"browser": true,
"globals": {
"angular": true,
"browser": true,
"element": true,
"by": true,
"module": true,
"console": true,
"it": true,
"describe": true,
"inject": true,
"expect": true,
"alert": true,
"afterEach": true,
"beforeEach": true<% if (filters.sockets) { %>,
"io" : true<% } %>
}
}
39 changes: 31 additions & 8 deletions app/templates/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ var bowerFiles = require('main-bower-files');
var runSequence = require('run-sequence');
var sq = require('streamqueue');
var path = require('path');
var async = require('async');
var _ = require('lodash');
var fs = require('fs');
var karma = require('karma').server;
var $ = require('gulp-load-plugins')();
Expand Down Expand Up @@ -128,14 +130,35 @@ gulp.task('watch', ['inject'], function () {
/**
* Control things
*/
gulp.task('control', function () {
return gulp.src([
'client/**/**/*.js',
'server/**/**/*.js',
'!client/bower_components/**'
])
.pipe($.jshint())
.pipe($.jshint.reporter('default'));
gulp.task('control', function (done) {

function getConfig (file) {
return _.merge(
JSON.parse(fs.readFileSync('./.jshintrc', 'utf-8')),
JSON.parse(fs.readFileSync(file, 'utf-8'))
);
}

function control (name, paths, conf) {
return function (done) {
gulp.src(paths)
.pipe($.jshint(conf))
.pipe($.jshint.reporter('jshint-stylish'))
.on('finish', function () {
gulp.src(paths)
.pipe($.jscs())
.on('error', function () {})
.pipe($.jscsStylish())
.on('end', done);
});
};
}

async.series([
control('client', ['client/**/*.js', '!client/bower_components/**'], getConfig('./client/.jshintrc')),
control('server', ['server/**/*.js'], getConfig('./server/.jshintrc'))
], done);

});


Expand Down
4 changes: 4 additions & 0 deletions app/templates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"gulp-concat": "^2.4.3",
"gulp-git": "^1.0.0",
"gulp-inject": "^1.1.1",
"gulp-jscs": "^1.4.0",
"gulp-jscs-stylish": "1.0.0",
"gulp-jshint": "^1.9.1",
"gulp-livereload": "^3.6.0",
"gulp-load-plugins": "^0.8.0",
Expand All @@ -28,6 +30,7 @@
"gulp-util": "^3.0.2",
"gulp-wait": "^0.0.2",
"gulp-watch": "^4.1.0",
"jshint-stylish": "^1.0.1",
"karma": "^0.12.31",
"karma-jasmine": "^0.3.5",
"karma-ng-html2js-preprocessor": "^0.1.2",
Expand All @@ -37,6 +40,7 @@
"streamqueue": "^0.1.2"
},
"dependencies": {
"async": "^0.9.0",
"body-parser": "^1.11.0",
"chalk": "^1.0.0",<% if (filters.auth) { %>
"composable-middleware": "^0.3.0",<% } %>
Expand Down
9 changes: 9 additions & 0 deletions app/templates/server/.jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"node": true,
"globals": {
"describe": true,
"it": true,
"afterEach": true,
"beforeEach": true
}
}

0 comments on commit 3623e9b

Please sign in to comment.