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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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