Fix ESLint issues

This commit is contained in:
Pierre HUBERT 2025-04-03 22:37:22 +02:00
parent 92ce2e68ad
commit 03f57a0ad7
5 changed files with 20 additions and 17 deletions

View File

@ -66,23 +66,25 @@ export class APIClient {
if (args.upProgress) {
const res: XMLHttpRequest = await new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest();
xhr.upload.addEventListener("progress", (e) =>
{ args.upProgress!(e.loaded / e.total); }
);
xhr.addEventListener("load", () => { resolve(xhr); });
xhr.addEventListener("error", () =>
{ reject(new Error("File upload failed")); }
);
xhr.addEventListener("abort", () =>
{ reject(new Error("File upload aborted")); }
);
xhr.addEventListener("timeout", () =>
{ reject(new Error("File upload timeout")); }
);
xhr.upload.addEventListener("progress", (e) => {
args.upProgress!(e.loaded / e.total);
});
xhr.addEventListener("load", () => {
resolve(xhr);
});
xhr.addEventListener("error", () => {
reject(new Error("File upload failed"));
});
xhr.addEventListener("abort", () => {
reject(new Error("File upload aborted"));
});
xhr.addEventListener("timeout", () => {
reject(new Error("File upload timeout"));
});
xhr.open(args.method, url, true);
xhr.withCredentials = true;
for (const key in headers) {
if (headers.hasOwnProperty(key))
if (Object.prototype.hasOwnProperty.call(headers, key))
xhr.setRequestHeader(key, headers[key]);
}
xhr.send(body);

View File

@ -26,7 +26,7 @@ export function CreateTokenDialog(p: {
const loadingMessage = useLoadingMessage();
const [newTokenUndef, setNewToken] = React.useState<NewToken | undefined>();
const newToken = newTokenUndef || {
const newToken = newTokenUndef ?? {
name: "",
ip_net: undefined,
max_inactivity: 3600 * 24 * 90,

View File

@ -200,6 +200,7 @@ function TokensRouteInner(p: {
getActions: ({ id }) => {
return [
<GridActionsCellItem
key={id}
icon={<DeleteIcon />}
label="Delete"
onClick={handleDeleteClick(id)}

View File

@ -26,7 +26,7 @@ export function checkConstraint(
export function checkURL(s: string): boolean {
try {
return Boolean(new URL(s));
} catch (e) {
} catch {
return false;
}
}

View File

@ -17,7 +17,7 @@ export function AsyncWidget(p: {
}): React.ReactElement {
const [state, setState] = useState(State.Loading);
const counter = useRef<any | null>(null);
const counter = useRef<any>(null);
const load = async () => {
try {