Fix ESLint warnings

Also switch on enforcing of some rules

Change-Id: I8bf6186eb800daad18ba4ec665c65452b3ce5ea3
This commit is contained in:
Vitaly Kramskikh 2015-08-01 22:15:15 +03:00
parent 1c832595ab
commit 804ddc8e28
8 changed files with 25 additions and 31 deletions

View File

@ -8,14 +8,14 @@
"rules": { "rules": {
"no-cond-assign": 2, "no-cond-assign": 2,
"no-console": 2, "no-console": 2,
"no-constant-condition": 1, "no-constant-condition": 2,
"no-debugger": 2, "no-debugger": 2,
"no-dupe-args": 2, "no-dupe-args": 2,
"no-dupe-keys": 2, "no-dupe-keys": 2,
"no-duplicate-case": 2, "no-duplicate-case": 2,
"no-empty-character-class": 2, "no-empty-character-class": 2,
"no-ex-assign": 2, "no-ex-assign": 2,
"no-extra-boolean-cast": 1, "no-extra-boolean-cast": 2,
"no-extra-parens": 0, "no-extra-parens": 0,
"no-extra-semi": 2, "no-extra-semi": 2,
"no-func-assign": 2, "no-func-assign": 2,
@ -79,15 +79,15 @@
"max-nested-callbacks": [0, 5], "max-nested-callbacks": [0, 5],
"no-array-constructor": 2, "no-array-constructor": 2,
"no-new-object": 2, "no-new-object": 2,
"no-lonely-if": 1, "no-lonely-if": 2,
"no-unneeded-ternary": 2, "no-unneeded-ternary": 2,
"id-match": [1, "^([A-Za-z\\d_$]+)$", {"properties": true}], "id-match": [2, "^([A-Za-z\\d_$]+)$", {"properties": true}],
"quotes": [2, "single", "avoid-escape"], "quotes": [2, "single", "avoid-escape"],
"react/jsx-curly-spacing": [2, "never"], "react/jsx-curly-spacing": [2, "never"],
"react/jsx-no-duplicate-props": 2, "react/jsx-no-duplicate-props": 2,
"react/jsx-no-undef": 2, "react/jsx-no-undef": 2,
"react/jsx-quotes": [1, "single", "avoid-escape"], "react/jsx-quotes": [2, "single", "avoid-escape"],
"react/jsx-uses-react": 2, "react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2, "react/jsx-uses-vars": 2,
"react/no-unknown-property": 2, "react/no-unknown-property": 2,

View File

@ -755,11 +755,9 @@ define([
model: models.Interface, model: models.Interface,
generateBondName: function(base) { generateBondName: function(base) {
var index, proposedName; var index, proposedName;
for (index = 0; true; index += 1) { for (index = 0;; index += 1) {
proposedName = base + index; proposedName = base + index;
if (!this.where({name: proposedName}).length) { if (!this.any({name: proposedName})) return proposedName;
return proposedName;
}
} }
}, },
comparator: function(ifc1, ifc2) { comparator: function(ifc1, ifc2) {

View File

@ -59,16 +59,16 @@ function(_, i18n, $, React, utils, models, dispatcher, dialogs, componentMixins,
getTitle: function() { getTitle: function() {
var title = 'title_new', var title = 'title_new',
cluster = this.props.cluster; cluster = this.props.cluster;
if (!!cluster.get('nodes').length) { if (cluster.get('nodes').length) {
title = 'title_ready'; title = 'title_ready';
} }
if (cluster.get('status') != 'new') { if (cluster.get('status') != 'new') {
title = null; title = null;
} }
if (!!cluster.task({group: 'deployment', status: 'running'})) { if (cluster.task({group: 'deployment', status: 'running'})) {
title = 'deploy_progress'; title = 'deploy_progress';
} }
if (!!cluster.task({group: 'deployment', status: 'error'})) { if (cluster.task({group: 'deployment', status: 'error'})) {
title = 'title_error'; title = 'title_error';
} }
return title; return title;
@ -875,10 +875,8 @@ function(_, i18n, $, React, utils, models, dispatcher, dialogs, componentMixins,
this.setState({disabled: false}); this.setState({disabled: false});
this.props.endRenaming(); this.props.endRenaming();
}, this)); }, this));
} else { } else if (cluster.validationError) {
if (cluster.validationError) { this.setState({error: cluster.validationError.name});
this.setState({error: cluster.validationError.name});
}
} }
} else { } else {
this.props.endRenaming(); this.props.endRenaming();

View File

@ -159,14 +159,12 @@ function($, _, i18n, Backbone, React, models, dispatcher, utils, componentMixins
if (this.props.autoIncreaseWith) { if (this.props.autoIncreaseWith) {
valuesToSet = newValue; valuesToSet = newValue;
} else { } else if (_.contains(name, 'range-start')) {
// if first range field // if first range field
if (_.contains(name, 'range-start')) { valuesToModify[0] = newValue;
valuesToModify[0] = newValue; } else if (_.contains(name, 'range-end')) {
// if end field // if end field
} else if (_.contains(name, 'range-end')) { valuesToModify[1] = newValue;
valuesToModify[1] = newValue;
}
} }
this.setValue(attribute, valuesToSet, {isInteger: this.props.integerValue}); this.setValue(attribute, valuesToSet, {isInteger: this.props.integerValue});

View File

@ -622,8 +622,8 @@ function($, _, i18n, Backbone, React, utils, models, dispatcher, controls, dialo
var data = {id: node.id, pending_roles: node.get('pending_roles')}; var data = {id: node.id, pending_roles: node.get('pending_roles')};
if (node.get('pending_roles').length) { if (node.get('pending_roles').length) {
if (this.props.mode == 'add') return _.extend(data, {cluster_id: this.props.cluster.id, pending_addition: true}); if (this.props.mode == 'add') return _.extend(data, {cluster_id: this.props.cluster.id, pending_addition: true});
} else { } else if (node.get('pending_addition')) {
if (node.get('pending_addition')) return _.extend(data, {cluster_id: null, pending_addition: false}); return _.extend(data, {cluster_id: null, pending_addition: false});
} }
return data; return data;
}, this)); }, this));

View File

@ -323,7 +323,7 @@ function($, _, i18n, React, utils, models, Expression, componentMixins, controls
message: messages.join(' ') message: messages.join(' ')
}; };
}, },
areCalсulationsPossible: function(setting) { areCalculationsPossible: function(setting) {
return _.contains(['checkbox', 'radio'], setting.type); return _.contains(['checkbox', 'radio'], setting.type);
}, },
getValuesToCheck: function(setting, valueAttribute) { getValuesToCheck: function(setting, valueAttribute) {
@ -342,7 +342,7 @@ function($, _, i18n, React, utils, models, Expression, componentMixins, controls
if (!this.props.allocatedRoles.length) return []; if (!this.props.allocatedRoles.length) return [];
var path = this.props.makePath(groupName, settingName), var path = this.props.makePath(groupName, settingName),
setting = this.props.settings.get(path); setting = this.props.settings.get(path);
if (!this.areCalсulationsPossible(setting)) return []; if (!this.areCalculationsPossible(setting)) return [];
var valueAttribute = this.props.getValueAttribute(settingName), var valueAttribute = this.props.getValueAttribute(settingName),
valuesToCheck = this.getValuesToCheck(setting, valueAttribute), valuesToCheck = this.getValuesToCheck(setting, valueAttribute),
pathToCheck = this.props.makePath(path, valueAttribute), pathToCheck = this.props.makePath(path, valueAttribute),
@ -360,7 +360,7 @@ function($, _, i18n, React, utils, models, Expression, componentMixins, controls
checkDependentSettings: function(groupName, settingName) { checkDependentSettings: function(groupName, settingName) {
var path = this.props.makePath(groupName, settingName), var path = this.props.makePath(groupName, settingName),
currentSetting = this.props.settings.get(path); currentSetting = this.props.settings.get(path);
if (!this.areCalсulationsPossible(currentSetting)) return []; if (!this.areCalculationsPossible(currentSetting)) return [];
var dependentRestrictions = {}; var dependentRestrictions = {};
var addDependentRestrictions = _.bind(function(pathToCheck, label) { var addDependentRestrictions = _.bind(function(pathToCheck, label) {
var result = _.filter(this.props.settings.expandedRestrictions[pathToCheck], function(restriction) { var result = _.filter(this.props.settings.expandedRestrictions[pathToCheck], function(restriction) {
@ -377,7 +377,7 @@ function($, _, i18n, React, utils, models, Expression, componentMixins, controls
_.each(group, function(setting, settingName) { _.each(group, function(setting, settingName) {
// we support dependecies on checkboxes, toggleable setting groups, dropdowns and radio groups // we support dependecies on checkboxes, toggleable setting groups, dropdowns and radio groups
var pathToCheck = this.props.makePath(groupName, settingName); var pathToCheck = this.props.makePath(groupName, settingName);
if (!this.areCalсulationsPossible(setting) || pathToCheck == path || this.props.checkRestrictions('hide', pathToCheck).result) return; if (!this.areCalculationsPossible(setting) || pathToCheck == path || this.props.checkRestrictions('hide', pathToCheck).result) return;
if (setting[this.props.getValueAttribute(settingName)] == true) { if (setting[this.props.getValueAttribute(settingName)] == true) {
addDependentRestrictions(pathToCheck, setting.label); addDependentRestrictions(pathToCheck, setting.label);
} else { } else {

View File

@ -92,7 +92,7 @@ function($, _, i18n, Backbone, React, utils, models, dispatcher, controls, compo
var classes = {'modal fade': true}; var classes = {'modal fade': true};
classes[this.props.modalClass] = this.props.modalClass; classes[this.props.modalClass] = this.props.modalClass;
return ( return (
<div className={utils.classNames(classes)} tabIndex="-1" onClick={this.closeOnLinkClick} onKeyDown={this.closeOnEscapeKey}> <div className={utils.classNames(classes)} tabIndex='-1' onClick={this.closeOnLinkClick} onKeyDown={this.closeOnEscapeKey}>
<div className='modal-dialog'> <div className='modal-dialog'>
<div className='modal-content'> <div className='modal-content'>
<div className='modal-header'> <div className='modal-header'>

View File

@ -340,7 +340,7 @@ function($, _, i18n, Backbone, React, utils, models, controls, componentMixins,
return ( return (
<div className='footer'> <div className='footer'>
{_.contains(version.get('feature_groups'), 'mirantis') && [ {_.contains(version.get('feature_groups'), 'mirantis') && [
<a key='logo' className="mirantis-logo-white" href='http://www.mirantis.com/' target='_blank'></a>, <a key='logo' className='mirantis-logo-white' href='http://www.mirantis.com/' target='_blank'></a>,
<div key='copyright'>{i18n('common.copyright')}</div> <div key='copyright'>{i18n('common.copyright')}</div>
]} ]}
<div key='version'>{i18n('common.version')}: {version.get('release')}</div> <div key='version'>{i18n('common.version')}: {version.get('release')}</div>