Sanity-check decaffeinate app.collections.Types

pull/1441/head
Simon Legner 1 year ago
parent e5f852e7c0
commit 7e4d5b9fd5

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

Loading…
Cancel
Save