Browse Source

Sanity-check decaffeinate app.collections.Types

Simon Legner 1 year ago
parent
commit
7e4d5b9fd5
1 changed files with 21 additions and 35 deletions
  1. 21 35
      assets/javascripts/collections/types.js

+ 21 - 35
assets/javascripts/collections/types.js

@@ -2,45 +2,31 @@
 // Sanity-check the conversion and remove this comment.
 /*
  * decaffeinate suggestions:
- * DS101: Remove unnecessary use of Array.from
- * DS102: Remove unnecessary code created because of implicit returns
  * DS104: Avoid inline assignments
- * DS206: Consider reworking classes to avoid initClass
  * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
  */
-(function () {
-  let GUIDES_RGX = undefined;
-  let APPENDIX_RGX = undefined;
-  app.collections.Types = class Types extends app.Collection {
-    static initClass() {
-      this.model = "Type";
+app.collections.Types = class Types extends app.Collection {
+  static model = "Type";
+  static GUIDES_RGX =
+    /(^|\()(guides?|tutorials?|reference|book|getting\ started|manual|examples)($|[\):])/i;
+  static APPENDIX_RGX = /appendix/i;
 
-      GUIDES_RGX =
-        /(^|\()(guides?|tutorials?|reference|book|getting\ started|manual|examples)($|[\):])/i;
-      APPENDIX_RGX = /appendix/i;
+  groups() {
+    const result = [];
+    for (var type of this.models) {
+      var name;
+      (result[(name = this._groupFor(type))] || (result[name] = [])).push(type);
     }
+    return result.filter((e) => e.length > 0);
+  }
 
-    groups() {
-      const result = [];
-      for (var type of Array.from(this.models)) {
-        var name;
-        (result[(name = this._groupFor(type))] || (result[name] = [])).push(
-          type,
-        );
-      }
-      return result.filter((e) => e.length > 0);
+  _groupFor(type) {
+    if (Types.GUIDES_RGX.test(type.name)) {
+      return 0;
+    } else if (Types.APPENDIX_RGX.test(type.name)) {
+      return 2;
+    } else {
+      return 1;
     }
-
-    _groupFor(type) {
-      if (GUIDES_RGX.test(type.name)) {
-        return 0;
-      } else if (APPENDIX_RGX.test(type.name)) {
-        return 2;
-      } else {
-        return 1;
-      }
-    }
-  };
-  app.collections.Types.initClass();
-  return app.collections.Types;
-})();
+  }
+};