Update linting
This commit is contained in:
1 parent
4f2dfb4f48
commit
0c9c027a77
112 files changed
+3781
-4125
No files matched your search
+32
-28
@@ -76,7 +76,7 @@ for (const r of [
|
||||
};
|
||||
}
|
||||
|
||||
class QueryResponse {
|
||||
export class QueryResponse {
|
||||
public get fulfilled(): number {
|
||||
queries.accessed.set(this, Date.now());
|
||||
return queries.fulfilled.get(this) || 0;
|
||||
@@ -106,7 +106,7 @@ function checkConnection(): void {
|
||||
connectionNotification = notifications.push(
|
||||
"warning",
|
||||
"Server is unreachable",
|
||||
{}
|
||||
{},
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -121,7 +121,7 @@ function checkConnection(): void {
|
||||
if (Math.abs(skew - clockSkew) > 5000 && now2 - now1 < 1000) {
|
||||
clockSkew = skew;
|
||||
console.warn(
|
||||
`System and server clocks are out of sync. Adding ${clockSkew}ms offset to any client-side time relative calculations.`
|
||||
`System and server clocks are out of sync. Adding ${clockSkew}ms offset to any client-side time relative calculations.`,
|
||||
);
|
||||
setTimestamp(now2);
|
||||
m.redraw();
|
||||
@@ -147,7 +147,7 @@ function checkConnection(): void {
|
||||
Reload: () => {
|
||||
window.location.reload();
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -164,7 +164,7 @@ function checkConnection(): void {
|
||||
Reload: () => {
|
||||
window.location.reload();
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -178,14 +178,14 @@ function checkConnection(): void {
|
||||
setInterval(checkConnection, 3000);
|
||||
|
||||
export async function xhrRequest(
|
||||
options: { url: string } & m.RequestOptions<unknown>
|
||||
options: { url: string } & m.RequestOptions<unknown>,
|
||||
): Promise<any> {
|
||||
const extract = options.extract;
|
||||
const deserialize = options.deserialize;
|
||||
|
||||
options.extract = (
|
||||
xhr: XMLHttpRequest,
|
||||
_options?: { url: string } & m.RequestOptions<unknown>
|
||||
_options?: { url: string } & m.RequestOptions<unknown>,
|
||||
): any => {
|
||||
if (typeof extract === "function") return extract(xhr, _options);
|
||||
|
||||
@@ -207,7 +207,7 @@ export async function xhrRequest(
|
||||
response = deserialize(xhr.responseText);
|
||||
} else if (
|
||||
(xhr.getResponseHeader("content-type") || "").startsWith(
|
||||
"application/json"
|
||||
"application/json",
|
||||
)
|
||||
) {
|
||||
try {
|
||||
@@ -243,7 +243,11 @@ export function count(resourceType: string, filter: Expression): QueryResponse {
|
||||
return queryResponse;
|
||||
}
|
||||
|
||||
function limitFilter(filter, sort, bookmark): Expression {
|
||||
function limitFilter(
|
||||
filter: Expression,
|
||||
sort: Record<string, number>,
|
||||
bookmark,
|
||||
): Expression {
|
||||
const sortSort = (a, b): number => Math.abs(b[1]) - Math.abs(a[1]);
|
||||
const arr = Object.entries(sort).sort(sortSort).reverse();
|
||||
return and(
|
||||
@@ -254,7 +258,7 @@ function limitFilter(filter, sort, bookmark): Expression {
|
||||
if (bookmark[param] == null) {
|
||||
return or(
|
||||
["IS NOT NULL", ["PARAM", param]],
|
||||
and(["IS NULL", ["PARAM", param]], cur)
|
||||
and(["IS NULL", ["PARAM", param]], cur),
|
||||
);
|
||||
}
|
||||
let f = null;
|
||||
@@ -266,7 +270,7 @@ function limitFilter(filter, sort, bookmark): Expression {
|
||||
f = or(f, ["<", ["PARAM", param], bookmark[param]]);
|
||||
return or(f, and(["=", ["PARAM", param], bookmark[param]], cur));
|
||||
}
|
||||
}, true as Expression)
|
||||
}, true as Expression),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -274,7 +278,7 @@ function compareFunction(sort: {
|
||||
[param: string]: number;
|
||||
}): (a: any, b: any) => number {
|
||||
const sortEntries = Object.entries(sort).sort(
|
||||
(a, b) => Math.abs(b[1]) - Math.abs(a[1])
|
||||
(a, b) => Math.abs(b[1]) - Math.abs(a[1]),
|
||||
);
|
||||
|
||||
return (a, b) => {
|
||||
@@ -335,14 +339,14 @@ function inferQuery(resourceType, queryResponse): void {
|
||||
|
||||
queries.value.set(
|
||||
queryResponse,
|
||||
findMatches(resourceType, filter, sort, limit)
|
||||
findMatches(resourceType, filter, sort, limit),
|
||||
);
|
||||
}
|
||||
|
||||
export function fetch(
|
||||
resourceType: string,
|
||||
filter: Expression,
|
||||
options: { limit?: number; sort?: { [param: string]: number } } = {}
|
||||
options: { limit?: number; sort?: { [param: string]: number } } = {},
|
||||
): QueryResponse {
|
||||
const filterStr = memoizedStringify(filter);
|
||||
const sort = Object.assign({}, options.sort);
|
||||
@@ -396,7 +400,7 @@ export function fulfill(accessTimestamp: number): void {
|
||||
throw new Error("Server is unreachable");
|
||||
} else if (xhr.status !== 200) {
|
||||
throw new Error(
|
||||
`Unexpected response status code ${xhr.status}`
|
||||
`Unexpected response status code ${xhr.status}`,
|
||||
);
|
||||
}
|
||||
return +xhr.getResponseHeader("x-total-count");
|
||||
@@ -406,7 +410,7 @@ export function fulfill(accessTimestamp: number): void {
|
||||
queries.value.set(queryResponse, c);
|
||||
queries.fulfilled.set(queryResponse, fulfillTimestamp);
|
||||
queries.fulfilling.delete(queryResponse);
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -463,7 +467,7 @@ export function fulfill(accessTimestamp: number): void {
|
||||
} else {
|
||||
queries.bookmark.delete(queryResponse);
|
||||
}
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -488,7 +492,7 @@ export function fulfill(accessTimestamp: number): void {
|
||||
|
||||
const [union, diff] = unionDiff(
|
||||
resources[resourceType].combinedFilter,
|
||||
combinedFilter
|
||||
combinedFilter,
|
||||
);
|
||||
|
||||
if (!diff) {
|
||||
@@ -497,7 +501,7 @@ export function fulfill(accessTimestamp: number): void {
|
||||
filter = memoizedEvaluate(
|
||||
filter,
|
||||
null,
|
||||
fulfillTimestamp + clockSkew
|
||||
fulfillTimestamp + clockSkew,
|
||||
);
|
||||
const limit = queries.limit.get(queryResponse);
|
||||
const bookmark = queries.bookmark.get(queryResponse);
|
||||
@@ -506,7 +510,7 @@ export function fulfill(accessTimestamp: number): void {
|
||||
|
||||
queries.value.set(
|
||||
queryResponse,
|
||||
findMatches(resourceType, filter, sort, limit)
|
||||
findMatches(resourceType, filter, sort, limit),
|
||||
);
|
||||
queries.fulfilled.set(queryResponse, fulfillTimestamp);
|
||||
queries.fulfilling.delete(queryResponse);
|
||||
@@ -559,12 +563,12 @@ export function fulfill(accessTimestamp: number): void {
|
||||
|
||||
queries.value.set(
|
||||
queryResponse,
|
||||
findMatches(resourceType, filter, sort, limit)
|
||||
findMatches(resourceType, filter, sort, limit),
|
||||
);
|
||||
queries.fulfilled.set(queryResponse, fulfillTimestamp);
|
||||
queries.fulfilling.delete(queryResponse);
|
||||
}
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (updated) m.redraw();
|
||||
@@ -593,7 +597,7 @@ export function getClockSkew(): number {
|
||||
|
||||
export function postTasks(
|
||||
deviceId: string,
|
||||
tasks: QueueTask[]
|
||||
tasks: QueueTask[],
|
||||
): Promise<string> {
|
||||
const tasks2: Task[] = [];
|
||||
for (const t of tasks) {
|
||||
@@ -626,7 +630,7 @@ export function postTasks(
|
||||
|
||||
export function updateTags(
|
||||
deviceId: string,
|
||||
tags: Record<string, boolean>
|
||||
tags: Record<string, boolean>,
|
||||
): Promise<void> {
|
||||
return xhrRequest({
|
||||
method: "POST",
|
||||
@@ -637,7 +641,7 @@ export function updateTags(
|
||||
|
||||
export function deleteResource(
|
||||
resourceType: string,
|
||||
id: string
|
||||
id: string,
|
||||
): Promise<void> {
|
||||
return xhrRequest({
|
||||
method: "DELETE",
|
||||
@@ -648,7 +652,7 @@ export function deleteResource(
|
||||
export function putResource(
|
||||
resourceType: string,
|
||||
id: string,
|
||||
object: Record<string, unknown>
|
||||
object: Record<string, unknown>,
|
||||
): Promise<void> {
|
||||
for (const k in object) if (object[k] === undefined) object[k] = null;
|
||||
|
||||
@@ -691,7 +695,7 @@ export function resourceExists(resource: string, id: string): Promise<number> {
|
||||
|
||||
export function evaluateExpression(
|
||||
exp: Expression,
|
||||
obj: Record<string, unknown>
|
||||
obj: Record<string, unknown>,
|
||||
): Expression {
|
||||
if (!Array.isArray(exp)) return exp;
|
||||
return memoizedEvaluate(exp, obj, fulfillTimestamp + clockSkew);
|
||||
@@ -700,7 +704,7 @@ export function evaluateExpression(
|
||||
export function changePassword(
|
||||
username: string,
|
||||
newPassword: string,
|
||||
authPassword?: string
|
||||
authPassword?: string,
|
||||
): Promise<void> {
|
||||
const body = { newPassword };
|
||||
if (authPassword) body["authPassword"] = authPassword;
|
||||
|
||||
Reference in new issue
Block a user