You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by am...@apache.org on 2018/01/03 17:12:24 UTC

[couchdb-fauxton] 06/06: Enforce no-else-return rule and fix issues

This is an automated email from the ASF dual-hosted git repository.

amaranhao pushed a commit to branch upgrade-to-eslint-v4
in repository https://gitbox.apache.org/repos/asf/couchdb-fauxton.git

commit 9223b694a8774808d264eb6c1520eff83210a1d9
Author: Antonio Maranhao <an...@Antonios-MacBook-Pro.local>
AuthorDate: Wed Jan 3 12:03:50 2018 -0500

    Enforce no-else-return rule and fix issues
---
 .eslintrc                                          |  1 +
 app/addons/cluster/resources.js                    |  3 +-
 app/addons/config/components.js                    | 55 +++++++++++-----------
 app/addons/databases/resources.js                  |  4 +-
 .../index-editor/components/DesignDocSelector.js   |  4 +-
 .../index-results/actions/queryoptions.js          | 12 ++---
 app/addons/documents/index-results/reducers.js     |  4 +-
 app/addons/setup/resources.js                      |  4 +-
 app/addons/setup/setup.js                          |  4 +-
 9 files changed, 45 insertions(+), 46 deletions(-)

diff --git a/.eslintrc b/.eslintrc
index 94c549f..64fb232 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -24,6 +24,7 @@
     "indent": ["error", 2, { "SwitchCase": 1, "VariableDeclarator": { "var": 2, "let": 2, "const": 3 } }],
     "no-case-declarations": "off",
     "no-console": [1, { "allow": ["warn", "error", "info"] }],
+    "no-else-return": "error",
     "no-mixed-spaces-and-tabs": ["error", "smart-tabs"],
     "no-trailing-spaces": "error",
     "semi-spacing": ["error", {"before": false, "after": true}],
diff --git a/app/addons/cluster/resources.js b/app/addons/cluster/resources.js
index cb74aeb..675c8ac 100644
--- a/app/addons/cluster/resources.js
+++ b/app/addons/cluster/resources.js
@@ -19,9 +19,8 @@ Cluster.ClusterNodes = Backbone.Model.extend({
   url: function (context) {
     if (context === 'apiurl') {
       return window.location.origin + '/_membership';
-    } else {
-      return app.host + '/_membership';
     }
+    return app.host + '/_membership';
   },
 
   parse: function (res) {
diff --git a/app/addons/config/components.js b/app/addons/config/components.js
index ef30b0d..0a9b8ea 100644
--- a/app/addons/config/components.js
+++ b/app/addons/config/components.js
@@ -67,16 +67,15 @@ class ConfigTableController extends React.Component {
           <Components.LoadLines />
         </div>
       );
-    } else {
-      return (
-        <ConfigTable
-          onDeleteOption={this.deleteOption}
-          onSaveOption={this.saveOption}
-          onEditOption={this.editOption}
-          onCancelEdit={this.cancelEdit}
-          options={this.state.options}/>
-      );
     }
+    return (
+      <ConfigTable
+        onDeleteOption={this.deleteOption}
+        onSaveOption={this.saveOption}
+        onEditOption={this.editOption}
+        onCancelEdit={this.cancelEdit}
+        options={this.state.options}/>
+    );
   }
 }
 
@@ -189,20 +188,20 @@ class ConfigOptionValue extends React.Component {
   getButtons = () => {
     if (this.state.saving) {
       return null;
-    } else {
-      return (
-        <span>
-          <button
-            className="btn btn-primary fonticon-ok-circled btn-small btn-config-save"
-            onClick={this.onSave.bind(this)}
-          />
-          <button
-            className="btn fonticon-cancel-circled btn-small btn-config-cancel"
-            onClick={this.props.onCancelEdit}
-          />
-        </span>
-      );
     }
+    return (
+      <span>
+        <button
+          className="btn btn-primary fonticon-ok-circled btn-small btn-config-save"
+          onClick={this.onSave.bind(this)}
+        />
+        <button
+          className="btn fonticon-cancel-circled btn-small btn-config-cancel"
+          onClick={this.props.onCancelEdit}
+        />
+      </span>
+    );
+
   };
 
   render() {
@@ -220,13 +219,13 @@ class ConfigOptionValue extends React.Component {
           </div>
         </td>
       );
-    } else {
-      return (
-        <td className="config-show-value" onClick={this.props.onEdit}>
-          {this.props.value}
-        </td>
-      );
     }
+    return (
+      <td className="config-show-value" onClick={this.props.onEdit}>
+        {this.props.value}
+      </td>
+    );
+
   }
 }
 
diff --git a/app/addons/databases/resources.js b/app/addons/databases/resources.js
index 639bc0d..dfb9c46 100644
--- a/app/addons/databases/resources.js
+++ b/app/addons/databases/resources.js
@@ -54,9 +54,9 @@ Databases.Model = FauxtonAPI.Model.extend({
       return FauxtonAPI.urls('changes', 'apiurl', this.safeID(), '?descending=true&limit=100&include_docs=true');
     } else if (context === "app") {
       return "/database/" + this.safeID();
-    } else {
-      return app.host + "/" + this.safeID();
     }
+    return app.host + "/" + this.safeID();
+
   },
 
   safeID: function () {
diff --git a/app/addons/documents/index-editor/components/DesignDocSelector.js b/app/addons/documents/index-editor/components/DesignDocSelector.js
index 0be5b10..fef9817 100644
--- a/app/addons/documents/index-editor/components/DesignDocSelector.js
+++ b/app/addons/documents/index-editor/components/DesignDocSelector.js
@@ -42,9 +42,9 @@ export default class DesignDocSelector extends Component {
       return this.props.designDocList.map ((designDoc) => {
         return (<option key={designDoc} value={designDoc}>{designDoc}</option>);
       });
-    } else {
-      return [];
     }
+    return [];
+
   }
 
   selectDesignDoc(e) {
diff --git a/app/addons/documents/index-results/actions/queryoptions.js b/app/addons/documents/index-results/actions/queryoptions.js
index 33c277d..60d21f7 100644
--- a/app/addons/documents/index-results/actions/queryoptions.js
+++ b/app/addons/documents/index-results/actions/queryoptions.js
@@ -43,13 +43,13 @@ export const queryOptionsToggleReduce = (previousReduce) => {
     return updateQueryOptions({
       reduce: !previousReduce
     });
-  } else {
-    // Disables includeDocs if reduce is changing to true
-    return updateQueryOptions({
-      reduce: !previousReduce,
-      includeDocs: false
-    });
   }
+  // Disables includeDocs if reduce is changing to true
+  return updateQueryOptions({
+    reduce: !previousReduce,
+    includeDocs: false
+  });
+
 };
 
 export const queryOptionsUpdateGroupLevel = (newGroupLevel) => {
diff --git a/app/addons/documents/index-results/reducers.js b/app/addons/documents/index-results/reducers.js
index 3263ea3..426a7da 100644
--- a/app/addons/documents/index-results/reducers.js
+++ b/app/addons/documents/index-results/reducers.js
@@ -196,9 +196,9 @@ export const getDataForRendering = (state, databaseName, deleteEnabled = true) =
 
   if (Constants.LAYOUT_ORIENTATION.JSON === options.selectedLayout) {
     return getJsonViewData(docsWithoutGeneratedMangoDocs, options);
-  } else {
-    return getTableViewData(docsWithoutGeneratedMangoDocs, options);
   }
+  return getTableViewData(docsWithoutGeneratedMangoDocs, options);
+
 };
 
 // Should we show the input checkbox where the user can elect to display
diff --git a/app/addons/setup/resources.js b/app/addons/setup/resources.js
index 609ca73..3f91a3e 100644
--- a/app/addons/setup/resources.js
+++ b/app/addons/setup/resources.js
@@ -23,9 +23,9 @@ Setup.Model = Backbone.Model.extend({
   url: function (context) {
     if (context === "apiurl") {
       return window.location.origin + "/_cluster_setup";
-    } else {
-      return '/_cluster_setup';
     }
+    return '/_cluster_setup';
+
   },
 
   validate: function (attrs) {
diff --git a/app/addons/setup/setup.js b/app/addons/setup/setup.js
index 281994d..fe1a59c 100644
--- a/app/addons/setup/setup.js
+++ b/app/addons/setup/setup.js
@@ -45,9 +45,9 @@ class ClusterConfiguredScreen extends React.Component {
       return 'clustered';
     } else if (this.state.clusterState === 'single_node_enabled') {
       return 'single';
-    } else {
-      return 'unknown state';
     }
+    return 'unknown state';
+
   };
 
   state = this.getStoreState();

-- 
To stop receiving notification emails like this one, please contact
"commits@couchdb.apache.org" <co...@couchdb.apache.org>.