MOBILE-3565 classes: Fix linting on some classes

main
Pau Ferrer Ocaña 2020-10-09 12:41:41 +02:00
parent c8fda5d3ca
commit 5acc551488
7 changed files with 34 additions and 13 deletions

View File

@ -32,7 +32,7 @@ export class CoreInterceptor implements HttpInterceptor {
*/
static serialize(obj: any, addNull?: boolean): string {
let query = '';
let fullSubName;
let fullSubName: string;
let subValue;
let innerObj;
@ -68,10 +68,11 @@ export class CoreInterceptor implements HttpInterceptor {
const newReq = req.clone({
headers: req.headers.set('Content-Type', 'application/x-www-form-urlencoded'),
body: typeof req.body == 'object' && String(req.body) != '[object File]' ?
CoreInterceptor.serialize(req.body) : req.body
CoreInterceptor.serialize(req.body) : req.body,
});
// Pass on the cloned request instead of the original request.
return next.handle(newReq);
}
}

View File

@ -92,7 +92,8 @@ export class CoreNativeToAngularHttpResponse<T> extends AngularHttpResponse<T> {
headers: new HttpHeaders(nativeResponse.headers),
status: nativeResponse.status,
statusText: HTTP_STATUS_MESSAGES[nativeResponse.status] || '',
url: nativeResponse.url || ''
url: nativeResponse.url || '',
});
}
}

View File

@ -53,6 +53,7 @@ export type CoreQueueRunnerAddOptions = {
* A queue to prevent having too many concurrent executions.
*/
export class CoreQueueRunner {
protected queue: {[id: string]: CoreQueueRunnerItem} = {};
protected orderedQueue: CoreQueueRunnerItem[] = [];
protected numberRunning = 0;
@ -140,4 +141,5 @@ export class CoreQueueRunner {
return item.deferred.promise;
}
}

View File

@ -80,4 +80,5 @@ export class CoreSingletonsFactory {
};
}
}

View File

@ -27,12 +27,18 @@ import { environment } from '@/environments/environment';
* Then you can call the log function you want to use in this logger instance.
*/
export class CoreLogger {
log: LogFunction;
info: LogFunction;
warn: LogFunction;
debug: LogFunction;
error: LogFunction;
// Avoid creating singleton instances.
private constructor() {
// Nothing to do.
}
/**
* Get a logger instance for a certain class, service or component.
*
@ -88,6 +94,7 @@ export class CoreLogger {
logFn.apply(null, args);
};
}
}
/**

View File

@ -72,7 +72,9 @@ interface UrlParts {
export class CoreUrl {
// Avoid creating singleton instances.
private constructor() {}
private constructor() {
// Nothing to do.
}
/**
* Parse parts of a url, using an implicit protocol if it is missing from the url.
@ -123,14 +125,14 @@ export class CoreUrl {
// Match using common suffixes.
const knownSuffixes = [
'\/my\/?',
'\/\\\?redirect=0',
'\/index\\\.php',
'\/course\/view\\\.php',
'\/login\/index\\\.php',
'\/mod\/page\/view\\\.php',
'/my/?',
'/\\?redirect=0',
'/index\\.php',
'/course/view\\.php',
'\\/login/index\\.php',
'/mod/page/view\\.php',
];
const match = url.match(new RegExp(`^https?:\/\/(.*?)(${knownSuffixes.join('|')})`));
const match = url.match(new RegExp(`^https?://(.*?)(${knownSuffixes.join('|')})`));
if (match) {
return match[1];
@ -184,10 +186,10 @@ export class CoreUrl {
*/
static sameDomainAndPath(urlA: string, urlB: string): boolean {
// Add protocol if missing, the parse function requires it.
if (!urlA.match(/^[^\/:\.\?]*:\/\//)) {
if (!urlA.match(/^[^/:.?]*:\/\//)) {
urlA = `https://${urlA}`;
}
if (!urlB.match(/^[^\/:\.\?]*:\/\//)) {
if (!urlB.match(/^[^/:.?]*:\/\//)) {
urlB = `https://${urlB}`;
}
@ -197,4 +199,5 @@ export class CoreUrl {
return partsA.domain == partsB.domain &&
CoreTextUtils.instance.removeEndingSlash(partsA.path) == CoreTextUtils.instance.removeEndingSlash(partsB.path);
}
}

View File

@ -32,6 +32,11 @@ export type CoreWindowOpenOptions = {
*/
export class CoreWindow {
// Avoid creating singleton instances.
private constructor() {
// Nothing to do.
}
/**
* "Safe" implementation of window.open. It will open the URL without overriding the app.
*
@ -73,4 +78,5 @@ export class CoreWindow {
}
}
}
}