From 7f2751bb4fef88beef112c74b78b3f5c50b192c6 Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Thu, 22 Oct 2020 12:32:32 +0200 Subject: [PATCH] MOBILE-3320 lint: Fix linting errors --- .eslintrc.js | 8 +------- src/app/core/login/services/helper.ts | 8 +++++++- src/app/directives/format-text.ts | 11 ++++++++--- src/app/services/file-helper.ts | 24 ++++++++++++++++++++---- src/app/services/utils/dom.ts | 8 +++++--- src/app/services/utils/utils.ts | 2 ++ 6 files changed, 43 insertions(+), 18 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 842a24fc9..19d6f58e5 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -173,12 +173,6 @@ const appConfig = { ], 'id-match': 'error', 'jsdoc/check-alignment': 'error', - 'jsdoc/check-indentation': [ - 'error', - { - excludeTags: ['param'], - }, - ], 'jsdoc/newline-after-description': 'error', 'linebreak-style': [ 'error', @@ -274,7 +268,7 @@ module.exports = { files: ['*.html'], extends: ['plugin:@angular-eslint/template/recommended'], rules: { - 'max-len': ['error', { code: 140 }], + 'max-len': ['warn', { code: 140 }], }, }, { diff --git a/src/app/core/login/services/helper.ts b/src/app/core/login/services/helper.ts index 02b8a2b1c..b01d6437e 100644 --- a/src/app/core/login/services/helper.ts +++ b/src/app/core/login/services/helper.ts @@ -28,7 +28,7 @@ import { CoreTextUtils } from '@services/utils/text'; import { CoreUrlParams, CoreUrlUtils } from '@services/utils/url'; import { CoreUtils } from '@services/utils/utils'; import { CoreConstants } from '@core/constants'; -import { CoreSite, CoreSiteConfig, CoreSiteIdentityProvider, CoreSitePublicConfigResponse } from '@classes/site'; +import { CoreSite, CoreSiteIdentityProvider, CoreSitePublicConfigResponse } from '@classes/site'; import { CoreError } from '@classes/errors/error'; import { CoreWSError } from '@classes/errors/wserror'; import { makeSingleton, Translate } from '@singletons/core.singletons'; @@ -447,6 +447,7 @@ export class CoreLoginHelperProvider { * @param params Params of the page. * @return Promise resolved when done. */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars goToNoSitePage(navCtrl: NavController, page: string, params?: Params): Promise { // @todo return Promise.resolve(); @@ -462,6 +463,7 @@ export class CoreLoginHelperProvider { * @param url URL to open once the main menu is loaded. * @return Promise resolved when done. */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars goToSiteInitialPage(navCtrl?: NavController, page?: string, params?: Params, options?: any, url?: string): Promise { // @todo return Promise.resolve(); @@ -628,6 +630,7 @@ export class CoreLoginHelperProvider { * @param siteId Site to load. * @return Promise resolved when done. */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars protected loadSiteAndPage(page: string, params: Params, siteId: string): Promise { // @todo return Promise.resolve(); @@ -668,6 +671,7 @@ export class CoreLoginHelperProvider { * @param url URL to open once the main menu is loaded. * @return Promise resolved when done. */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars protected openMainMenu(navCtrl: NavController, page: string, params: Params, options?: any, url?: string): Promise { // @todo return Promise.resolve(); @@ -827,6 +831,7 @@ export class CoreLoginHelperProvider { * * @param siteId The site ID. */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars passwordChangeForced(siteId: string): void { // @todo } @@ -885,6 +890,7 @@ export class CoreLoginHelperProvider { * @param siteId Site to load. If not defined, current site. * @return Promise resolved when done. */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars async redirect(page: string, params?: Params, siteId?: string): Promise { // @todo } diff --git a/src/app/directives/format-text.ts b/src/app/directives/format-text.ts index e12d6479d..a1ff7c33d 100644 --- a/src/app/directives/format-text.ts +++ b/src/app/directives/format-text.ts @@ -46,9 +46,6 @@ export class CoreFormatTextDirective implements OnChanges { @Input() adaptImg?: boolean | string = true; // Whether to adapt images to screen width. @Input() clean?: boolean | string; // Whether all the HTML tags should be removed. @Input() singleLine?: boolean | string; // Whether new lines should be removed (all text in single line). Only if clean=true. - @Input() maxHeight?: number; // Max height in pixels to render the content box. It should be 50 at least to make sense. - // Using this parameter will force display: block to calculate height better. - // If you want to avoid this use class="inline" at the same time to use display: inline-block. @Input() fullOnClick?: boolean | string; // Whether it should open a new page with the full contents on click. @Input() fullTitle?: string; // Title to use in full view. Defaults to "Description". @Input() highlight?: string; // Text to highlight. @@ -57,6 +54,14 @@ export class CoreFormatTextDirective implements OnChanges { @Input() contextInstanceId?: number; // The instance ID related to the context. @Input() courseId?: number; // Course ID the text belongs to. It can be used to improve performance with filters. @Input() wsNotFiltered?: boolean | string; // If true it means the WS didn't filter the text for some reason. + + /** + * Max height in pixels to render the content box. It should be 50 at least to make sense. + * Using this parameter will force display: block to calculate height better. + * If you want to avoid this use class="inline" at the same time to use display: inline-block. + */ + @Input() maxHeight?: number; + @Output() afterRender: EventEmitter; // Called when the data is rendered. protected element: HTMLElement; diff --git a/src/app/services/file-helper.ts b/src/app/services/file-helper.ts index ae7842ebd..336c6cc91 100644 --- a/src/app/services/file-helper.ts +++ b/src/app/services/file-helper.ts @@ -174,7 +174,15 @@ export class CoreFileHelperProvider { } else { // Outdated but offline, so we return the local URL. return CoreFilepool.instance.getUrlByUrl( - siteId, fileUrl, component, componentId, timemodified, false, false, file); + siteId, + fileUrl, + component, + componentId, + timemodified, + false, + false, + file, + ); } } @@ -220,8 +228,17 @@ export class CoreFileHelperProvider { } try { - return await CoreFilepool.instance.downloadUrl(siteId, fileUrl, false, component, componentId, timemodified, - onProgress, undefined, file); + return await CoreFilepool.instance.downloadUrl( + siteId, + fileUrl, + false, + component, + componentId, + timemodified, + onProgress, + undefined, + file, + ); } catch (error) { // Download failed, check the state again to see if the file was downloaded before. const state = await CoreFilepool.instance.getFileStateByUrl(siteId, fileUrl, timemodified); @@ -405,4 +422,3 @@ export class CoreFileHelperProvider { export class CoreFileHelper extends makeSingleton(CoreFileHelperProvider) {} export type CoreFileHelperOnProgress = (event?: ProgressEvent | { calculating: true }) => void; - diff --git a/src/app/services/utils/dom.ts b/src/app/services/utils/dom.ts index b2e617bb6..418168858 100644 --- a/src/app/services/utils/dom.ts +++ b/src/app/services/utils/dom.ts @@ -86,7 +86,7 @@ export class CoreDomUtilsProvider { if (!element) { return null; } - + // Try to use closest if the browser supports it. if (typeof element.closest == 'function') { return element.closest(selector); @@ -363,8 +363,8 @@ export class CoreDomUtilsProvider { fixHtml(html: string): string { this.template.innerHTML = html; - const attrNameRegExp = /[^\x00-\x20\x7F-\x9F"'>\/=]+/; - + // eslint-disable-next-line no-control-regex + const attrNameRegExp = /[^\x00-\x20\x7F-\x9F"'>/=]+/; const fixElement = (element: Element): void => { // Remove attributes with an invalid name. Array.from(element.attributes).forEach((attr) => { @@ -1547,6 +1547,7 @@ export class CoreDomUtilsProvider { * @param placeholder Placeholder of the input element if any. * @return Promise resolved when modal presented. */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars showTextareaPrompt(title: string, message: string, buttons: (string | any)[], placeholder?: string): Promise { // @todo return Promise.resolve(); @@ -1661,6 +1662,7 @@ export class CoreDomUtilsProvider { * @param componentId An ID to use in conjunction with the component. * @param fullScreen Whether the modal should be full screen. */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars viewImage(image: string, title?: string | null, component?: string, componentId?: string | number, fullScreen?: boolean): void { // @todo } diff --git a/src/app/services/utils/utils.ts b/src/app/services/utils/utils.ts index eb77397e0..66de0a607 100644 --- a/src/app/services/utils/utils.ts +++ b/src/app/services/utils/utils.ts @@ -1491,7 +1491,9 @@ export class CoreUtilsProvider { * @param title Title of the modal. Defaults to "QR reader". * @return Promise resolved with the captured text or undefined if cancelled or error. */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars scanQR(title?: string): Promise { + // eslint-disable-next-line @typescript-eslint/no-unused-vars return new Promise((resolve, reject): void => { // @todo });