Skip to content

Commit

Permalink
Enable jshint
Browse files Browse the repository at this point in the history
  • Loading branch information
Tzu-Lin Huang committed May 26, 2015
1 parent 99fafac commit abb177f
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"browser": true,
"globalstrict": true
}
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# RollingSpider
Rolling Spider remote controller app for FxOS

bower install
# Build

```sh
$> npm install
$> bower install
```

# Enable JS syntax linter and make it lint-as-you-save
```sh
$> gulp
```

50 changes: 50 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
'use strict';
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var notify = require('gulp-notify');
var map = require('map-stream');
var events = require('events');
var emmitter = new events.EventEmitter();
var path = require('path');


var jsHintErrorReporter = map(function (file, cb) {
if (!file.jshint.success) {
file.jshint.results.forEach(function (err) {
if (err) {
//console.log(err);

// Error message
var msg = [
path.basename(file.path),
'Line: ' + err.error.line,
'Reason: ' + err.error.reason
];

// Emit this error event
emmitter.emit('error', new Error(msg.join('\n')));

}
});

}
cb(null, file);
});

gulp.task('jshint', function() {
gulp.src('js/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jsHintErrorReporter)
.on('error', notify.onError(function (error) {
return error.message;
}));
});

gulp.task('watch', function() {
gulp.watch('js/**/*.js', ['jshint']);
});

gulp.task('default', ['jshint'], function () {
gulp.start('watch');
});
4 changes: 2 additions & 2 deletions js/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* global console, VirtualJoystick, RollingSpiderHelper */
'use strict';

window.addEventListener('resize', function ResizeHandler() {
Expand Down Expand Up @@ -151,5 +152,4 @@ function init(clientWidth, clientHeight) {
'fsCutOff'].forEach(function(eventName){
rsHelper.on(eventName, flyingStatusHandler.bind(this, eventName));
});

};
}
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "fxos-rolling-spider",
"version": "1.0.0",
"description": "Rolling Spider Control App for Firefox OS",
"repository": {
"type": "git",
"url": "https://github.com/weilonge/RollingSpider.git"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/weilonge/RollingSpider/issues"
},
"homepage": "https://github.com/weilonge/RollingSpider#readme",
"devDependencies": {
"gulp": "^3.8.11",
"gulp-jshint": "^1.11.0",
"gulp-notify": "^2.2.0",
"jshint-stylish": "^2.0.0",
"map-stream": "0.0.5",
"path": "^0.11.14"
}
}

0 comments on commit abb177f

Please sign in to comment.