From b69861ecd698a95d89dd5e38011e181771b8fd4d Mon Sep 17 00:00:00 2001 From: Tomasz Szewcow Date: Fri, 25 Sep 2015 08:52:47 +0200 Subject: [PATCH] Issues #6 / #20 resolved: - eslint integrated (rules specified in .eslintrc file, eslint run during gulp test, use gulp lint to run eslint is separation - lint errors in generated tests corrected - jshint support removed --- app/files.json | 2 +- app/templates/.eslintrc | 27 ++++++++++++++++++ app/templates/_.jshintrc | 37 ------------------------- app/templates/gulp/unit-tests.js | 9 +++--- app/templates/package.json | 5 ++-- controller/templates/controller-spec.js | 2 +- controller/templates/controller.js | 3 +- test/generator-app.spec.js | 2 +- 8 files changed, 39 insertions(+), 48 deletions(-) create mode 100644 app/templates/.eslintrc delete mode 100644 app/templates/_.jshintrc diff --git a/app/files.json b/app/files.json index fc0326d..d2f0e1d 100644 --- a/app/files.json +++ b/app/files.json @@ -23,9 +23,9 @@ "app/main/welcome/welcome.tpl.html", "bower.json", "_.bowerrc", - "_.jshintrc", "_.gitignore", "_.editorconfig", + ".eslintrc", "config.json", "gulp/build.js", "gulp/lib/builder-factory.js", diff --git a/app/templates/.eslintrc b/app/templates/.eslintrc new file mode 100644 index 0000000..0576ddd --- /dev/null +++ b/app/templates/.eslintrc @@ -0,0 +1,27 @@ +{ + "rules": { + "quotes": [2, "single"], + "linebreak-style": [2, "windows"], + "semi": [2, "always"], + "strict": 2 + }, + "env": { + "browser": true + }, + "globals": { + "angular": true, + // Angular Mocks + "inject": false, + // JASMINE + "describe": false, + "it": false, + "before": false, + "beforeEach": false, + "after": false, + "afterEach": false, + "expect": false, + "jasmine": false, + "spyOn": false + }, + "extends": "eslint:recommended" +} \ No newline at end of file diff --git a/app/templates/_.jshintrc b/app/templates/_.jshintrc deleted file mode 100644 index efb6bc8..0000000 --- a/app/templates/_.jshintrc +++ /dev/null @@ -1,37 +0,0 @@ -{ - "node": true, - "esnext": true, - "bitwise": true, - "camelcase": true, - "curly": true, - "eqeqeq": true, - "immed": true, - "indent": 2, - "latedef": true, - "newcap": true, - "noarg": true, - "quotmark": "single", - "regexp": true, - "undef": true, - "unused": true, - "strict": true, - "trailing": true, - "smarttabs": true, - "white": true, - "validthis": true, - "globals": { - "angular": false, - // Angular Mocks - "inject": false, - // JASMINE - "describe": false, - "it": false, - "before": false, - "beforeEach": false, - "after": false, - "afterEach": false, - "expect": false, - "jasmine": false, - "spyOn": false - } -} diff --git a/app/templates/gulp/unit-tests.js b/app/templates/gulp/unit-tests.js index dc19152..000800e 100644 --- a/app/templates/gulp/unit-tests.js +++ b/app/templates/gulp/unit-tests.js @@ -3,6 +3,7 @@ var gulp = require('gulp'); var $ = require('gulp-load-plugins')(); +var eslint = require('gulp-eslint'); var createKarmaTask = function (options) { /** * Pass empty array - karma will query for files. @@ -40,7 +41,7 @@ gulp.task('test:tdd:debug', ['ngTemplates'], function () { }); gulp.task('lint', function () { return gulp.src(config.scripts.lintSrc()) - .pipe($.jshint()) - .pipe($.jshint.reporter('jshint-stylish')) - .pipe($.jshint.reporter('fail')); -}); + .pipe(eslint()) + .pipe(eslint.format()) + .pipe(eslint.failOnError()); +}); \ No newline at end of file diff --git a/app/templates/package.json b/app/templates/package.json index 325fa8b..6430626 100644 --- a/app/templates/package.json +++ b/app/templates/package.json @@ -13,6 +13,7 @@ "del": "1.2.0", "gulp": "3.9.0", "gulp-concat": "2.6.0", + "gulp-eslint": "1.0.0", "gulp-filter": "2.0.2", "gulp-flatten": "0.1.0", "gulp-git": "1.2.4", @@ -20,7 +21,6 @@ "gulp-imagemin": "2.3.0", "gulp-inject": "1.3.1", "gulp-insert": "0.4.0", - "gulp-jshint": "1.11.2", "gulp-karma": "0.0.4", "gulp-less": "3.0.3", "gulp-load-plugins": "0.10.0", @@ -45,7 +45,6 @@ "gulp.spritesmith": "3.8.2", "http-proxy": "1.11.1", "jasmine-core": "2.3.4", - "jshint-stylish": "2.0.1", "karma": "0.12.37", "karma-chrome-launcher": "0.2.0", "karma-coverage": "0.4.2", @@ -70,4 +69,4 @@ "postinstall": "bower install -F", "test": "gulp test" } -} +} \ No newline at end of file diff --git a/controller/templates/controller-spec.js b/controller/templates/controller-spec.js index 557bf5b..d6d524b 100644 --- a/controller/templates/controller-spec.js +++ b/controller/templates/controller-spec.js @@ -3,7 +3,7 @@ describe('<%= controllerName %> tests', function () { beforeEach(module('<%= targetModuleName %>')); beforeEach(inject(function ($controller) { - $controller('<%= controllerName %>', {}); + $controller('<%= controllerName %>', {$scope: {}}); })); describe('tests', function () { diff --git a/controller/templates/controller.js b/controller/templates/controller.js index b1c8b84..e28bee0 100644 --- a/controller/templates/controller.js +++ b/controller/templates/controller.js @@ -1,4 +1,5 @@ angular.module('<%= targetModuleName %>') .controller('<%= controllerName %>', function ($scope) { - + 'use strict'; + $scope.message = 'Hello!'; }); diff --git a/test/generator-app.spec.js b/test/generator-app.spec.js index e1c1be9..722b151 100644 --- a/test/generator-app.spec.js +++ b/test/generator-app.spec.js @@ -17,7 +17,7 @@ describe('oasp:app', function () { 'bower.json', 'package.json', '.editorconfig', - '.jshintrc' + '.eslintrc' ]); }); });