From a60c0e530df29ebdd26e0f96dd05498c73a42205 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 22 May 2017 12:40:41 +0100 Subject: [PATCH 1/5] Install eslint and run it during the jstest --- .eslintignore | 1 + .eslintrc.json | 25 +++++++++++++++++++++++++ Makefile | 2 +- package.json | 1 + 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 .eslintignore create mode 100644 .eslintrc.json diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..b5b25be8e --- /dev/null +++ b/.eslintignore @@ -0,0 +1 @@ +/frontend/tests/* diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 000000000..5badfb252 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,25 @@ +{ + "env": { + "browser": true, + "commonjs": true, + "es6": true + }, + "extends": "eslint:recommended", + "parserOptions": { + "sourceType": "module" + }, + "rules": { + "indent": [ + "error", + 2 + ], + "linebreak-style": [ + "error", + "unix" + ], + "semi": [ + "error", + "always" + ] + } +} diff --git a/Makefile b/Makefile index 701f41e0a..69b3f24b5 100644 --- a/Makefile +++ b/Makefile @@ -108,7 +108,7 @@ pythontest: jstest: @echo "Running javascript testsuite" @echo "----------------------------" - `npm bin`/jshint --config .jshintrc --exclude frontend/tests frontend + ./node_modules/.bin/eslint --config .eslintrc.json --ignore-path .eslintignore frontend/ `npm bin`/node-qunit-phantomjs frontend/tests/tests.html .PHONY: jscoverage diff --git a/package.json b/package.json index e22e5f195..b9843f034 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "babel-preset-env": "^1.4.0", "babel-preset-es2015": "^6.24.1", "css-loader": "^0.28.1", + "eslint": "^3.19.0", "jshint": "*", "node-qunit-phantomjs": "*", "vue-loader": "^12.0.4", From 1291439fbf5d7d74ee228bd93b66e9b804d4f4d6 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 22 May 2017 12:43:28 +0100 Subject: [PATCH 2/5] Remove jshint --- .jshintrc | 48 ------------------------------------------------ package.json | 1 - 2 files changed, 49 deletions(-) delete mode 100644 .jshintrc diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 95ed49ba6..000000000 --- a/.jshintrc +++ /dev/null @@ -1,48 +0,0 @@ -{ - "esversion": 6, - "passfail" : false, - "maxerr" : 100, - "browser" : true, - "predef" : [ - "define", - "require" - ], - "debug" : false, - "devel" : true, - "strict" : false, - "globalstrict" : false, - "asi" : false, - "laxbreak" : false, - "bitwise" : true, - "boss" : false, - "unused" : true, - "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" : true, - "nonew" : true, - "nomen" : true, - "onevar" : false, - "plusplus" : false, - "sub" : false, - "trailing" : true, - "white" : false, - "indent" : 2, - "globals": { - "module": true - } -} diff --git a/package.json b/package.json index b9843f034..f6a02036a 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,6 @@ "babel-preset-es2015": "^6.24.1", "css-loader": "^0.28.1", "eslint": "^3.19.0", - "jshint": "*", "node-qunit-phantomjs": "*", "vue-loader": "^12.0.4", "vue-template-compiler": "^2.3.3", From 2b0f13bf2c8c88ee28b075fbab055085a5cbe9cd Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 22 May 2017 13:02:12 +0100 Subject: [PATCH 3/5] Fix eslint tests --- frontend/admin/admin-resources.js | 44 ++----------------------------- frontend/admin/main.js | 3 +-- frontend/user/user-resources.js | 36 +------------------------ 3 files changed, 4 insertions(+), 79 deletions(-) diff --git a/frontend/admin/admin-resources.js b/frontend/admin/admin-resources.js index 8b9b86774..d8fa6da9f 100644 --- a/frontend/admin/admin-resources.js +++ b/frontend/admin/admin-resources.js @@ -63,7 +63,6 @@ var API = (function () { })(); var RestError = function(code, message) { - console.log("Creating error "+code+" message: "+message); this.code = code; this.message = message; }; @@ -97,11 +96,6 @@ var create_handler = function(promise, data, textStatus, jqXHR) { if (status !== 201) { // Strange situation in which the call succeeded, but // not with a 201. Just do our best. - console.log( - "Create succeded but response with status " + - status + - " instead of 201." - ); promise.reject(status, payload); return; } @@ -113,7 +107,6 @@ var create_handler = function(promise, data, textStatus, jqXHR) { var arr = url.pathname.replace(/\/$/, "").split('/'); id = arr[arr.length - 1]; } catch (e) { - console.log("Response had invalid or absent Location header"); promise.reject(status, payload); return; } @@ -133,11 +126,6 @@ var create_singleton_handler = function(promise, data, textStatus, jqXHR) { if (status !== 201) { // Strange situation in which the call succeeded, but // not with a 201. Just do our best. - console.log( - "Create succeded but response with status " + - status + - " instead of 201." - ); promise.reject(status, payload); return; } @@ -146,7 +134,6 @@ var create_singleton_handler = function(promise, data, textStatus, jqXHR) { try { location = jqXHR.getResponseHeader('Location'); } catch (e) { - console.log("Response had invalid or absent Location header"); promise.reject(status, payload); return; } @@ -166,11 +153,6 @@ var update_handler = function(promise, data, textStatus, jqXHR) { if (status !== 204) { // Strange situation in which the call succeeded, but // not with a 201. Just do our best. - console.log( - "Update succeded but response with status " + - status + - " instead of 204." - ); promise.reject(status, payload); return; } @@ -188,11 +170,6 @@ var delete_handler = function(promise, data, textStatus, jqXHR) { } if (status !== 204) { - console.log( - "Delete succeded but response with status " + - status + - " instead of 204." - ); promise.reject(status, payload); return; } @@ -210,19 +187,11 @@ var retrieve_handler = function(promise, data, textStatus, jqXHR) { } if (status !== 200) { - console.log( - "Retrieve succeded but response with status " + - status + - " instead of 200." - ); promise.reject(status, payload); return; } if (payload === null) { - console.log( - "Retrieve succeded but empty or invalid payload" - ); promise.reject(status, payload); return; } @@ -255,8 +224,7 @@ var Resource = function(type) { API.request("PUT", urlUtils.pathJoin(type, id), body, query_args) .done(function(data, textStatus, jqXHR) { update_handler(promise, data, textStatus, jqXHR); - } - ) + }) .fail(function(jqXHR) { fail_handler(promise, jqXHR); }); @@ -309,19 +277,11 @@ var Resource = function(type) { } if (status !== 200) { - console.log( - "Items retrieve succeded but response with status " + - status + - " instead of 200." - ); promise.reject(status, payload); return; } if (payload === null) { - console.log( - "Items Retrieve succeded but empty or invalid payload" - ); promise.reject(status, payload); return; } @@ -411,4 +371,4 @@ module.exports = { "User" : new Resource("users"), "Container" : new Resource("containers"), "Stats" : new SingletonResource("stats"), -}; \ No newline at end of file +}; diff --git a/frontend/admin/main.js b/frontend/admin/main.js index f76bb889a..1c222c17f 100644 --- a/frontend/admin/main.js +++ b/frontend/admin/main.js @@ -32,8 +32,7 @@ let router = new VueRouter({ ] }); -let vm; -vm = new Vue({ +new Vue({ el: "#app", router: router }); diff --git a/frontend/user/user-resources.js b/frontend/user/user-resources.js index f8d425134..d16061266 100644 --- a/frontend/user/user-resources.js +++ b/frontend/user/user-resources.js @@ -63,7 +63,6 @@ var API = (function () { })(); var RestError = function(code, message) { - console.log("Creating error "+code+" message: "+message); this.code = code; this.message = message; }; @@ -97,11 +96,6 @@ var create_handler = function(promise, data, textStatus, jqXHR) { if (status !== 201) { // Strange situation in which the call succeeded, but // not with a 201. Just do our best. - console.log( - "Create succeded but response with status " + - status + - " instead of 201." - ); promise.reject(status, payload); return; } @@ -113,7 +107,6 @@ var create_handler = function(promise, data, textStatus, jqXHR) { var arr = url.pathname.replace(/\/$/, "").split('/'); id = arr[arr.length - 1]; } catch (e) { - console.log("Response had invalid or absent Location header"); promise.reject(status, payload); return; } @@ -133,11 +126,6 @@ var update_handler = function(promise, data, textStatus, jqXHR) { if (status !== 204) { // Strange situation in which the call succeeded, but // not with a 201. Just do our best. - console.log( - "Update succeded but response with status " + - status + - " instead of 204." - ); promise.reject(status, payload); return; } @@ -155,11 +143,6 @@ var delete_handler = function(promise, data, textStatus, jqXHR) { } if (status !== 204) { - console.log( - "Delete succeded but response with status " + - status + - " instead of 204." - ); promise.reject(status, payload); return; } @@ -177,19 +160,11 @@ var retrieve_handler = function(promise, data, textStatus, jqXHR) { } if (status !== 200) { - console.log( - "Retrieve succeded but response with status " + - status + - " instead of 200." - ); promise.reject(status, payload); return; } if (payload === null) { - console.log( - "Retrieve succeded but empty or invalid payload" - ); promise.reject(status, payload); return; } @@ -222,8 +197,7 @@ var Resource = function(type) { API.request("PUT", urlUtils.pathJoin(type, id), body, query_args) .done(function(data, textStatus, jqXHR) { update_handler(promise, data, textStatus, jqXHR); - } - ) + }) .fail(function(jqXHR) { fail_handler(promise, jqXHR); }); @@ -276,19 +250,11 @@ var Resource = function(type) { } if (status !== 200) { - console.log( - "Items retrieve succeded but response with status " + - status + - " instead of 200." - ); promise.reject(status, payload); return; } if (payload === null) { - console.log( - "Items Retrieve succeded but empty or invalid payload" - ); promise.reject(status, payload); return; } From 2a721c6ca073c2c0231cbef82f894f07b4cfb8a1 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 22 May 2017 13:34:50 +0100 Subject: [PATCH 4/5] Add support of vue files for eslint --- .eslintrc.json | 1 + Makefile | 2 +- package.json | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index 5badfb252..d8cac4e3c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -5,6 +5,7 @@ "es6": true }, "extends": "eslint:recommended", + "plugins": ["vue"], "parserOptions": { "sourceType": "module" }, diff --git a/Makefile b/Makefile index 69b3f24b5..2523ecc15 100644 --- a/Makefile +++ b/Makefile @@ -108,7 +108,7 @@ pythontest: jstest: @echo "Running javascript testsuite" @echo "----------------------------" - ./node_modules/.bin/eslint --config .eslintrc.json --ignore-path .eslintignore frontend/ + ./node_modules/.bin/eslint --ext .vue,.js --ignore-path .eslintignore frontend/ `npm bin`/node-qunit-phantomjs frontend/tests/tests.html .PHONY: jscoverage diff --git a/package.json b/package.json index f6a02036a..6d5abea05 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "babel-preset-es2015": "^6.24.1", "css-loader": "^0.28.1", "eslint": "^3.19.0", + "eslint-plugin-vue": "^2.0.1", "node-qunit-phantomjs": "*", "vue-loader": "^12.0.4", "vue-template-compiler": "^2.3.3", From aa0b3644c7c87539422e6a5154b0d17436b2e899 Mon Sep 17 00:00:00 2001 From: martinRenou Date: Mon, 22 May 2017 13:37:46 +0100 Subject: [PATCH 5/5] Clear command --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2523ecc15..3ca454646 100644 --- a/Makefile +++ b/Makefile @@ -108,7 +108,7 @@ pythontest: jstest: @echo "Running javascript testsuite" @echo "----------------------------" - ./node_modules/.bin/eslint --ext .vue,.js --ignore-path .eslintignore frontend/ + `npm bin`/eslint --ext .vue,.js --ignore-path .eslintignore frontend/ `npm bin`/node-qunit-phantomjs frontend/tests/tests.html .PHONY: jscoverage