Skip to content

Commit

Permalink
MOBILE-4362 lint: Solve deprecation linting
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyserver committed Oct 19, 2023
1 parent d6a19b6 commit b690668
Show file tree
Hide file tree
Showing 55 changed files with 199 additions and 133 deletions.
2 changes: 1 addition & 1 deletion src/addons/badges/services/badges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export type AddonBadgesUserBadge = {
targetframework?: string; // Target framework.
targetcode?: string; // Target code.
}[];
competencies?: { // @deprecatedonmoodle from 3.7. @since 3.6. In 3.7 it was renamed to alignment.
competencies?: { // @deprecatedonmoodle since 3.7. @since 3.6. In 3.7 it was renamed to alignment.
id?: number; // Alignment id.
badgeid?: number; // Badge id.
targetname?: string; // Target name.
Expand Down
2 changes: 1 addition & 1 deletion src/addons/calendar/pages/edit-event/edit-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ export class AddonCalendarEditEventPage implements OnInit, OnDestroy, CanLeave {
*/
async addReminder(): Promise<void> {
const formData = this.form.value;
const eventTime = CoreTimeUtils.convertToTimestamp(formData.timestart, true);
const eventTime = moment(formData.timestar).unix();

const reminderTime = await CoreDomUtils.openPopover<{timeBefore: number}>({
component: CoreRemindersSetReminderMenuComponent,
Expand Down
14 changes: 8 additions & 6 deletions src/addons/messages/services/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class AddonMessagesProvider {
* @param userId User ID of the person to add.
* @param siteId Site ID. If not defined, use current site.
* @returns Resolved when done.
* @deprecated since Moodle 3.6
* @deprecatedonmoodle since 3.6
*/
protected async addContact(userId: number, siteId?: string): Promise<void> {
const site = await CoreSites.getSite(siteId);
Expand Down Expand Up @@ -582,7 +582,7 @@ export class AddonMessagesProvider {
*
* @param siteId Site ID. If not defined, use current site.
* @returns Promise resolved with the WS data.
* @deprecated since Moodle 3.6
* @deprecatedonmoodle since 3.6
*/
async getAllContacts(siteId?: string): Promise<AddonMessagesGetContactsWSResponse> {
siteId = siteId || CoreSites.getCurrentSiteId();
Expand Down Expand Up @@ -634,7 +634,7 @@ export class AddonMessagesProvider {
*
* @param siteId Site ID. If not defined, use current site.
* @returns Promise resolved with the WS data.
* @deprecated since Moodle 3.6
* @deprecatedonmoodle since 3.6
*/
async getContacts(siteId?: string): Promise<AddonMessagesGetContactsWSResponse> {
const site = await CoreSites.getSite(siteId);
Expand Down Expand Up @@ -2120,7 +2120,7 @@ export class AddonMessagesProvider {
*
* @param userIdFrom User Id for the sender.
* @returns Promise resolved with boolean marking success or not.
* @deprecated since Moodle 3.6
* @deprecatedonmoodle since 3.6
*/
async markAllMessagesRead(userIdFrom?: number): Promise<boolean> {
const params: AddonMessagesMarkAllMessagesAsReadWSParams = {
Expand Down Expand Up @@ -3049,12 +3049,14 @@ export type AddonMessagesMessagePreferencesNotificationProcessor = {
lockedmessage?: string; // @since 3.6. Text to display if locked.
userconfigured: number; // Is configured?.
enabled?: boolean; // @since 4.0. Processor enabled.
loggedin: AddonNotificationsPreferencesNotificationProcessorState; // @deprecated removed on 4.0.
loggedoff: AddonNotificationsPreferencesNotificationProcessorState; // @deprecated removed on 4.0.
loggedin: AddonNotificationsPreferencesNotificationProcessorState; // @deprecatedonmoodle since 4.0.
loggedoff: AddonNotificationsPreferencesNotificationProcessorState; // @deprecatedonmoodle since 4.0.
};

/**
* Message discussion (before 3.6).
*
* @deprecatedonmoodle since 3.6.
*/
export type AddonMessagesDiscussion = {
fullname: string; // Full name of the other user in the discussion.
Expand Down
4 changes: 2 additions & 2 deletions src/addons/notifications/pages/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy {
}

/**
* Page destroyed.
* @inheritdoc
*/
ngOnDestroy(): void {
// If there is a pending action to update preferences, execute it right now.
Expand All @@ -347,7 +347,7 @@ export class AddonNotificationsSettingsPage implements OnInit, OnDestroy {
/**
* State in notification processor in notification preferences component with some calculated data.
*
* @deprecated 4.0
* @deprecatedonmoodle since 4.0
*/
type ProcessorStateFormatted = AddonNotificationsPreferencesNotificationProcessorState & {
updating?: boolean; // Calculated in the app. Whether the state is being updated.
Expand Down
6 changes: 3 additions & 3 deletions src/addons/notifications/services/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,14 @@ export type AddonNotificationsPreferencesNotificationProcessor = {
lockedmessage?: string; // @since 3.6. Text to display if locked.
userconfigured: number; // Is configured?.
enabled?: boolean; // @since 4.0. Processor enabled.
loggedin: AddonNotificationsPreferencesNotificationProcessorState; // @deprecated removed on 4.0.
loggedoff: AddonNotificationsPreferencesNotificationProcessorState; // @deprecated removed on 4.0.
loggedin: AddonNotificationsPreferencesNotificationProcessorState; // @deprecatedonmoodle since 4.0.
loggedoff: AddonNotificationsPreferencesNotificationProcessorState; // @deprecatedonmoodle since 4.0.
};

/**
* State in notification processor in notification preferences component.
*
* @deprecated removed on 4.0.
* @deprecatedonmoodle since 4.0
*/
export type AddonNotificationsPreferencesNotificationProcessorState = {
name: 'loggedoff' | 'loggedin'; // Name.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

import { ElementController } from './ElementController';

/**
* Possible types of frame elements.
*
* @todo Remove frame TAG support.
*/
export type FrameElement = HTMLIFrameElement | HTMLFrameElement | HTMLObjectElement | HTMLEmbedElement;

/**
Expand Down
5 changes: 4 additions & 1 deletion src/core/classes/errors/ajaxerror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import { CoreSiteError, CoreSiteErrorOptions } from '@classes/errors/siteerror';
*/
export class CoreAjaxError extends CoreSiteError {

available = 1; // @deprecated since app 4.0. AJAX endpoint should always be available in supported Moodle versions.
/**
* @deprecated since 4.0. AJAX endpoint should always be available in supported Moodle versions.
*/
available = 1;
status?: number;

constructor(messageOrOptions: string | CoreSiteErrorOptions, available?: number, status?: number) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/classes/promised-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class CorePromisedValue<T = unknown> extends CorePromise<T> {

/**
* @returns Promise.
* @deprecated since app 4.1. The instance can be directly used as a promise.
* @deprecated since 4.1. The instance can be directly used as a promise.
*/
get promise(): Promise<T> {
return this;
Expand Down
11 changes: 6 additions & 5 deletions src/core/classes/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1607,8 +1607,9 @@ export class CoreSite {
* Check if the local_mobile plugin is installed in the Moodle site.
*
* @returns Promise resolved when the check is done.
* @deprecated since app 4.0
* @deprecated since 4.0.
*/
// eslint-disable-next-line deprecation/deprecation
async checkLocalMobilePlugin(): Promise<LocalMobileResponse> {
// Not used anymore.
return { code: 0, coreSupported: true };
Expand All @@ -1618,7 +1619,7 @@ export class CoreSite {
* Check if local_mobile has been installed in Moodle.
*
* @returns Whether the App is able to use local_mobile plugin for this site.
* @deprecated since app 4.0
* @deprecated since 4.0.
*/
checkIfAppUsesLocalMobile(): boolean {
return false;
Expand All @@ -1628,7 +1629,7 @@ export class CoreSite {
* Check if local_mobile has been installed in Moodle but the app is not using it.
*
* @returns Promise resolved it local_mobile was added, rejected otherwise.
* @deprecated since app 4.0
* @deprecated since 4.0.
*/
async checkIfLocalMobileInstalledAndNotUsed(): Promise<void> {
throw new CoreError('Deprecated.');
Expand Down Expand Up @@ -2125,7 +2126,7 @@ export class CoreSite {
CoreConstants.SECONDS_MINUTE * 6,
);

if (CoreTimeUtils.timestamp() - this.lastAutoLogin < timeBetweenRequests) {
if (CoreTimeUtils.timestamp() - this.lastAutoLogin < Number(timeBetweenRequests)) {
// Not enough time has passed since last auto login.
return url;
}
Expand Down Expand Up @@ -2626,7 +2627,7 @@ export type CoreSiteWSPreSets = {
/**
* Response of checking local_mobile status.
*
* @deprecated since app 4.0
* @deprecated since 4.0.
*/
export type LocalMobileResponse = {
/**
Expand Down
5 changes: 3 additions & 2 deletions src/core/components/context-menu/context-menu-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ export class CoreContextMenuItemComponent implements OnInit, OnDestroy, OnChange
@Output() toggleChange = new EventEmitter<boolean>();// Will emit an event when toggle changes to enable 2-way data binding.

/**
* @deprecated since 4.0.
* @deprecated since 4.0. Not used anymore.
*/
@Input() iconDescription?: string; // Name of the icon to be shown on the left side of the item. Not used anymore.
@Input() iconDescription?: string;

protected hasAction = false;
protected destroyed = false;
Expand Down Expand Up @@ -93,6 +93,7 @@ export class CoreContextMenuItemComponent implements OnInit, OnDestroy, OnChange
this.ctxtMenu.addItem(this);
}

// eslint-disable-next-line deprecation/deprecation
if (this.iconDescription !== undefined) {
CoreLogger.getInstance('CoreContextMenuItemComponent')
.warn('iconDescription Input is deprecated and should not be used');
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/download-refresh/download-refresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class CoreDownloadRefreshComponent {
@Input() enabled = false; // Whether the download is enabled.
@Input() loading = true; // Force loading status when is not downloading.
/**
* @deprecated since 4.0. It has no effect.
* @deprecated since 4.0. Not used anymore.
*/
@Input() size = ''; // Size of the buttons.
@Input() canTrustDownload = false; // If false, refresh will be shown if downloaded.
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/empty-box/empty-box.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class CoreEmptyBoxComponent {
@Input() flipIconRtl = false; // Whether to flip the icon in RTL. Defaults to false.

/**
* @deprecated not used anymore.
* @deprecated since 4.0. Not used anymore.
*/
@Input() inline = false;

Expand Down
1 change: 1 addition & 0 deletions src/core/components/loading/loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ export class CoreLoadingComponent implements OnInit, OnChanges, AfterViewInit, A
}

// Event has been deprecated since app 4.0.
// eslint-disable-next-line deprecation/deprecation
CoreEvents.trigger(CoreEvents.CORE_LOADING_CHANGED, <CoreEventLoadingChangedData> {
loaded,
uniqueId: this.uniqueId,
Expand Down
4 changes: 2 additions & 2 deletions src/core/components/mod-icon/mod-icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class CoreModIconComponent implements OnInit, OnChanges {
isLocalUrl = true;
linkIconWithComponent = false;

protected legacyIcon = true; // @deprecatedonmoodle since Moodle 3.11.
protected legacyIcon = true; // @deprecatedonmoodle since 3.11.

constructor(protected el: ElementRef) { }

Expand Down Expand Up @@ -122,7 +122,7 @@ export class CoreModIconComponent implements OnInit, OnChanges {

let path = assetsPath + 'mod/';
if (this.legacyIcon) {
// @deprecatedonmoodle since Moodle 3.11.
// @deprecatedonmoodle since 3.11.
path = assetsPath + 'mod_legacy/';
}

Expand Down
5 changes: 4 additions & 1 deletion src/core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ export class CoreConstants {
// WS constants.
static readonly WS_TIMEOUT = 30000; // Timeout when not in WiFi.
static readonly WS_TIMEOUT_WIFI = 30000; // Timeout when in WiFi.
static readonly WS_PREFIX = 'local_mobile_'; // @deprecated since app 4.0.
/**
* @deprecated since 4.0. Not used anymore.
*/
static readonly WS_PREFIX = 'local_mobile_';

// Login constants.
/**
Expand Down
20 changes: 15 additions & 5 deletions src/core/directives/format-text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ import { CoreRefreshContext, CORE_REFRESH_CONTEXT } from '@/core/utils/refresh-c
import { CorePlatform } from '@services/platform';
import { ElementController } from '@classes/element-controllers/ElementController';
import { MediaElementController } from '@classes/element-controllers/MediaElementController';
import { FrameElementController } from '@classes/element-controllers/FrameElementController';
import { FrameElement, FrameElementController } from '@classes/element-controllers/FrameElementController';
import { CoreUrl } from '@singletons/url';
import { CoreIcons } from '@singletons/icons';

Expand Down Expand Up @@ -90,12 +90,20 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncDirec
@Input() hideIfEmpty = false; // If true, the tag will contain nothing if text is empty.
@Input() disabled?: boolean; // If disabled, autoplay elements will be disabled.

@Input() fullOnClick?: boolean | string; // @deprecated on 4.0 Won't do anything.
@Input() fullTitle?: string; // @deprecated on 4.0 Won't do anything.
/**
* @deprecated since 4.0. Not used anymore.
*/
@Input() fullOnClick?: boolean | string;
/**
* @deprecated since 4.0. Not used anymore.
*/
@Input() fullTitle?: string;
/**
* Max height in pixels to render the content box. It should be 50 at least to make sense.
*
* @deprecated since 4.0 Use collapsible-item directive instead.
*/
@Input() maxHeight?: number; // @deprecated on 4.0 Use collapsible-item directive instead.
@Input() maxHeight?: number;

@Output() afterRender: EventEmitter<void>; // Called when the data is rendered.
@Output() onClick: EventEmitter<void> = new EventEmitter(); // Called when clicked.
Expand Down Expand Up @@ -373,8 +381,10 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncDirec
await CoreUtils.nextTick();

// Use collapsible-item directive instead.
// eslint-disable-next-line deprecation/deprecation
if (this.maxHeight && !this.collapsible) {
this.collapsible = new CoreCollapsibleItemDirective(new ElementRef(this.element));
// eslint-disable-next-line deprecation/deprecation
this.collapsible.height = this.maxHeight;
this.collapsible.ngOnInit();
}
Expand Down Expand Up @@ -574,7 +584,7 @@ export class CoreFormatTextDirective implements OnChanges, OnDestroy, AsyncDirec
});

// Handle all kind of frames.
const frameControllers = frames.map((frame: HTMLFrameElement | HTMLObjectElement | HTMLEmbedElement) => {
const frameControllers = frames.map((frame: FrameElement) => {
CoreIframeUtils.treatFrame(frame, false);

return new FrameElementController(frame, !this.disabled);
Expand Down
5 changes: 3 additions & 2 deletions src/core/features/compile/services/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,11 @@ export class CoreCompileProvider {
instance['CoreLoggerProvider'] = CoreLogger;
instance['moment'] = moment;
instance['Md5'] = Md5;
instance['Network'] = CoreNetwork.instance; // @deprecated on 4.1, plugins should use CoreNetwork instead.
instance['Platform'] = CorePlatform.instance; // @deprecated on 4.1, plugins should use CorePlatform instead.
instance['Network'] = CoreNetwork.instance; // @deprecated since 4.1, plugins should use CoreNetwork instead.
instance['Platform'] = CorePlatform.instance; // @deprecated since 4.1, plugins should use CorePlatform instead.
instance['CoreSyncBaseProvider'] = CoreSyncBaseProvider;
instance['CoreArray'] = CoreArray;
// eslint-disable-next-line deprecation/deprecation
instance['CoreComponentsRegistry'] = CoreComponentsRegistry;
instance['CoreDirectivesRegistry'] = CoreDirectivesRegistry;
instance['CoreNetwork'] = CoreNetwork.instance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class CoreContentLinksModuleIndexHandler extends CoreContentLinksHandlerB
* @param params The params of the URL. E.g. 'mysite.com?id=1' -> {id: 1}
* @param courseId Course ID related to the URL. Optional but recommended.
* @returns List of params to pass to navigateToModule / navigateToModuleByInstance.
* @deprecated since 4.0
* @deprecated since 4.0. Not used anymore.
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
getPageParams(url: string, params: Record<string, string>, courseId?: number): Params {
Expand Down Expand Up @@ -101,6 +101,7 @@ export class CoreContentLinksModuleIndexHandler extends CoreContentLinksHandlerB
let modNavOptions = this.getModNavOptions(url, params, siteId, courseId);
if (!modNavOptions) {
// Use the old function, currently deprecated.
// eslint-disable-next-line deprecation/deprecation
const pageParams = this.getPageParams(url, params, courseId);
if (pageParams && Object.keys(pageParams).length > 0) {
modNavOptions = { params: pageParams };
Expand Down
4 changes: 4 additions & 0 deletions src/core/features/course/components/components.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ import { CoreCourseModuleCompletionDetailsComponent } from './module-completion-
CoreCourseModuleComponent,
CoreCourseModuleCompletionComponent,
CoreCourseModuleCompletionLegacyComponent,
// eslint-disable-next-line deprecation/deprecation
CoreCourseModuleDescriptionComponent,
CoreCourseModuleInfoComponent,
// eslint-disable-next-line deprecation/deprecation
CoreCourseModuleManualCompletionComponent,
CoreCourseCourseIndexComponent,
CoreCourseCourseIndexTourComponent,
Expand All @@ -59,8 +61,10 @@ import { CoreCourseModuleCompletionDetailsComponent } from './module-completion-
CoreCourseModuleComponent,
CoreCourseModuleCompletionComponent,
CoreCourseModuleCompletionLegacyComponent,
// eslint-disable-next-line deprecation/deprecation
CoreCourseModuleDescriptionComponent,
CoreCourseModuleInfoComponent,
// eslint-disable-next-line deprecation/deprecation
CoreCourseModuleManualCompletionComponent,
CoreCourseCourseIndexComponent,
CoreCourseCourseIndexTourComponent,
Expand Down
1 change: 1 addition & 0 deletions src/core/features/course/components/module/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export class CoreCourseModuleComponent implements OnInit, OnDestroy {
* @param event Click event.
*/
buttonClicked(event: Event): void {
// eslint-disable-next-line deprecation/deprecation
const button = this.module.handlerData?.button ?? this.module.handlerData?.buttons?.[0];
if (!button || !button.action) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ export class CoreCourseSummaryPage implements OnInit, OnDestroy {
promises.push(CoreCourseOptionsDelegate.clearAndInvalidateCoursesOptions(this.courseId));
promises.push(CoreCourses.invalidateCoursesByField('id', this.courseId));

// eslint-disable-next-line deprecation/deprecation
promises.push(CoreCourses.invalidateCourseEnrolmentMethods(this.courseId));

this.selfEnrolInstances.forEach((method) => {
Expand Down
Loading

0 comments on commit b690668

Please sign in to comment.