DEV: Fix `ember/require-super-in-lifecycle-hooks` (#24007)

and `ember/no-ember-super-in-es-classes`
This commit is contained in:
Jarek Radosz 2023-10-19 13:47:45 +02:00 committed by GitHub
parent ac30673b98
commit 24dc36cf91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 42 additions and 10 deletions

View File

@ -27,6 +27,7 @@ export default class AceEditor extends Component {
}
didRender() {
super.didRender(...arguments);
this._skipContentChangeEvent = false;
}
@ -160,9 +161,8 @@ export default class AceEditor extends Component {
}
willDestroyElement() {
if (this._darkModeListener) {
this._darkModeListener.removeListener(this.setAceTheme);
}
super.willDestroyElement(...arguments);
this._darkModeListener?.removeListener(this.setAceTheme);
}
@bind

View File

@ -53,6 +53,7 @@ export default class AdminGraph extends Component {
}
didInsertElement() {
super.didInsertElement(...arguments);
loadScript("/javascripts/Chart.min.js").then(() =>
this.refreshChart.apply(this)
);

View File

@ -117,6 +117,7 @@ export default class InstallTheme extends Component {
}
willDestroy() {
super.willDestroy(...arguments);
this.args.model.clearParams?.();
}

View File

@ -16,6 +16,7 @@ export default class MergeUsersProgress extends Component {
}
willDestroy() {
super.willDestroy(...arguments);
this.messageBus.unsubscribe("/merge_user", this.onMessage);
}

View File

@ -66,6 +66,7 @@ export default class DModalBody extends Component {
@action
willDestroy() {
super.willDestroy(...arguments);
this.appEvents.trigger("modal:body-dismissed");
}
}

View File

@ -44,6 +44,7 @@ export default Component.extend({
},
didInsertElement() {
this._super(...arguments);
this.appEvents.trigger("decorate-non-stream-cooked-element", this.element);
},
});

View File

@ -48,6 +48,7 @@ export default Component.extend({
},
willDestroyElement() {
this._super(...arguments);
this.router.off("routeDidChange", this, this.currentRouteChanged);
},

View File

@ -128,6 +128,7 @@ export default class BookmarkModal extends Component {
}
willDestroy() {
super.willDestroy(...arguments);
this._itsatrap?.destroy();
this._itsatrap = null;
KeyboardShortcuts.unpause();

View File

@ -84,6 +84,7 @@ export default Component.extend({
},
didInsertElement() {
this._super(...arguments);
WidgetClickHook.setupDocumentCallback();
this._rootNode = document.createElement("div");
@ -92,6 +93,7 @@ export default Component.extend({
},
willClearRender() {
this._super(...arguments);
const callbacks = _cleanCallbacks[this.widget];
if (callbacks) {
callbacks.forEach((cb) => cb(this._tree));
@ -106,6 +108,7 @@ export default Component.extend({
},
willDestroyElement() {
this._super(...arguments);
this._dispatched.forEach((evt) => {
const [eventName, caller] = evt;
this.appEvents.off(eventName, this, caller);
@ -198,6 +201,7 @@ export default Component.extend({
},
didUpdateAttrs() {
this._super(...arguments);
this.queueRerender();
},
});

View File

@ -6,6 +6,7 @@ import { afterRender } from "discourse-common/utils/decorators";
export default Component.extend({
didRender() {
this._super(...arguments);
this._loadOneboxes();
this._resolveUrls();
},

View File

@ -365,6 +365,7 @@ export default MountWidget.extend({
},
didUpdateAttrs() {
this._super(...arguments);
this._refresh({ force: true });
},

View File

@ -57,6 +57,7 @@ export default class Sidebar extends Component {
}
willDestroy() {
super.willDestroy(...arguments);
if (this.site.mobileView) {
document.removeEventListener("click", this.collapseSidebar);
}

View File

@ -18,6 +18,7 @@ export default class SidebarMoreSectionLinks extends Component {
}
willDestroy() {
super.willDestroy(...arguments);
this.#removeClickEventListener();
this.router.off("routeDidChange", this, this.#setActiveSectionLink);
}

View File

@ -20,9 +20,8 @@ export default class SectionLink extends Component {
@service currentUser;
willDestroy() {
if (this.args.willDestroy) {
this.args.willDestroy();
}
super.willDestroy(...arguments);
this.args.willDestroy?.();
}
didInsert(_element, [args]) {

View File

@ -25,9 +25,8 @@ export default class SidebarSection extends Component {
}
willDestroy() {
if (this.args.willDestroy) {
this.args.willDestroy();
}
super.willDestroy(...arguments);
this.args.willDestroy?.();
}
@action

View File

@ -53,6 +53,8 @@ export default class SidebarUserMessagesSection extends Component {
}
willDestroy() {
super.willDestroy(...arguments);
this.appEvents.off(
"page:changed",
this,

View File

@ -29,6 +29,7 @@ export default class SidebarUserTagsSection extends Component {
}
willDestroy() {
super.willDestroy(...arguments);
this.topicTrackingState.offStateChange(this.callbackId);
}

View File

@ -220,6 +220,8 @@ const SiteHeaderComponent = MountWidget.extend(
},
willRender() {
this._super(...arguments);
if (this.get("currentUser.staff")) {
document.body.classList.add("staff");
}

View File

@ -59,11 +59,15 @@ export default Component.extend({
this.toggleChevron();
this._updateA11yAttributes();
},
didRender() {
this._super(...arguments);
if (this.onActiveRender && this.chevronIcon) {
this.onActiveRender(this.element);
}
},
_updateA11yAttributes() {
let criteria = "";
const pressed = this.order === this.field;

View File

@ -161,6 +161,7 @@ export default Component.extend(CleansUp, {
},
willDestroyElement() {
this._super(...arguments);
this.appEvents.off("topic-entrance:show", this, "_show");
},

View File

@ -387,6 +387,8 @@ export default class TopicTimelineScrollArea extends Component {
}
willDestroy() {
super.willDestroy(...arguments);
if (!this.args.mobileView) {
this.intersectionObserver?.disconnect();
this.intersectionObserver = null;

View File

@ -10,7 +10,7 @@ export default class UserStatusPicker extends Component {
emojiPickerIsActive = false;
didInsertElement() {
this._super(...arguments);
super.didInsertElement(...arguments);
if (!this.status) {
this.set("status", {});

View File

@ -1923,6 +1923,7 @@ class PluginApi {
pluginId: `${mountedComponent}/${widgetKey}/${appEvent}`,
didInsertElement() {
// eslint-disable-next-line ember/no-ember-super-in-es-classes
this._super();
this.dispatch(appEvent, widgetKey);
},

View File

@ -15,6 +15,7 @@ acceptance("Acceptance | decorateCookedElement", function () {
return super(...arguments);
}
willDestroy() {
super.willDestroy(...arguments);
DemoComponent.eventLog.push("willDestroy");
}
}

View File

@ -68,18 +68,22 @@ class DemoComponent extends ClassicComponent {
}
didInsertElement() {
super.didInsertElement(...arguments);
DemoComponent.eventLog.push("didInsertElement");
}
willDestroyElement() {
super.willDestroyElement(...arguments);
DemoComponent.eventLog.push("willDestroyElement");
}
didReceiveAttrs() {
super.didReceiveAttrs(...arguments);
DemoComponent.eventLog.push("didReceiveAttrs");
}
willDestroy() {
super.willDestroy(...arguments);
DemoComponent.eventLog.push("willDestroy");
}
}

View File

@ -40,6 +40,7 @@ module("Integration | Helper | raw", function (hooks) {
</template>
willDestroy() {
super.willDestroy(...arguments);
willDestroyCalled = true;
}
}