From 466af18058ecda652ee0ad2e8e2bd56074df1aea Mon Sep 17 00:00:00 2001 From: Gunther Brunner Date: Thu, 14 Jan 2016 21:20:54 +0900 Subject: [PATCH] Add eslint task. Needs eslintrc tweaking. --- .eslintrc | 2 +- gulpfile.js | 23 +++++++++++++++++++++++ lib/db/api.js | 2 +- lib/util/streamutil.js | 2 +- package.json | 1 + 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/.eslintrc b/.eslintrc index 40f3f90e..e6fee7a0 100644 --- a/.eslintrc +++ b/.eslintrc @@ -6,7 +6,7 @@ "comma-style": [2, "first"], "no-extra-semi": 2, "no-underscore-dangle": 0, - "quotes": [2, "single"], + "quotes": [2, "single", "avoid-escape"], "semi": [2, "never"], "space-before-blocks": [2, "always"], "strict": [0, "function"] diff --git a/gulpfile.js b/gulpfile.js index 1ae034cb..4e2df385 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,6 +4,7 @@ var gulp = require('gulp') var gutil = require('gulp-util') var jshint = require('gulp-jshint') var jsonlint = require('gulp-jsonlint') +var eslint = require('gulp-eslint') var standard = require('gulp-standard') var webpack = require('webpack') var webpackConfig = require('./webpack.config').webpack @@ -46,6 +47,28 @@ gulp.task('jsonlint', function () { .pipe(jsonlint.reporter()) }) +gulp.task('eslint', function () { + return gulp.src([ + 'lib/**/*.js' + , 'res/app/**/*.js' + , 'res/auth-ldap/**/*.js' + , 'res/auth-mock/**/*.js' + , 'res/common/**/*.js' + , 'res/test/**/*.js' + , '*.js' + , '!node_modules/**' + ]) + // eslint() attaches the lint output to the "eslint" property + // of the file object so it can be used by other modules. + .pipe(eslint()) + // eslint.format() outputs the lint results to the console. + // Alternatively use eslint.formatEach() (see Docs). + .pipe(eslint.format()) + // To have the process exit with an error code (1) on + // lint error, return the stream and pipe to failAfterError last. + .pipe(eslint.failAfterError()); +}); + gulp.task('jscs', function () { return gulp.src([ 'lib/**/*.js' diff --git a/lib/db/api.js b/lib/db/api.js index ed2cd6b4..1979d05a 100644 --- a/lib/db/api.js +++ b/lib/db/api.js @@ -320,7 +320,7 @@ dbapi.saveUserAccessToken = function(email, token) { dbapi.removeUserAccessToken = function(email, title) { return db.run(r.table('accessTokens').getAll(email, { index: 'email' - }).filter({"title": title}).delete()) + }).filter({'title': title}).delete()) } dbapi.loadAccessTokens = function(email) { diff --git a/lib/util/streamutil.js b/lib/util/streamutil.js index de2f54a8..8b11bc2a 100644 --- a/lib/util/streamutil.js +++ b/lib/util/streamutil.js @@ -26,7 +26,7 @@ module.exports.readAll = function(stream) { } function readableListener() { - var chunk; + var chunk while ((chunk = stream.read())) { collected = Buffer.concat([collected, chunk]) } diff --git a/package.json b/package.json index e619f5f7..8c3610e9 100644 --- a/package.json +++ b/package.json @@ -95,6 +95,7 @@ "file-loader": "^0.8.5", "gulp": "^3.8.11", "gulp-angular-gettext": "^2.1.0", + "gulp-eslint": "^1.1.1", "gulp-jade": "^1.0.0", "gulp-jscs": "^3.0.2", "gulp-jshint": "^1.12.0",