refactor: Fix eslint warnings (#3698)
* Update dependencies and remove typescript version pinning (fixed upstream) * Fix esling warnings (disabled any and script lang checks) Rewrote clipboard copy (Fixes #3407) Run prettier --------- Co-authored-by: Oleg Lobanov <oleg@lobanov.me>
This commit is contained in:
@@ -325,6 +325,7 @@ const token = ref<string>("");
|
||||
const audio = ref<HTMLAudioElement>();
|
||||
const tag = ref<boolean>(false);
|
||||
|
||||
const $showError = inject<IToastError>("$showError")!;
|
||||
const $showSuccess = inject<IToastSuccess>("$showSuccess")!;
|
||||
|
||||
const { t } = useI18n({});
|
||||
@@ -463,9 +464,9 @@ const download = () => {
|
||||
if (req.value === null) return false;
|
||||
layoutStore.closeHovers();
|
||||
|
||||
let files: string[] = [];
|
||||
const files: string[] = [];
|
||||
|
||||
for (let i of fileStore.selected) {
|
||||
for (const i of fileStore.selected) {
|
||||
files.push(req.value.items[i].path);
|
||||
}
|
||||
|
||||
@@ -488,13 +489,23 @@ const linkSelected = () => {
|
||||
};
|
||||
|
||||
const copyToClipboard = (text: string) => {
|
||||
copy(text).then(
|
||||
copy({ text }).then(
|
||||
() => {
|
||||
// clipboard successfully set
|
||||
$showSuccess(t("success.linkCopied"));
|
||||
},
|
||||
() => {
|
||||
// clipboard write failed
|
||||
copy({ text }, { permission: true }).then(
|
||||
() => {
|
||||
// clipboard successfully set
|
||||
$showSuccess(t("success.linkCopied"));
|
||||
},
|
||||
(e) => {
|
||||
// clipboard write failed
|
||||
$showError(e);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
@@ -108,7 +108,7 @@ onMounted(() => {
|
||||
showPrintMargin: false,
|
||||
readOnly: fileStore.req?.type === "textImmutable",
|
||||
theme: "ace/theme/chrome",
|
||||
mode: modelist.getModeForPath(fileStore.req?.name).mode,
|
||||
mode: modelist.getModeForPath(fileStore.req!.name).mode,
|
||||
wrap: true,
|
||||
enableBasicAutocompletion: true,
|
||||
enableLiveAutocompletion: true,
|
||||
@@ -173,7 +173,7 @@ const close = () => {
|
||||
|
||||
fileStore.updateRequest(null);
|
||||
|
||||
let uri = url.removeLastDir(route.path) + "/";
|
||||
const uri = url.removeLastDir(route.path) + "/";
|
||||
router.push({ path: uri });
|
||||
};
|
||||
|
||||
|
||||
@@ -523,12 +523,12 @@ const keyEvent = (event: KeyboardEvent) => {
|
||||
break;
|
||||
case "a":
|
||||
event.preventDefault();
|
||||
for (let file of items.value.files) {
|
||||
for (const file of items.value.files) {
|
||||
if (fileStore.selected.indexOf(file.index) === -1) {
|
||||
fileStore.selected.push(file.index);
|
||||
}
|
||||
}
|
||||
for (let dir of items.value.dirs) {
|
||||
for (const dir of items.value.dirs) {
|
||||
if (fileStore.selected.indexOf(dir.index) === -1) {
|
||||
fileStore.selected.push(dir.index);
|
||||
}
|
||||
@@ -551,9 +551,9 @@ const copyCut = (event: Event | KeyboardEvent): void => {
|
||||
|
||||
if (fileStore.req === null) return;
|
||||
|
||||
let items = [];
|
||||
const items = [];
|
||||
|
||||
for (let i of fileStore.selected) {
|
||||
for (const i of fileStore.selected) {
|
||||
items.push({
|
||||
from: fileStore.req.items[i].url,
|
||||
name: fileStore.req.items[i].name,
|
||||
@@ -575,9 +575,9 @@ const paste = (event: Event) => {
|
||||
if ((event.target as HTMLElement).tagName?.toLowerCase() === "input") return;
|
||||
|
||||
// TODO router location should it be
|
||||
let items: any[] = [];
|
||||
const items: any[] = [];
|
||||
|
||||
for (let item of clipboardStore.items) {
|
||||
for (const item of clipboardStore.items) {
|
||||
const from = item.from.endsWith("/") ? item.from.slice(0, -1) : item.from;
|
||||
const to = route.path + encodeURIComponent(item.name);
|
||||
items.push({ from, to, name: item.name });
|
||||
@@ -614,7 +614,7 @@ const paste = (event: Event) => {
|
||||
return;
|
||||
}
|
||||
|
||||
let conflict = upload.checkConflict(items, fileStore.req!.items);
|
||||
const conflict = upload.checkConflict(items, fileStore.req!.items);
|
||||
|
||||
let overwrite = false;
|
||||
let rename = false;
|
||||
@@ -640,14 +640,13 @@ const paste = (event: Event) => {
|
||||
|
||||
const colunmsResize = () => {
|
||||
// Update the columns size based on the window width.
|
||||
let items_ = css(["#listing.mosaic .item", ".mosaic#listing .item"]);
|
||||
const items_ = css(["#listing.mosaic .item", ".mosaic#listing .item"]);
|
||||
if (items_ === null) return;
|
||||
|
||||
let columns = Math.floor(
|
||||
(document.querySelector("main")?.offsetWidth ?? 0) / columnWidth.value
|
||||
);
|
||||
if (columns === 0) columns = 1;
|
||||
// @ts-ignore never type error
|
||||
items_.style.width = `calc(${100 / columns}% - 1em)`;
|
||||
};
|
||||
|
||||
@@ -677,11 +676,10 @@ const dragEnter = () => {
|
||||
|
||||
// When the user starts dragging an item, put every
|
||||
// file on the listing with 50% opacity.
|
||||
let items = document.getElementsByClassName("item");
|
||||
const items = document.getElementsByClassName("item");
|
||||
|
||||
// @ts-ignore
|
||||
Array.from(items).forEach((file: HTMLElement) => {
|
||||
file.style.opacity = "0.5";
|
||||
Array.from(items).forEach((file: Element) => {
|
||||
(file as HTMLElement).style.opacity = "0.5";
|
||||
});
|
||||
};
|
||||
|
||||
@@ -698,7 +696,7 @@ const drop = async (event: DragEvent) => {
|
||||
dragCounter.value = 0;
|
||||
resetOpacity();
|
||||
|
||||
let dt = event.dataTransfer;
|
||||
const dt = event.dataTransfer;
|
||||
let el: HTMLElement | null = event.target as HTMLElement;
|
||||
|
||||
if (fileStore.req === null || dt === null || dt.files.length <= 0) return;
|
||||
@@ -709,7 +707,7 @@ const drop = async (event: DragEvent) => {
|
||||
}
|
||||
}
|
||||
|
||||
let files: UploadList = (await upload.scanFiles(dt)) as UploadList;
|
||||
const files: UploadList = (await upload.scanFiles(dt)) as UploadList;
|
||||
let items = fileStore.req.items;
|
||||
let path = route.path.endsWith("/") ? route.path : route.path + "/";
|
||||
|
||||
@@ -729,7 +727,7 @@ const drop = async (event: DragEvent) => {
|
||||
}
|
||||
}
|
||||
|
||||
let conflict = upload.checkConflict(files, items);
|
||||
const conflict = upload.checkConflict(files, items);
|
||||
|
||||
if (conflict) {
|
||||
layoutStore.showHover({
|
||||
@@ -753,10 +751,10 @@ const drop = async (event: DragEvent) => {
|
||||
};
|
||||
|
||||
const uploadInput = (event: Event) => {
|
||||
let files = (event.currentTarget as HTMLInputElement)?.files;
|
||||
const files = (event.currentTarget as HTMLInputElement)?.files;
|
||||
if (files === null) return;
|
||||
|
||||
let folder_upload = !!files[0].webkitRelativePath;
|
||||
const folder_upload = !!files[0].webkitRelativePath;
|
||||
|
||||
const uploadFiles: UploadList = [];
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
@@ -771,8 +769,8 @@ const uploadInput = (event: Event) => {
|
||||
});
|
||||
}
|
||||
|
||||
let path = route.path.endsWith("/") ? route.path : route.path + "/";
|
||||
let conflict = upload.checkConflict(uploadFiles, fileStore.req!.items);
|
||||
const path = route.path.endsWith("/") ? route.path : route.path + "/";
|
||||
const conflict = upload.checkConflict(uploadFiles, fileStore.req!.items);
|
||||
|
||||
if (conflict) {
|
||||
layoutStore.showHover({
|
||||
@@ -796,7 +794,7 @@ const uploadInput = (event: Event) => {
|
||||
};
|
||||
|
||||
const resetOpacity = () => {
|
||||
let items = document.getElementsByClassName("item");
|
||||
const items = document.getElementsByClassName("item");
|
||||
|
||||
Array.from(items).forEach((file: Element) => {
|
||||
(file as HTMLElement).style.opacity = "1";
|
||||
@@ -822,7 +820,6 @@ const sort = async (by: string) => {
|
||||
|
||||
try {
|
||||
if (authStore.user?.id) {
|
||||
// @ts-ignore
|
||||
await users.update({ id: authStore.user?.id, sorting: { by, asc } }, [
|
||||
"sorting",
|
||||
]);
|
||||
@@ -873,10 +870,10 @@ const download = () => {
|
||||
confirm: (format: any) => {
|
||||
layoutStore.closeHovers();
|
||||
|
||||
let files = [];
|
||||
const files = [];
|
||||
|
||||
if (fileStore.selectedCount > 0 && fileStore.req !== null) {
|
||||
for (let i of fileStore.selected) {
|
||||
for (const i of fileStore.selected) {
|
||||
files.push(fileStore.req.items[i].url);
|
||||
}
|
||||
} else {
|
||||
@@ -899,13 +896,12 @@ const switchView = async () => {
|
||||
|
||||
const data = {
|
||||
id: authStore.user?.id,
|
||||
viewMode: modes[authStore.user?.viewMode ?? "list"] || "list",
|
||||
viewMode: (modes[authStore.user?.viewMode ?? "list"] ||
|
||||
"list") as ViewModeType,
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
users.update(data, ["viewMode"]).catch($showError);
|
||||
|
||||
// @ts-ignore
|
||||
authStore.updateUser(data);
|
||||
|
||||
setItemWeight();
|
||||
|
||||
@@ -353,7 +353,7 @@ const updatePreview = async () => {
|
||||
autoPlay.value = false;
|
||||
}
|
||||
|
||||
let dirs = route.fullPath.split("/");
|
||||
const dirs = route.fullPath.split("/");
|
||||
name.value = decodeURIComponent(dirs[dirs.length - 1]);
|
||||
|
||||
if (!listing.value) {
|
||||
@@ -422,7 +422,7 @@ const toggleNavigation = throttle(function () {
|
||||
const close = () => {
|
||||
fileStore.updateRequest(null);
|
||||
|
||||
let uri = url.removeLastDir(route.path) + "/";
|
||||
const uri = url.removeLastDir(route.path) + "/";
|
||||
router.push({ path: uri });
|
||||
};
|
||||
|
||||
|
||||
@@ -282,7 +282,7 @@ const formattedChunkSize = computed({
|
||||
// Define funcs
|
||||
const capitalize = (name: string, where: string | RegExp = "_") => {
|
||||
if (where === "caps") where = /(?=[A-Z])/;
|
||||
let split = name.split(where);
|
||||
const split = name.split(where);
|
||||
name = "";
|
||||
|
||||
for (let i = 0; i < split.length; i++) {
|
||||
@@ -294,7 +294,7 @@ const capitalize = (name: string, where: string | RegExp = "_") => {
|
||||
|
||||
const save = async () => {
|
||||
if (settings.value === null) return false;
|
||||
let newSettings: ISettings = {
|
||||
const newSettings: ISettings = {
|
||||
...settings.value,
|
||||
shell:
|
||||
settings.value?.shell
|
||||
@@ -376,7 +376,7 @@ onMounted(async () => {
|
||||
try {
|
||||
layoutStore.loading = true;
|
||||
const original: ISettings = await api.get();
|
||||
let newSettings: ISettings = { ...original, commands: {} };
|
||||
const newSettings: ISettings = { ...original, commands: {} };
|
||||
|
||||
const keys = Object.keys(original.commands) as Array<keyof SettingsCommand>;
|
||||
for (const key of keys) {
|
||||
|
||||
@@ -87,12 +87,12 @@ onMounted(async () => {
|
||||
layoutStore.loading = true;
|
||||
|
||||
try {
|
||||
let newLinks = await api.list();
|
||||
const newLinks = await api.list();
|
||||
if (authStore.user?.perm.admin) {
|
||||
let userMap = new Map<number, string>();
|
||||
for (let user of await users.getAll())
|
||||
const userMap = new Map<number, string>();
|
||||
for (const user of await users.getAll())
|
||||
userMap.set(user.id, user.username);
|
||||
for (let link of newLinks) {
|
||||
for (const link of newLinks) {
|
||||
if (link.userID && userMap.has(link.userID))
|
||||
link.username = userMap.get(link.userID);
|
||||
}
|
||||
@@ -108,13 +108,23 @@ onMounted(async () => {
|
||||
});
|
||||
|
||||
const copyToClipboard = (text: string) => {
|
||||
copy(text).then(
|
||||
copy({ text }).then(
|
||||
() => {
|
||||
// clipboard successfully set
|
||||
$showSuccess(t("success.linkCopied"));
|
||||
},
|
||||
() => {
|
||||
// clipboard write failed
|
||||
copy({ text }, { permission: true }).then(
|
||||
() => {
|
||||
// clipboard successfully set
|
||||
$showSuccess(t("success.linkCopied"));
|
||||
},
|
||||
(e) => {
|
||||
// clipboard write failed
|
||||
$showError(e);
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
@@ -90,7 +90,7 @@ const fetchData = async () => {
|
||||
|
||||
try {
|
||||
if (isNew.value) {
|
||||
let { defaults, createUserDir: _createUserDir } = await settings.get();
|
||||
const { defaults, createUserDir: _createUserDir } = await settings.get();
|
||||
createUserDir.value = _createUserDir;
|
||||
user.value = {
|
||||
...defaults,
|
||||
|
||||
Reference in New Issue
Block a user