diff --git a/.eslintrc b/.eslintrc index d745a518ef..ca6ce1d48b 100644 --- a/.eslintrc +++ b/.eslintrc @@ -37,6 +37,8 @@ rules: space-in-parens: 1 no-use-before-define: 1 no-unneeded-ternary: 1 + consistent-return: 0 + no-unmodified-loop-condition: 0 ############################################################################# # Angular Plugin Customization diff --git a/horizon/static/horizon/js/horizon.d3linechart.js b/horizon/static/horizon/js/horizon.d3linechart.js index b7fbb26afc..f01b81992d 100644 --- a/horizon/static/horizon/js/horizon.d3linechart.js +++ b/horizon/static/horizon/js/horizon.d3linechart.js @@ -522,7 +522,7 @@ horizon.d3_line_chart = { new Rickshaw.Graph.HoverDetail({ graph: graph, formatter: function(series, x, y) { - if(y % 1 === 0) { + if (y % 1 === 0) { y = parseInt(y, 10); } else { y = parseFloat(y).toFixed(2); diff --git a/horizon/static/horizon/js/horizon.extensible_header.js b/horizon/static/horizon/js/horizon.extensible_header.js index bdbec77210..8d16b9b0a7 100644 --- a/horizon/static/horizon/js/horizon.extensible_header.js +++ b/horizon/static/horizon/js/horizon.extensible_header.js @@ -25,7 +25,7 @@ horizon.extensible_header = { $('#extensible-header').replaceWith($(data)); selected = horizon.cookies.get('selected_header'); - if(selected && $('#header-list #' + selected).length){ + if (selected && $('#header-list #' + selected).length) { $old_primary = $('#primary-extensible-header > a'); $new_primary = $('#header-list #' + selected); diff --git a/horizon/static/horizon/js/horizon.forms.js b/horizon/static/horizon/js/horizon.forms.js index 276b766422..8fff1d0f5d 100644 --- a/horizon/static/horizon/js/horizon.forms.js +++ b/horizon/static/horizon/js/horizon.forms.js @@ -278,7 +278,7 @@ horizon.forms.init_themable_select = function ($elem) { } // Set the select if necessary - if($select.val() !== value) { + if ($select.val() !== value) { $select.val(value).change(); } }); @@ -520,7 +520,7 @@ horizon.addInitFunction(horizon.forms.init = function () { } } else { //If the input is a checkbox no need to replace html for label since it has another structure - if($input.attr('type') !== "checkbox"){ + if ($input.attr('type') !== "checkbox") { $('label[for=' + $input.attr('id') + ']').html(data); } $input.closest('.form-group').show(); @@ -568,7 +568,7 @@ horizon.addInitFunction(horizon.forms.init = function () { var hide_tab = String($switchable.data('hide-tab')).split(','); for (var i = 0, len = hide_tab.length; i < len; i++) { var tab = $('*[data-target="#'+ hide_tab[i] +'"]').parent(); - if(checked == hide_on) { + if (checked == hide_on) { // If the checkbox is not checked then hide the tab tab.hide(); } else if (!tab.is(':visible')) { @@ -579,11 +579,11 @@ horizon.addInitFunction(horizon.forms.init = function () { // hide/show button-next or button-final var $btnfinal = $('.button-final'); - if(checked == hide_on) { + if (checked == hide_on) { $('.button-next').hide(); $btnfinal.show(); $btnfinal.data('show-on-tab', $fieldset.prop('id')); - } else{ + } else { $btnfinal.hide(); $('.button-next').show(); $btnfinal.removeData('show-on-tab'); diff --git a/horizon/static/horizon/js/horizon.heattop.js b/horizon/static/horizon/js/horizon.heattop.js index 2cfa9ea4fd..97f28ef133 100644 --- a/horizon/static/horizon/js/horizon.heattop.js +++ b/horizon/static/horizon/js/horizon.heattop.js @@ -157,7 +157,7 @@ function build_node_links(node){ //make sure target node exists try { target_idx = findNodeIndex(node.required_by[j]); - } catch(err) { + } catch (err) { push_link =false; } //check for duplicates @@ -180,11 +180,11 @@ function build_node_links(node){ function build_reverse_links(node){ for (var i=0;i $(b).data("index")) { return 1; } + if ($(a).data("index") < $(b).data("index")) { return -1; } + if ($(a).data("index") > $(b).data("index")) { return 1; } return 0; }) ); @@ -60,7 +60,7 @@ horizon.lists = { e.preventDefault(); e.stopPropagation(); - if($this.parents("ul#available_"+type).length > 0) { + if ($this.parents("ul#available_"+type).length > 0) { $this.parent().appendTo($("#selected_"+type)); } else if ($this.parents("ul#selected_"+type).length > 0) { $this.parent().appendTo($("#available_"+type)); @@ -103,7 +103,7 @@ horizon.lists = { $('pre.logs').text(response_body); }, error: function () { - if(via_user_submit) { + if (via_user_submit) { horizon.clearErrorMessages(); horizon.toast.add('error', error_txt); } diff --git a/horizon/static/horizon/js/horizon.membership.js b/horizon/static/horizon/js/horizon.membership.js index d586a6a35e..7d453c5567 100644 --- a/horizon/static/horizon/js/horizon.membership.js +++ b/horizon/static/horizon/js/horizon.membership.js @@ -252,7 +252,7 @@ horizon.membership = { generate_html: function(step_slug) { var data_id, data = horizon.membership.data[step_slug]; for (data_id in data) { - if(data.hasOwnProperty(data_id)){ + if (data.hasOwnProperty(data_id)) { var display_name = data[data_id]; var role_ids = this.get_member_roles(step_slug, data_id); if (role_ids.length > 0) { @@ -491,7 +491,7 @@ horizon.membership = { // prevent filter inputs from submitting form on 'enter' $form.find('.' + step_slug + '_membership').keydown(function(event){ - if(event.keyCode === 13) { + if (event.keyCode === 13) { event.preventDefault(); return false; } diff --git a/horizon/static/horizon/js/horizon.tables.js b/horizon/static/horizon/js/horizon.tables.js index 5f42784405..8783716429 100644 --- a/horizon/static/horizon/js/horizon.tables.js +++ b/horizon/static/horizon/js/horizon.tables.js @@ -22,7 +22,7 @@ horizon.datatables = { var requests = []; // do nothing if there are no rows to update. - if($rows_to_update.length <= 0) { return; } + if ($rows_to_update.length <= 0) { return; } // Do not update this row if the action column is expanded if ($rows_to_update.find('.actions_column .btn-group.open').length) { @@ -50,7 +50,7 @@ horizon.datatables = { // existing count minus one for the row we're removing row_count = horizon.datatables.update_footer_count($table, -1); - if(row_count === 0) { + if (row_count === 0) { colspan = $table.find('.table_column_header th').length; template = horizon.templates.compiled_templates["#empty_row_template"]; params = { @@ -104,12 +104,12 @@ horizon.datatables = { } // Only replace row if the html content has changed - if($new_row.html() !== $row.html()) { + if ($new_row.html() !== $row.html()) { // Directly accessing the checked property of the element // is MUCH faster than using jQuery's helper method var $checkbox = $row.find('.table-row-multi-select'); - if($checkbox.length && $checkbox[0].checked) { + if ($checkbox.length && $checkbox[0].checked) { // Preserve the checkbox if it's already clicked $new_row.find('.table-row-multi-select').prop('checked', true); } @@ -146,7 +146,7 @@ horizon.datatables = { $table.attr('decay_constant', decay_constant); var next_poll = interval * decay_constant; // Limit the interval to 30 secs - if(next_poll > 30 * 1000) { next_poll = 30 * 1000; } + if (next_poll > 30 * 1000) { next_poll = 30 * 1000; } setTimeout(horizon.datatables.update, next_poll); }); }, @@ -164,7 +164,7 @@ horizon.datatables = { var $new_action = $(data); // Only replace row if the html content has changed - if($new_action.html() != $action.html()) { + if ($new_action.html() != $action.html()) { $action.replaceWith($new_action); } } @@ -296,11 +296,11 @@ horizon.datatables.confirm = function(action) { name_string = " \"" + $action.closest("tr").attr("data-display") + "\""; name_array = [name_string]; } - } else{ + } else { // Probably we are getting the action from a detail view, so we try to get // the data-display from a dd element instead $data_display = $('dd[data-display]'); - if($data_display.length > 0) { + if ($data_display.length > 0) { name_string = ' "' + $('dd[data-display]').attr("data-display") + '"'; name_array = [name_string]; } @@ -475,7 +475,7 @@ $.tablesorter.addParser({ // numerically comparable to other strings. s = s.toUpperCase(); var value = 0.0; - for(var i = 0; i < s.length; i++) { + for (var i = 0; i < s.length; i++) { var char_offset = 1.0 / Math.pow(100, i); value = value + (s.charCodeAt(i) * char_offset); } diff --git a/horizon/static/horizon/js/horizon.tabs.js b/horizon/static/horizon/js/horizon.tabs.js index 81df14b0fc..34bef0f137 100644 --- a/horizon/static/horizon/js/horizon.tabs.js +++ b/horizon/static/horizon/js/horizon.tabs.js @@ -41,7 +41,7 @@ horizon.tabs.load_tab = function () { .addClass('tab-loading'); // If query params exist, append tab id. - if(window.location.search.length > 0) { + if (window.location.search.length > 0) { $tab_pane.load(window.location.search + "&tab=" + tab_id.replace('#', ''), function() { horizon.tabs.initTabLoad($tab_pane); }); @@ -74,7 +74,7 @@ horizon.addInitFunction(horizon.tabs.init = function () { }); // d3 renders incorrectly in a hidden tab, this forces a rerender when the // container size is not 0 from display:none - if($content.find(".d3-container").length) { + if ($content.find(".d3-container").length) { window.dispatchEvent(new Event('resize')); } diff --git a/openstack_dashboard/static/js/.eslintrc b/openstack_dashboard/static/js/.eslintrc index 2e608255c1..f655e6701d 100644 --- a/openstack_dashboard/static/js/.eslintrc +++ b/openstack_dashboard/static/js/.eslintrc @@ -12,6 +12,7 @@ rules: one-var: 0 space-infix-ops: 0 space-after-keywords: 0 + keyword-spacing: 0 no-console: 0 no-multiple-empty-lines: 0 no-sync: 0 diff --git a/package.json b/package.json index 38c6cd9605..be51478a67 100644 --- a/package.json +++ b/package.json @@ -6,14 +6,14 @@ "repository": "none", "license": "Apache 2.0", "devDependencies": { - "eslint": "1.10.3", - "eslint-config-openstack": "1.2.4", - "eslint-plugin-angular": "1.0.1", + "eslint": "3.0.0", + "eslint-config-openstack": "4.0.1", + "eslint-plugin-angular": "4.0.1", "jasmine-core": "2.4.1", "karma": "1.1.2", - "karma-firefox-launcher": "2.1.0", "karma-cli": "1.0.1", "karma-coverage": "1.1.1", + "karma-firefox-launcher": "2.1.0", "karma-jasmine": "1.0.2", "karma-ng-html2js-preprocessor": "1.0.0", "karma-threshold-reporter": "0.1.15"