From ed344e55aaac254b0c477d3f721218dcf7ef14f3 Mon Sep 17 00:00:00 2001 From: zhurong Date: Wed, 21 Sep 2016 09:54:40 +0800 Subject: [PATCH] Update murano-dashboard eslint devDependencies Synchronize the eslint and eslint-config-openstack versions with horizon. Change-Id: I117d1e5e418183cc72048a889acbd825a240cfe0 --- .eslintrc | 19 ++++++ .../static/muranodashboard/js/add-select.js | 16 ++--- .../js/draggable-components.js | 8 +-- .../js/environments-in-place.js | 4 +- .../static/muranodashboard/js/external-ad.js | 8 +-- .../js/horizon.muranotopology.js | 62 +++++++++---------- .../static/muranodashboard/js/mixed-mode.js | 6 +- .../muranodashboard/js/murano.service.js | 2 +- package.json | 4 +- 9 files changed, 74 insertions(+), 55 deletions(-) diff --git a/.eslintrc b/.eslintrc index edfecbc30..80f501cc1 100644 --- a/.eslintrc +++ b/.eslintrc @@ -15,6 +15,25 @@ globals: # allow passing TENANT_ID from django templates TENANT_ID: false +# Below we adjust rules specific to horizon's usage of openstack's linting +# rules, and its own plugin inclusions. +rules: + ############################################################################# + # Disabled Rules from eslint-config-openstack + ############################################################################# + valid-jsdoc: [1, { + requireParamDescription: false + }] + no-undefined: 1 + brace-style: 1 + no-extra-parens: 1 + callback-return: 1 + block-scoped-var: 1 + quote-props: 0 + space-in-parens: 1 + no-use-before-define: 1 + no-unneeded-ternary: 1 + # Only support ECMA5, disable everything else. # NOTE(kzaitsev): blatantly copied from horizon ecmaFeatures: diff --git a/muranodashboard/static/muranodashboard/js/add-select.js b/muranodashboard/static/muranodashboard/js/add-select.js index 733aa8a0e..a46760248 100644 --- a/muranodashboard/static/muranodashboard/js/add-select.js +++ b/muranodashboard/static/muranodashboard/js/add-select.js @@ -17,11 +17,11 @@ $(function() { "use strict"; var plus = ""; - if ( typeof window.murano === "undefined" ) { + if (typeof window.murano === "undefined") { window.murano = {}; } - if ( !window.murano.bind_add_item_handlers ) { + if (!window.murano.bind_add_item_handlers) { window.murano.bind_add_item_handlers = true; horizon.modals.addModalInitFunction(initPlusButton); @@ -37,13 +37,13 @@ $(function() { var urls, link, $choices; try { urls = $.parseJSON($this.attr("data-add-item-url")); - } catch(err) { + } catch (err) { if (window.console) { window.console.log(err); } } - if ( urls && urls[0].length ) { - if ( urls.length === 1 ) { + if (urls && urls[0].length) { + if (urls.length === 1) { link = $this.next().find('a'); link.html(plus); link.attr('href', urls[0][1]); @@ -62,9 +62,9 @@ $(function() { $this.next('span').append($choices); } } - if ( $this.hasClass('murano_add_select') ) { + if ($this.hasClass('murano_add_select')) { // NOTE(tsufiev): hide selectbox in case it contains no elements - if ( this.options.length === 1 ) { + if (this.options.length === 1) { $this.hide(); $this.next('span').removeClass('input-group-btn').find('i').text( ' Add Application'); @@ -72,7 +72,7 @@ $(function() { // NOTE(tsufiev): show hidden select once the new option was added to it // programmatically (on return from the finished modal dialog) $this.change(function() { - if ( !$this.is(':visible') && this.options.length > 1 ) { + if (!$this.is(':visible') && this.options.length > 1) { $this.show(); $this.next('span').addClass('input-group-btn').find('i').text(''); $this.val($(this.options[1]).val()); diff --git a/muranodashboard/static/muranodashboard/js/draggable-components.js b/muranodashboard/static/muranodashboard/js/draggable-components.js index 56918f587..acd63eda4 100644 --- a/muranodashboard/static/muranodashboard/js/draggable-components.js +++ b/muranodashboard/static/muranodashboard/js/draggable-components.js @@ -241,9 +241,9 @@ $(function() { modalContent.append(button); $('.modal-close button').tooltip(); $('.modal-close button').on("click", function () { - window.clearInterval(intervalId); - document.location = $form.attr('action'); - }); + window.clearInterval(intervalId); + document.location = $form.attr('action'); + }); if (startUrl) { $.ajax({ type: 'POST', @@ -255,7 +255,7 @@ $(function() { }, error: handleError }); - if ( resultUrl ) { + if (resultUrl) { intervalId = window.setInterval(function () { // it's better to avoid placing the whole downloadable content diff --git a/muranodashboard/static/muranodashboard/js/environments-in-place.js b/muranodashboard/static/muranodashboard/js/environments-in-place.js index 95dc8c82d..ad3f361e8 100644 --- a/muranodashboard/static/muranodashboard/js/environments-in-place.js +++ b/muranodashboard/static/muranodashboard/js/environments-in-place.js @@ -42,7 +42,7 @@ $(function() { var $form = $(data).find('form'); var $name = $form.find('div.form-group'); $name.addClass("col-md-6"); - if ( validationFailed ) { + if (validationFailed) { $thead.find('tr.new_env').remove(); } @@ -83,7 +83,7 @@ $(function() { gettext("There was an error submitting the form. Please try again.")); }, success: function(data, status, xhr) { - if ( data === '' ) { + if (data === '') { // environment was created successfully var redirUrl = xhr.getResponseHeader('X-Horizon-Location'); $newEnvTr.remove(); diff --git a/muranodashboard/static/muranodashboard/js/external-ad.js b/muranodashboard/static/muranodashboard/js/external-ad.js index e2b4fe9d2..6573c8d08 100644 --- a/muranodashboard/static/muranodashboard/js/external-ad.js +++ b/muranodashboard/static/muranodashboard/js/external-ad.js @@ -18,13 +18,13 @@ $(function() { var checked = $("input[id*='externalAD']").prop('checked'); if (checked === true) { $("select[id*='-domain']").attr("disabled", "disabled"); - $("label[for*='domainAdminUserName']").parent().css({'display': 'inline-block'}); - $("label[for*='domainAdminPassword']").parent().css({'display': 'inline-block'}); + $("label[for*='domainAdminUserName']").parent().css({"display": 'inline-block'}); + $("label[for*='domainAdminPassword']").parent().css({"display": 'inline-block'}); } if (checked === false) { $("select[id*='-domain']").removeAttr("disabled"); - $("label[for*='domainAdminUserName']").parent().css({'display': 'none'}); - $("label[for*='domainAdminPassword']").parent().css({'display': 'none'}); + $("label[for*='domainAdminUserName']").parent().css({"display": 'none'}); + $("label[for*='domainAdminPassword']").parent().css({"display": 'none'}); } } diff --git a/muranodashboard/static/muranodashboard/js/horizon.muranotopology.js b/muranodashboard/static/muranodashboard/js/horizon.muranotopology.js index a24122d26..cb207b944 100644 --- a/muranodashboard/static/muranodashboard/js/horizon.muranotopology.js +++ b/muranodashboard/static/muranodashboard/js/horizon.muranotopology.js @@ -56,46 +56,46 @@ $(function() { function update() { node = node.data(nodes, function(d) { - return d.id; - }); + return d.id; + }); link = link.data(links); var nodeEnter = node.enter().append("g") .attr("class", "node") .attr("node_name", function(d) { - return d.name; - }) + return d.name; + }) .attr("node_id", function(d) { - return d.id; - }) + return d.id; + }) .call(force.drag); nodeEnter.append("image") .attr("xlink:href", function(d) { - return d.image; - }) + return d.image; + }) .attr("id", function(d) { - return "image_" + d.id; - }) + return "image_" + d.id; + }) .attr("x", function(d) { - return d.image_x; - }) + return d.image_x; + }) .attr("y", function(d) { - return d.image_y; - }) + return d.image_y; + }) .attr("width", function(d) { - return d.image_size; - }) + return d.image_size; + }) .attr("height", function(d) { - return d.image_size; - }) + return d.image_size; + }) .attr("clip-path", "url(#clipCircle)"); node.exit().remove(); link.enter().insert("path", "g.node") .attr("class", function(d) { - return "link " + d.link_type; - }); + return "link " + d.link_type; + }); link.exit().remove(); //Setup click action for all nodes @@ -117,8 +117,8 @@ $(function() { function tick() { link.attr('d', drawLink).style('stroke-width', 3).attr('marker-end', "url(#end)"); node.attr("transform", function(d) { - return "translate(" + d.x + "," + d.y + ")"; - }); + return "translate(" + d.x + "," + d.y + ")"; + }); } function setInProgress(stack, innerNodes) { @@ -192,7 +192,7 @@ $(function() { //make sure target node exists try { targetIdx = findNodeIndex(innerNode.required_by[j]); - } catch(err) { + } catch (err) { if (window.console) { window.console.log(err); } @@ -208,10 +208,10 @@ $(function() { if (pushLink === true && (sourceIdx && targetIdx)) { links.push({ - 'target': sourceIdx, - 'source': targetIdx, - 'value': 1, - 'link_type': innerNode.link_type + "target": sourceIdx, + "source": targetIdx, + "value": 1, + "link_type": innerNode.link_type }); } } @@ -225,10 +225,10 @@ $(function() { //if new node is required by existing node, push new link if (innerNode.id === dependency) { links.push({ - 'target': findNodeIndex(nodes[i].id), - 'source': findNodeIndex(innerNode.id), - 'value': 1, - 'link_type': nodes[i].link_type + "target": findNodeIndex(nodes[i].id), + "source": findNodeIndex(innerNode.id), + "value": 1, + "link_type": nodes[i].link_type }); } } diff --git a/muranodashboard/static/muranodashboard/js/mixed-mode.js b/muranodashboard/static/muranodashboard/js/mixed-mode.js index 02230fe0f..a3a6ccdd4 100644 --- a/muranodashboard/static/muranodashboard/js/mixed-mode.js +++ b/muranodashboard/static/muranodashboard/js/mixed-mode.js @@ -16,10 +16,10 @@ $(function() { "use strict"; function checkMixedMode() { var checked = $("input[id*='mixedModeAuth']").prop('checked'); - if ( checked === true) { - $("label[for*='saPassword']").parent().css({'display': 'inline-block'}); + if (checked === true) { + $("label[for*='saPassword']").parent().css({"display": 'inline-block'}); } else if (checked === false) { - $("label[for*='saPassword']").parent().css({'display': 'none'}); + $("label[for*='saPassword']").parent().css({"display": 'none'}); } } diff --git a/muranodashboard/static/muranodashboard/js/murano.service.js b/muranodashboard/static/muranodashboard/js/murano.service.js index 684b672ae..9f65b6372 100644 --- a/muranodashboard/static/muranodashboard/js/murano.service.js +++ b/muranodashboard/static/muranodashboard/js/murano.service.js @@ -64,7 +64,7 @@ */ function getPackages(params) { - var config = params ? { 'params' : params} : {}; + var config = params ? { "params" : params} : {}; return apiService.get('/api/app-catalog/packages/', config) .error(function () { toastService.add('error', gettext('Unable to retrieve the packages.')); diff --git a/package.json b/package.json index 171191981..42ce5f1bf 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "repository": "none", "license": "Apache 2.0", "devDependencies": { - "eslint": "1.2.1", - "eslint-config-openstack": "1.2.3" + "eslint": "1.10.3", + "eslint-config-openstack": "1.2.4" }, "scripts": { "lint": "eslint --no-color muranodashboard/static"