refactor: ♻️ Fix linter errors

This commit is contained in:
Jesse Wierzbinski 2024-06-19 14:07:56 -10:00
parent 8a984abfb2
commit f9433e259b
No known key found for this signature in database
30 changed files with 235 additions and 157 deletions

View file

@ -30,8 +30,12 @@ const loaded = computed(() => note.value !== null && context.value !== null);
watch(
[() => context.value?.ancestors, loaded],
async () => {
if (context.value?.ancestors.length === 0) return;
if (!loaded.value) return;
if (context.value?.ancestors.length === 0) {
return;
}
if (!loaded.value) {
return;
}
await nextTick();
// Wait for 200ms
await new Promise((resolve) => setTimeout(resolve, 200));

View file

@ -111,14 +111,14 @@ const hostname = useRequestURL().hostname;
const query = new URLSearchParams(
window?.location.search ?? useRequestURL().search,
);
const redirect_uri = query.get("redirect_uri");
const response_type = query.get("response_type");
const client_id = query.get("client_id");
const redirectUri = query.get("redirect_uri");
const responseType = query.get("response_type");
const clientId = query.get("client_id");
const scope = query.get("scope");
const error = query.get("error");
const error_description = query.get("error_description");
const errorDescription = query.get("error_description");
const validUrlParameters = redirect_uri && response_type && client_id && scope;
const validUrlParameters = redirectUri && responseType && clientId && scope;
const ssoConfig = useSSOConfig();
</script>

View file

@ -92,11 +92,11 @@ const application = query.application;
const website = query.website
? decodeURIComponent(query.website as string)
: null;
const redirect_uri = query.redirect_uri as string;
const client_id = query.client_id;
const redirectUri = query.redirect_uri as string;
const clientId = query.client_id;
const scope = query.scope ? decodeURIComponent(query.scope as string) : "";
const validUrlParameters = application && redirect_uri && client_id && scope;
const validUrlParameters = application && redirectUri && clientId && scope;
const oauthScopeText: Record<string, string> = {
"rw:accounts": "$VERB your account information",
@ -123,7 +123,7 @@ const scopes = scope.split(" ");
// Return an array of strings to display
// "read write:accounts" returns all the fields with $VERB as read, plus the accounts field with $VERB as write
const getScopeText = (fullScopes: string[]) => {
const scopeTexts = [];
const scopeTexts: string[][] = [];
const readScopes = fullScopes.filter((scope) => scope.includes("read"));
const writeScopes = fullScopes.filter((scope) => scope.includes("write"));
@ -138,12 +138,14 @@ const getScopeText = (fullScopes: string[]) => {
(writeScopes.includes(`write:${scopeName}`) ||
writeScopes.find((scope) => scope === "write"))
) {
if (oauthScopeText[possibleScope]?.includes("$VERB"))
if (oauthScopeText[possibleScope]?.includes("$VERB")) {
scopeTexts.push([
"Read and write",
oauthScopeText[possibleScope]?.replace("$VERB", ""),
oauthScopeText[possibleScope]?.replace("$VERB", "") ?? "",
]);
else scopeTexts.push(["", oauthScopeText[possibleScope]]);
} else {
scopeTexts.push(["", oauthScopeText[possibleScope] ?? ""]);
}
continue;
}
@ -152,12 +154,14 @@ const getScopeText = (fullScopes: string[]) => {
(readScopes.includes(`read:${scopeName}`) ||
readScopes.find((scope) => scope === "read"))
) {
if (oauthScopeText[possibleScope]?.includes("$VERB"))
if (oauthScopeText[possibleScope]?.includes("$VERB")) {
scopeTexts.push([
"Read",
oauthScopeText[possibleScope]?.replace("$VERB", ""),
oauthScopeText[possibleScope]?.replace("$VERB", "") ?? "",
]);
else scopeTexts.push(["", oauthScopeText[possibleScope]]);
} else {
scopeTexts.push(["", oauthScopeText[possibleScope] ?? ""]);
}
}
if (
@ -165,12 +169,14 @@ const getScopeText = (fullScopes: string[]) => {
(writeScopes.includes(`write:${scopeName}`) ||
writeScopes.find((scope) => scope === "write"))
) {
if (oauthScopeText[possibleScope]?.includes("$VERB"))
if (oauthScopeText[possibleScope]?.includes("$VERB")) {
scopeTexts.push([
"Write",
oauthScopeText[possibleScope]?.replace("$VERB", ""),
oauthScopeText[possibleScope]?.replace("$VERB", "") ?? "",
]);
else scopeTexts.push(["", oauthScopeText[possibleScope]]);
} else {
scopeTexts.push(["", oauthScopeText[possibleScope] ?? ""]);
}
}
}
return scopeTexts;

View file

@ -99,14 +99,14 @@ const query = new URLSearchParams(
window?.location.search ?? useRequestURL().search,
);
const token = query.get("token");
const login_reset = query.get("login_reset") === "true";
const loginReset = query.get("login_reset") === "true";
const success = query.get("success") === "true";
let error = query.get("error");
let error_description = query.get("error_description");
let errorDescription = query.get("error_description");
if (login_reset) {
if (loginReset) {
error = "Login reset";
error_description =
errorDescription =
"Your password has been reset by an administrator. Please change it here.";
}

View file

@ -86,7 +86,7 @@
</p>
<ButtonsPrimary type="submit" class="w-full" :disabled="isLoading">{{ isLoading ? "Registering..." :
"Register" }}</ButtonsPrimary>
"Register" }}</ButtonsPrimary>
</VeeForm>
</div>
<div v-else>
@ -158,10 +158,10 @@ const register = (result: {
"en",
result.reason || "Empty reason",
)
.then(async () => {
.then(() => {
navigateTo("/register/success");
})
.catch(async (e) => {
.catch((e) => {
const error = e as ResponseError<{
error: string;
}>;