diff --git a/README.md b/README.md index 7bddc25..3012ef5 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,17 @@ meteor-boilerplate adds these meteor core packages by default: ##Deployment with Docker This package includes a basic dockerfile for deploying built versions of your application. More instructions and development on this feature to come. -##Coding Standards -This boilerplate includes a `gulpfile.js` that includes a `cs` task that runs jscs and jshint on your codebase. All you have to do is run `gulp cs` in the project root, and you'll get a full report on all the coding standards issues in your project. +## Coding Standards +This project contains multiple tools for enforcing coding standards and checking for errors within the codebase. The standards are defined in the `.jscsrc` and `.jshintrc` files in the project root. + +### Installation + +* Change directory to the crowd.work directory, like: `cd /path/to/project` +* Run `npm install` to retrieve dependencies. + +### Checking + +To check your local codebase, run `gulp cs` from a console in the project root. An error report, if any, will be generated in the console. ##Folder Structure The /client, /server, and /lib folders provide some basic app structure that I've found to be useful: diff --git a/gulpfile.js b/gulpfile.js index c880b48..eba3dcf 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,19 +6,42 @@ var gulp = require('gulp'), jshint = require('gulp-jshint'), - jscs = require('gulp-jscs'); + jscs = require('gulp-jscs'), + jsonlint = require("gulp-jsonlint"), + runSequence = require('run-sequence'); /** - * @task lint + * @task JavaScript and JSON coding standards. + * Executes lint and style checkers on project JavaScript and JSON. + */ +gulp.task('cs', function (callback) { + runSequence('lintjson', 'lintjs', callback); +}); + +/** + * @task JSON lint. + * Checks JSON configuration files for errors. + */ +gulp.task('lintjson', function () { + return gulp.src([ + '.jscsrc', + '.jshintrc' + ]) + .pipe(jsonlint()) + .pipe(jsonlint.reporter()); +}); + +/** + * @task JavaScript lint. * Runs JSCS and JSLint on module, theme, and gulp files. Excludes all * minified JavaScript files. */ -gulp.task('cs', function () { +gulp.task('lintjs', function () { return gulp.src([ + 'gulpfile.js', 'src/**/*.js', - 'gulpfile.js' '!src/.meteor/**/*.js', - '!src/packages/**/*.js', + '!src/packages/**/*.js' ]) .pipe(jshint()) .pipe(jshint.reporter('default')) diff --git a/package.json b/package.json index 574f8cd..c4e0c15 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,8 @@ "devDependencies": { "gulp": "~3.8.10", "gulp-jscs": "^1.3.1", - "gulp-jshint": "^1.6.2" + "gulp-jshint": "^1.6.2", + "gulp-jsonlint": "^1.0.2", + "run-sequence": "^1.0.2" } }