From fc323ae89d739606a02a7b23ec79a24fbef8bfc4 Mon Sep 17 00:00:00 2001 From: Per Ploug Date: Thu, 25 Jun 2015 11:49:00 +0200 Subject: [PATCH] Include EsLint in grunt ESlint is not turned on by default - as it gives us 500ish errors as of the current state of the codebase, also, we should start linting controllers (why arent we?) EsLint contains angular best practices rules and will help us get V8 ready for Angular2 and to follow best practices, untill everything passes we can turn it on and off during clean-up time --- src/Umbraco.Web.UI.Client/.eslintrc | 53 ++++++++++++++++++++++++++ src/Umbraco.Web.UI.Client/gruntFile.js | 22 +++++++++-- src/Umbraco.Web.UI.Client/package.json | 3 ++ 3 files changed, 75 insertions(+), 3 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/.eslintrc diff --git a/src/Umbraco.Web.UI.Client/.eslintrc b/src/Umbraco.Web.UI.Client/.eslintrc new file mode 100644 index 0000000000..811fabdabf --- /dev/null +++ b/src/Umbraco.Web.UI.Client/.eslintrc @@ -0,0 +1,53 @@ +{ + "env": { + "browser": true + }, + + "plugins": [ + "angular" + ], + + "rules": { + "eqeqeq": 2, + "curly": 2, + + "no-unused-vars": 1, + "no-eval": 1, + "no-delete-var": 1, + "quotes": 1, + "dot-notation": 1, + + "no-use-before-define": 0, + "angular/ng_controller_as": 1, + "angular/ng_controller_as_vm": 1, + + + "strict": 0, + "no-irregular-whitespace": 0, + "no-mixed-spaces-and-tabs": 0, + "no-multi-spaces": 0, + "key-spacing": 0, + "semi-spacing": 0, + "space-infix-ops": 0, + "comma-spacing": 0, + "no-trailing-spaces": 0, + "eol-last": 0, + "no-underscore-dangle": 0, + "camelcase": 0 + }, + + "globals": { + "angular": false, + "_": false, + "$", false, + "tinymce": false, + "tinyMCE": false, + "FileReader": false, + "Umbraco": false, + "window": false, + "LazyLoad": false, + "ActiveXObject": false, + "Bloodhound", false + } + +} \ No newline at end of file diff --git a/src/Umbraco.Web.UI.Client/gruntFile.js b/src/Umbraco.Web.UI.Client/gruntFile.js index 53dd53bab1..8f43408105 100644 --- a/src/Umbraco.Web.UI.Client/gruntFile.js +++ b/src/Umbraco.Web.UI.Client/gruntFile.js @@ -92,7 +92,10 @@ module.exports = function (grunt) { ' * Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>\n */\n', src: { js: ['src/**/*.js', 'src/*.js'], + common: ['src/common/**/*.js'], + controllers: ['src/**/*.controller.js'], + specs: ['test/**/*.spec.js'], scenarios: ['test/**/*.scenario.js'], samples: ['sample files/*.js'], @@ -195,6 +198,7 @@ module.exports = function (grunt) { src: ['src/canvasdesigner/canvasdesigner.global.js', 'src/canvasdesigner/canvasdesigner.controller.js', 'src/canvasdesigner/editors/*.js', 'src/canvasdesigner/lib/*.js'], dest: '<%= distdir %>/js/canvasdesigner.panel.js' }, + controllers: { src: ['src/controllers/**/*.controller.js', 'src/views/**/*.controller.js'], dest: '<%= distdir %>/js/umbraco.controllers.js', @@ -203,6 +207,7 @@ module.exports = function (grunt) { footer: "\n\n})();" } }, + services: { src: ['src/common/services/*.js'], dest: '<%= distdir %>/js/umbraco.services.js', @@ -211,6 +216,7 @@ module.exports = function (grunt) { footer: "\n\n})();" } }, + security: { src: ['src/common/security/*.js'], dest: '<%= distdir %>/js/umbraco.security.js', @@ -219,6 +225,7 @@ module.exports = function (grunt) { footer: "\n\n})();" } }, + resources: { src: ['src/common/resources/*.js'], dest: '<%= distdir %>/js/umbraco.resources.js', @@ -227,6 +234,7 @@ module.exports = function (grunt) { footer: "\n\n})();" } }, + testing: { src: ['src/common/mocks/*/*.js'], dest: '<%= distdir %>/js/umbraco.testing.js', @@ -235,6 +243,7 @@ module.exports = function (grunt) { footer: "\n\n})();" } }, + directives: { src: ['src/common/directives/**/*.js'], dest: '<%= distdir %>/js/umbraco.directives.js', @@ -243,6 +252,7 @@ module.exports = function (grunt) { footer: "\n\n})();" } }, + filters: { src: ['src/common/filters/*.js'], dest: '<%= distdir %>/js/umbraco.filters.js', @@ -356,16 +366,21 @@ module.exports = function (grunt) { } }, + eslint:{ + src: ['<%= src.common %>','<%= src.controllers %>'], + options: {quiet: true} + }, + jshint: { dev: { files: { - src: ['<%= src.common %>', '<%= src.specs %>', '<%= src.scenarios %>', '<%= src.samples %>'] + src: ['<%= src.common %>'] }, options: { curly: true, eqeqeq: true, immed: true, - latedef: true, + latedef: "nofunc", newcap: true, noarg: true, sub: true, @@ -390,7 +405,7 @@ module.exports = function (grunt) { curly: true, eqeqeq: true, immed: true, - latedef: true, + latedef: "nofunc", newcap: true, noarg: true, sub: true, @@ -489,4 +504,5 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-bower'); grunt.loadNpmTasks('grunt-ngdocs'); + grunt.loadNpmTasks('grunt-eslint'); }; diff --git a/src/Umbraco.Web.UI.Client/package.json b/src/Umbraco.Web.UI.Client/package.json index aa83829193..4f12362c14 100644 --- a/src/Umbraco.Web.UI.Client/package.json +++ b/src/Umbraco.Web.UI.Client/package.json @@ -22,6 +22,8 @@ "dependencies": {}, "devDependencies": { "bower": "^1.4.1", + "eslint": "^0.23.0", + "eslint-plugin-angular": "0.0.13", "grunt": "~0.4.0", "grunt-bower": "^0.19.0", "grunt-bower-install-simple": "^1.1.3", @@ -32,6 +34,7 @@ "grunt-contrib-jshint": "~0.2.0", "grunt-contrib-uglify": "~0.1.1", "grunt-contrib-watch": "~0.3.1", + "grunt-eslint": "^15.0.0", "grunt-html2js": "~0.1.0", "grunt-karma": "~0.5", "grunt-ngdocs": "~0.1.2",