Fix eslint warnings

This commit is contained in:
Kloon ImKloon 2023-10-01 15:10:36 +02:00
parent 38db04f8ae
commit 6a7a1eef0c
No known key found for this signature in database
GPG Key ID: CCF1C86A995C5B6A
6 changed files with 21 additions and 23 deletions

View File

@ -11,8 +11,12 @@
],
"rules": {
"vue/multi-word-component-names": "off",
"vue/no-reserved-component-names": "warn",
"vue/no-mutating-props": "warn"
"vue/no-mutating-props": [
"error",
{
"shallowOnly": true
}
]
// no-undef is already included in
// @vue/eslint-config-typescript
},

View File

@ -16,6 +16,7 @@ defineProps<{
}>();
const emit = defineEmits<{
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(e: "update:theme", val: string | null): void;
}>();

View File

@ -114,17 +114,17 @@ export function detectLocale() {
}
// TODO: was this really necessary?
function removeEmpty(obj: Record<string, any>): void {
Object.keys(obj)
.filter((k) => obj[k] !== null && obj[k] !== undefined && obj[k] !== "") // Remove undef. and null and empty.string.
.reduce(
(newObj, k) =>
typeof obj[k] === "object"
? Object.assign(newObj, { [k]: removeEmpty(obj[k]) }) // Recurse.
: Object.assign(newObj, { [k]: obj[k] }), // Copy value.
{}
);
}
// function removeEmpty(obj: Record<string, any>): void {
// Object.keys(obj)
// .filter((k) => obj[k] !== null && obj[k] !== undefined && obj[k] !== "") // Remove undef. and null and empty.string.
// .reduce(
// (newObj, k) =>
// typeof obj[k] === "object"
// ? Object.assign(newObj, { [k]: removeEmpty(obj[k]) }) // Recurse.
// : Object.assign(newObj, { [k]: obj[k] }), // Copy value.
// {}
// );
// }
export const rtlLanguages = ["he", "ar"];

View File

@ -12,7 +12,7 @@ import Shares from "@/views/settings/Shares.vue";
import Errors from "@/views/Errors.vue";
import { useAuthStore } from "@/stores/auth";
import { baseURL, name } from "@/utils/constants";
import { i18n, isRtl, rtlLanguages } from "@/i18n";
import i18n from "@/i18n";
import { recaptcha, loginPage } from "@/utils/constants";
import { login, validateLogin } from "@/utils/auth";
@ -177,13 +177,7 @@ const router = createRouter({
});
router.beforeResolve(async (to, from, next) => {
let title;
try {
title = i18n.global.t(titles[to.name as keyof typeof titles]);
} catch (error) {
console.error(error);
}
// const title = titles[to.name];
const title = i18n.global.t(titles[to.name as keyof typeof titles]);
document.title = title + " - " + name;
const authStore = useAuthStore();

View File

@ -1,5 +1,5 @@
import { defineStore } from "pinia";
import i18n, { detectLocale, setLocale } from "@/i18n";
import { detectLocale, setLocale } from "@/i18n";
import { cloneDeep } from "lodash-es";
export const useAuthStore = defineStore("auth", {

View File

@ -82,7 +82,6 @@ import { users as api } from "@/api";
import Languages from "@/components/settings/Languages.vue";
import { computed, inject, onMounted, ref } from "vue";
import { useI18n } from "vue-i18n";
import i18n, { rtlLanguages } from "@/i18n";
const layoutStore = useLayoutStore();
const authStore = useAuthStore();