diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..367d6e3 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,19 @@ +{ + "env" : { + "node": true, + "browser": true + }, + "globals": { + "$": true + }, + "rules" : { + "quotes": false, + "space-after-keywords": [2, "always", {"checkFunctionKeyword": true}], + "space-before-blocks": [2, "always"], + "brace-style": [2, "1tbs", { "allowSingleLine": false}], + "spaced-line-comment": [2, "always"], + "radix": [2, "always"], + "key-spacing": [2, "always", {"beforeColon": false, "afterColon": true}], + "no-multiple-empty-lines": [2, {max: 1}], + } +} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 80cb452..0000000 --- a/.jshintrc +++ /dev/null @@ -1,61 +0,0 @@ -{ - "passfail" : false, - "maxerr" : 100, - - "browser" : true, - - "node" : true, - "rhino" : false, - "couch" : false, - "wsh" : false, - - "jquery" : true, - "prototypejs" : false, - "mootools" : false, - "dojo" : false, - - "predef" : [ - "require", - "define" - ], - - "debug" : false, - "devel" : true, - - "strict" : true, - "globalstrict" : false, - - "asi" : false, - "laxbreak" : false, - "bitwise" : false, - "boss" : false, - "curly" : true, - "eqeqeq" : true, - "eqnull" : false, - "evil" : false, - "expr" : false, - "forin" : false, - "immed" : true, - "latedef" : true, - "loopfunc" : false, - "noarg" : true, - "regexp" : true, - "regexdash" : false, - "scripturl" : true, - "shadow" : false, - "supernew" : false, - "undef" : true, - - "newcap" : true, - "noempty" : false, - "nonew" : true, - "nomen" : false, - "onevar" : false, - "plusplus" : false, - "sub" : false, - "trailing" : true, - "white" : true, - "indent" : 2, - "laxcomma" : true, - "camelcase" : true -} diff --git a/gulpfile.js b/gulpfile.js index 3c85ca5..d3422e5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,7 +4,7 @@ var gulp = require('gulp') , browserify = require('browserify') , bump = require('gulp-bump') , connect = require('gulp-connect') - , jshint = require('gulp-jshint') + , eslint = require('gulp-eslint') , rename = require('gulp-rename') , rimraf = require('gulp-rimraf') , sass = require('gulp-sass') @@ -13,8 +13,9 @@ var gulp = require('gulp') gulp.task('lint', function () { return gulp.src(['./src/**/*.js', './gulpfile.js']) - .pipe(jshint()) - .pipe(jshint.reporter('default')); + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failOnError()); }); gulp.task('clean:js', function () { diff --git a/package.json b/package.json index e8fc920..dd3adcf 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "gulp": "^3.8.10", "gulp-bump": "^0.1.11", "gulp-connect": "^2.2.0", - "gulp-jshint": "^1.9.0", + "gulp-eslint": "^0.2.0", "gulp-rename": "^1.2.0", "gulp-rimraf": "^0.1.1", "gulp-sass": "^1.3.1", diff --git a/src/js/lib/guid.js b/src/js/lib/guid.js index 1f27e08..bd9034e 100644 --- a/src/js/lib/guid.js +++ b/src/js/lib/guid.js @@ -3,13 +3,13 @@ */ 'use strict'; -module.exports = (function() { +module.exports = (function () { function s4() { return Math.floor((1 + Math.random()) * 0x10000) .toString(16) .substring(1); } - return function() { + return function () { return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); }; diff --git a/src/js/plugin/default-setting.js b/src/js/plugin/default-setting.js index 4e2b174..86eaf3e 100644 --- a/src/js/plugin/default-setting.js +++ b/src/js/plugin/default-setting.js @@ -14,5 +14,5 @@ module.exports = { suppressScrollX: false, suppressScrollY: false, scrollXMarginOffset: 0, - scrollYMarginOffset: 0, + scrollYMarginOffset: 0 }; diff --git a/src/js/plugin/destroy.js b/src/js/plugin/destroy.js index a1fb1b8..664d61d 100644 --- a/src/js/plugin/destroy.js +++ b/src/js/plugin/destroy.js @@ -3,8 +3,7 @@ */ 'use strict'; -var cls = require('../lib/class') - , d = require('../lib/dom') +var d = require('../lib/dom') , h = require('../lib/helper') , instances = require('./instances'); diff --git a/src/js/plugin/initialize.js b/src/js/plugin/initialize.js index 1d302c3..a111b7e 100644 --- a/src/js/plugin/initialize.js +++ b/src/js/plugin/initialize.js @@ -63,7 +63,7 @@ module.exports = function (element, userSettings) { e.preventDefault(); }; - var mouseUpHandler = function (e) { + var mouseUpHandler = function () { cls.remove(element, 'ps-x'); cls.remove(element, 'ps-in-scrolling'); $(i.ownerDocument).unbind(i.eventClass('mousemove'), mouseMoveHandler); @@ -97,7 +97,7 @@ module.exports = function (element, userSettings) { e.preventDefault(); }; - var mouseUpHandler = function (e) { + var mouseUpHandler = function () { cls.remove(element, 'ps-y'); cls.remove(element, 'ps-in-scrolling'); $(i.ownerDocument).unbind(i.eventClass('mousemove'), mouseMoveHandler); @@ -253,10 +253,10 @@ module.exports = function (element, userSettings) { function bindKeyboardHandler() { var hovered = false; - $(element).bind(i.eventClass('mouseenter'), function (e) { + $(element).bind(i.eventClass('mouseenter'), function () { hovered = true; }); - $(element).bind(i.eventClass('mouseleave'), function (e) { + $(element).bind(i.eventClass('mouseleave'), function () { hovered = false; }); @@ -331,7 +331,7 @@ module.exports = function (element, userSettings) { } function bindRailClickHandler() { - function stopPropagation(e) { e.stopPropagation(); } + var stopPropagation = window.Event.prototype.stopPropagation.bind; $(i.scrollbarY).bind(i.eventClass('click'), stopPropagation); $(i.scrollbarYRail).bind(i.eventClass('click'), function (e) { @@ -403,7 +403,7 @@ module.exports = function (element, userSettings) { } var isSelected = false; - $(i.ownerDocument).bind(i.eventClass('selectionchange'), function (e) { + $(i.ownerDocument).bind(i.eventClass('selectionchange'), function () { if ($.contains(element, getRangeNode())) { isSelected = true; } else { @@ -411,7 +411,7 @@ module.exports = function (element, userSettings) { stopScrolling(); } }); - $(window).bind(i.eventClass('mouseup'), function (e) { + $(window).bind(i.eventClass('mouseup'), function () { if (isSelected) { isSelected = false; stopScrolling(); @@ -480,10 +480,10 @@ module.exports = function (element, userSettings) { var inGlobalTouch = false; var inLocalTouch = false; - function globalTouchStart(e) { + function globalTouchStart() { inGlobalTouch = true; } - function globalTouchEnd(e) { + function globalTouchEnd() { inGlobalTouch = false; } @@ -550,7 +550,7 @@ module.exports = function (element, userSettings) { } } } - function touchEnd(e) { + function touchEnd() { if (!inGlobalTouch && inLocalTouch) { inLocalTouch = false; @@ -600,7 +600,7 @@ module.exports = function (element, userSettings) { } function bindScrollHandler() { - $(element).bind(i.eventClass('scroll'), function (e) { + $(element).bind(i.eventClass('scroll'), function () { updateGeometry(element); }); }