From dff149a63e80dad707312da15af9be9914bdcc41 Mon Sep 17 00:00:00 2001 From: Hendrik Leppelsack Date: Wed, 9 Mar 2016 11:13:16 +0100 Subject: add better js linting --- .eslintrc.json | 24 ++++++++++++++++++++++++ .jshintrc | 3 --- gulpfile.js | 19 ++++++++++++++++--- package.json | 2 +- 4 files changed, 41 insertions(+), 7 deletions(-) create mode 100644 .eslintrc.json delete mode 100644 .jshintrc diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 00000000..45b46f4c --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,24 @@ +{ + "extends": "eslint:recommended", + "rules": { + "no-undef": "off", + "no-unused-vars": "off", + + "eqeqeq": ["warn", "smart"], + "no-console": "warn", + "no-loop-func": "warn", + + "block-spacing": "error", + "camelcase": "error", + "comma-spacing": "error", + "comma-style": "error", + "curly": ["error", "multi-line", "consistent"], + "indent": ["error", "tab"], + "no-alert": "error", + "no-trailing-spaces": "error", + "quotes": ["error", "single", "avoid-escape"], + "semi": "error", + "space-before-blocks": "error" + + } +} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index c44dc44f..00000000 --- a/.jshintrc +++ /dev/null @@ -1,3 +0,0 @@ -[ - -] \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 852a627b..7f262af4 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,6 +1,6 @@ var gulp = require('gulp'), concat = require('gulp-concat'), - jshint = require('gulp-jshint'); + eslint = require('gulp-eslint'); gulp.task('js', function() { return gulp.src([ @@ -10,12 +10,25 @@ gulp.task('js', function() { 'js/services/**/*.js', 'js/filters/**/*.js' ]) - .pipe(jshint('.jshintrc')) - .pipe(jshint.reporter('default')) + .pipe(eslint()) + .pipe(eslint.format()) .pipe(concat('script.js')) .pipe(gulp.dest('js/public')); }); +gulp.task('eslint', function() { + return gulp.src([ + 'js/main.js', + 'js/components/**/*.js', + 'js/models/**/*.js', + 'js/services/**/*.js', + 'js/filters/**/*.js' + ]) + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failAfterError()); +}) + gulp.task('watch', ['js'], function() { gulp.watch('js/**/*.js', ['js']); }); diff --git a/package.json b/package.json index cb835f33..c820cbc5 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,6 @@ "devDependencies": { "gulp": "^3.9.0", "gulp-concat": "^2.6.0", - "gulp-jshint": "^1.11.2" + "gulp-eslint": "^2.0.0" } } -- cgit v1.2.3