MOBILE-3320 lint: Fix linting errors

main
Noel De Martin 2020-10-22 12:32:32 +02:00
parent 836e866443
commit 7f2751bb4f
6 changed files with 43 additions and 18 deletions

View File

@ -173,12 +173,6 @@ const appConfig = {
], ],
'id-match': 'error', 'id-match': 'error',
'jsdoc/check-alignment': 'error', 'jsdoc/check-alignment': 'error',
'jsdoc/check-indentation': [
'error',
{
excludeTags: ['param'],
},
],
'jsdoc/newline-after-description': 'error', 'jsdoc/newline-after-description': 'error',
'linebreak-style': [ 'linebreak-style': [
'error', 'error',
@ -274,7 +268,7 @@ module.exports = {
files: ['*.html'], files: ['*.html'],
extends: ['plugin:@angular-eslint/template/recommended'], extends: ['plugin:@angular-eslint/template/recommended'],
rules: { rules: {
'max-len': ['error', { code: 140 }], 'max-len': ['warn', { code: 140 }],
}, },
}, },
{ {

View File

@ -28,7 +28,7 @@ import { CoreTextUtils } from '@services/utils/text';
import { CoreUrlParams, CoreUrlUtils } from '@services/utils/url'; import { CoreUrlParams, CoreUrlUtils } from '@services/utils/url';
import { CoreUtils } from '@services/utils/utils'; import { CoreUtils } from '@services/utils/utils';
import { CoreConstants } from '@core/constants'; 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 { CoreError } from '@classes/errors/error';
import { CoreWSError } from '@classes/errors/wserror'; import { CoreWSError } from '@classes/errors/wserror';
import { makeSingleton, Translate } from '@singletons/core.singletons'; import { makeSingleton, Translate } from '@singletons/core.singletons';
@ -447,6 +447,7 @@ export class CoreLoginHelperProvider {
* @param params Params of the page. * @param params Params of the page.
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
goToNoSitePage(navCtrl: NavController, page: string, params?: Params): Promise<any> { goToNoSitePage(navCtrl: NavController, page: string, params?: Params): Promise<any> {
// @todo // @todo
return Promise.resolve(); return Promise.resolve();
@ -462,6 +463,7 @@ export class CoreLoginHelperProvider {
* @param url URL to open once the main menu is loaded. * @param url URL to open once the main menu is loaded.
* @return Promise resolved when done. * @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<any> { goToSiteInitialPage(navCtrl?: NavController, page?: string, params?: Params, options?: any, url?: string): Promise<any> {
// @todo // @todo
return Promise.resolve(); return Promise.resolve();
@ -628,6 +630,7 @@ export class CoreLoginHelperProvider {
* @param siteId Site to load. * @param siteId Site to load.
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
protected loadSiteAndPage(page: string, params: Params, siteId: string): Promise<any> { protected loadSiteAndPage(page: string, params: Params, siteId: string): Promise<any> {
// @todo // @todo
return Promise.resolve(); return Promise.resolve();
@ -668,6 +671,7 @@ export class CoreLoginHelperProvider {
* @param url URL to open once the main menu is loaded. * @param url URL to open once the main menu is loaded.
* @return Promise resolved when done. * @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<any> { protected openMainMenu(navCtrl: NavController, page: string, params: Params, options?: any, url?: string): Promise<any> {
// @todo // @todo
return Promise.resolve(); return Promise.resolve();
@ -827,6 +831,7 @@ export class CoreLoginHelperProvider {
* *
* @param siteId The site ID. * @param siteId The site ID.
*/ */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
passwordChangeForced(siteId: string): void { passwordChangeForced(siteId: string): void {
// @todo // @todo
} }
@ -885,6 +890,7 @@ export class CoreLoginHelperProvider {
* @param siteId Site to load. If not defined, current site. * @param siteId Site to load. If not defined, current site.
* @return Promise resolved when done. * @return Promise resolved when done.
*/ */
// eslint-disable-next-line @typescript-eslint/no-unused-vars
async redirect(page: string, params?: Params, siteId?: string): Promise<void> { async redirect(page: string, params?: Params, siteId?: string): Promise<void> {
// @todo // @todo
} }

View File

@ -46,9 +46,6 @@ export class CoreFormatTextDirective implements OnChanges {
@Input() adaptImg?: boolean | string = true; // Whether to adapt images to screen width. @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() 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() 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() 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() fullTitle?: string; // Title to use in full view. Defaults to "Description".
@Input() highlight?: string; // Text to highlight. @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() 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() 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. @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<void>; // Called when the data is rendered. @Output() afterRender: EventEmitter<void>; // Called when the data is rendered.
protected element: HTMLElement; protected element: HTMLElement;

View File

@ -174,7 +174,15 @@ export class CoreFileHelperProvider {
} else { } else {
// Outdated but offline, so we return the local URL. // Outdated but offline, so we return the local URL.
return CoreFilepool.instance.getUrlByUrl( 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 { try {
return await CoreFilepool.instance.downloadUrl(siteId, fileUrl, false, component, componentId, timemodified, return await CoreFilepool.instance.downloadUrl(
onProgress, undefined, file); siteId,
fileUrl,
false,
component,
componentId,
timemodified,
onProgress,
undefined,
file,
);
} catch (error) { } catch (error) {
// Download failed, check the state again to see if the file was downloaded before. // Download failed, check the state again to see if the file was downloaded before.
const state = await CoreFilepool.instance.getFileStateByUrl(siteId, fileUrl, timemodified); const state = await CoreFilepool.instance.getFileStateByUrl(siteId, fileUrl, timemodified);
@ -405,4 +422,3 @@ export class CoreFileHelperProvider {
export class CoreFileHelper extends makeSingleton(CoreFileHelperProvider) {} export class CoreFileHelper extends makeSingleton(CoreFileHelperProvider) {}
export type CoreFileHelperOnProgress = (event?: ProgressEvent | { calculating: true }) => void; export type CoreFileHelperOnProgress = (event?: ProgressEvent | { calculating: true }) => void;

View File

@ -86,7 +86,7 @@ export class CoreDomUtilsProvider {
if (!element) { if (!element) {
return null; return null;
} }
// Try to use closest if the browser supports it. // Try to use closest if the browser supports it.
if (typeof element.closest == 'function') { if (typeof element.closest == 'function') {
return element.closest(selector); return element.closest(selector);
@ -363,8 +363,8 @@ export class CoreDomUtilsProvider {
fixHtml(html: string): string { fixHtml(html: string): string {
this.template.innerHTML = html; 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 => { const fixElement = (element: Element): void => {
// Remove attributes with an invalid name. // Remove attributes with an invalid name.
Array.from(element.attributes).forEach((attr) => { Array.from(element.attributes).forEach((attr) => {
@ -1547,6 +1547,7 @@ export class CoreDomUtilsProvider {
* @param placeholder Placeholder of the input element if any. * @param placeholder Placeholder of the input element if any.
* @return Promise resolved when modal presented. * @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<any> { showTextareaPrompt(title: string, message: string, buttons: (string | any)[], placeholder?: string): Promise<any> {
// @todo // @todo
return Promise.resolve(); return Promise.resolve();
@ -1661,6 +1662,7 @@ export class CoreDomUtilsProvider {
* @param componentId An ID to use in conjunction with the component. * @param componentId An ID to use in conjunction with the component.
* @param fullScreen Whether the modal should be full screen. * @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 { viewImage(image: string, title?: string | null, component?: string, componentId?: string | number, fullScreen?: boolean): void {
// @todo // @todo
} }

View File

@ -1491,7 +1491,9 @@ export class CoreUtilsProvider {
* @param title Title of the modal. Defaults to "QR reader". * @param title Title of the modal. Defaults to "QR reader".
* @return Promise resolved with the captured text or undefined if cancelled or error. * @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<string> { scanQR(title?: string): Promise<string> {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
return new Promise((resolve, reject): void => { return new Promise((resolve, reject): void => {
// @todo // @todo
}); });