mirror of
https://github.com/thiloho/archtika.git
synced 2025-11-22 02:41:35 +01:00
Add ESLint
This commit is contained in:
36
web-app/eslint.config.js
Normal file
36
web-app/eslint.config.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import js from "@eslint/js";
|
||||||
|
import ts from "typescript-eslint";
|
||||||
|
import svelte from "eslint-plugin-svelte";
|
||||||
|
import prettier from "eslint-config-prettier";
|
||||||
|
import globals from "globals";
|
||||||
|
|
||||||
|
/** @type {import('eslint').Linter.Config[]} */
|
||||||
|
export default [
|
||||||
|
js.configs.recommended,
|
||||||
|
...ts.configs.recommended,
|
||||||
|
...svelte.configs["flat/recommended"],
|
||||||
|
prettier,
|
||||||
|
...svelte.configs["flat/prettier"],
|
||||||
|
{
|
||||||
|
languageOptions: {
|
||||||
|
globals: {
|
||||||
|
...globals.browser,
|
||||||
|
...globals.node
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
files: ["**/*.svelte"],
|
||||||
|
languageOptions: {
|
||||||
|
parserOptions: {
|
||||||
|
parser: ts.parser
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
"svelte/no-at-html-tags": "off"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ignores: ["build/", ".svelte-kit/", "dist/"]
|
||||||
|
}
|
||||||
|
];
|
||||||
1636
web-app/package-lock.json
generated
1636
web-app/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -9,7 +9,7 @@
|
|||||||
"test": "playwright test",
|
"test": "playwright test",
|
||||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||||
"lint": "prettier --check .",
|
"lint": "prettier --check . && eslint .",
|
||||||
"format": "prettier --write ."
|
"format": "prettier --write ."
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -18,12 +18,20 @@
|
|||||||
"@sveltejs/adapter-node": "5.2.2",
|
"@sveltejs/adapter-node": "5.2.2",
|
||||||
"@sveltejs/kit": "2.5.22",
|
"@sveltejs/kit": "2.5.22",
|
||||||
"@sveltejs/vite-plugin-svelte": "3.1.1",
|
"@sveltejs/vite-plugin-svelte": "3.1.1",
|
||||||
|
"@types/eslint": "9.6.1",
|
||||||
|
"@types/eslint__js": "8.42.3",
|
||||||
|
"@types/eslint-config-prettier": "6.11.3",
|
||||||
"@types/node": "22.2.0",
|
"@types/node": "22.2.0",
|
||||||
|
"eslint": "9.10.0",
|
||||||
|
"eslint-config-prettier": "9.1.0",
|
||||||
|
"eslint-plugin-svelte": "2.43.0",
|
||||||
|
"globals": "15.9.0",
|
||||||
"prettier": "3.3.3",
|
"prettier": "3.3.3",
|
||||||
"prettier-plugin-svelte": "3.2.6",
|
"prettier-plugin-svelte": "3.2.6",
|
||||||
"svelte": "5.0.0-next.220",
|
"svelte": "5.0.0-next.220",
|
||||||
"svelte-check": "3.8.5",
|
"svelte-check": "3.8.5",
|
||||||
"typescript": "5.5.4",
|
"typescript": "5.5.4",
|
||||||
|
"typescript-eslint": "8.4.0",
|
||||||
"vite": "5.4.0"
|
"vite": "5.4.0"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -6,13 +6,6 @@ import GithubSlugger from "github-slugger";
|
|||||||
import DOMPurify from "isomorphic-dompurify";
|
import DOMPurify from "isomorphic-dompurify";
|
||||||
import { applyAction, deserialize } from "$app/forms";
|
import { applyAction, deserialize } from "$app/forms";
|
||||||
|
|
||||||
export const sortOptions = [
|
|
||||||
{ value: "creation-time", text: "Creation time" },
|
|
||||||
{ value: "last-modified", text: "Last modified" },
|
|
||||||
{ value: "title-a-to-z", text: "Title - A to Z" },
|
|
||||||
{ value: "title-z-to-a", text: "Title - Z to A" }
|
|
||||||
];
|
|
||||||
|
|
||||||
export const ALLOWED_MIME_TYPES = ["image/jpeg", "image/png", "image/svg+xml", "image/webp"];
|
export const ALLOWED_MIME_TYPES = ["image/jpeg", "image/png", "image/svg+xml", "image/webp"];
|
||||||
|
|
||||||
const createMarkdownParser = (showToc = true) => {
|
const createMarkdownParser = (showToc = true) => {
|
||||||
@@ -61,7 +54,7 @@ const createMarkdownParser = (showToc = true) => {
|
|||||||
const text = this.parser.parseInline(tokens);
|
const text = this.parser.parseInline(tokens);
|
||||||
const raw = unescape(this.parser.parseInline(tokens, this.parser.textRenderer))
|
const raw = unescape(this.parser.parseInline(tokens, this.parser.textRenderer))
|
||||||
.trim()
|
.trim()
|
||||||
.replace(/<[!\/a-z].*?>/gi, "");
|
.replace(/<[!a-z].*?>/gi, "");
|
||||||
const level = depth;
|
const level = depth;
|
||||||
const id = `${prefix}${slugger.slug(raw.toLowerCase())}`;
|
const id = `${prefix}${slugger.slug(raw.toLowerCase())}`;
|
||||||
const heading = { level, text, id, raw };
|
const heading = { level, text, id, raw };
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { enhance } from "$app/forms";
|
import { enhance } from "$app/forms";
|
||||||
import DateTime from "$lib/components/DateTime.svelte";
|
import DateTime from "$lib/components/DateTime.svelte";
|
||||||
import { sortOptions } from "$lib/utils.js";
|
|
||||||
import { page } from "$app/stores";
|
import { page } from "$app/stores";
|
||||||
import Modal from "$lib/components/Modal.svelte";
|
import Modal from "$lib/components/Modal.svelte";
|
||||||
import SuccessOrError from "$lib/components/SuccessOrError.svelte";
|
import SuccessOrError from "$lib/components/SuccessOrError.svelte";
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { Actions, PageServerLoad } from "./$types";
|
import type { Actions, PageServerLoad } from "./$types";
|
||||||
import { API_BASE_PREFIX } from "$lib/server/utils";
|
import { API_BASE_PREFIX } from "$lib/server/utils";
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ params, fetch, cookies, url }) => {
|
export const load: PageServerLoad = async ({ params, fetch, cookies }) => {
|
||||||
const globalSettingsData = await fetch(
|
const globalSettingsData = await fetch(
|
||||||
`${API_BASE_PREFIX}/settings?website_id=eq.${params.websiteId}`,
|
`${API_BASE_PREFIX}/settings?website_id=eq.${params.websiteId}`,
|
||||||
{
|
{
|
||||||
@@ -45,7 +45,7 @@ export const load: PageServerLoad = async ({ params, fetch, cookies, url }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const actions: Actions = {
|
export const actions: Actions = {
|
||||||
updateGlobal: async ({ request, fetch, cookies, params, locals }) => {
|
updateGlobal: async ({ request, fetch, cookies, params }) => {
|
||||||
const data = await request.formData();
|
const data = await request.formData();
|
||||||
const faviconFile = data.get("favicon") as File;
|
const faviconFile = data.get("favicon") as File;
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ export const load: PageServerLoad = async ({ params, fetch, cookies, url, parent
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const actions: Actions = {
|
export const actions: Actions = {
|
||||||
createArticle: async ({ request, fetch, cookies, params, locals }) => {
|
createArticle: async ({ request, fetch, cookies, params }) => {
|
||||||
const data = await request.formData();
|
const data = await request.formData();
|
||||||
|
|
||||||
const res = await fetch(`${API_BASE_PREFIX}/article`, {
|
const res = await fetch(`${API_BASE_PREFIX}/article`, {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import WebsiteEditor from "$lib/components/WebsiteEditor.svelte";
|
import WebsiteEditor from "$lib/components/WebsiteEditor.svelte";
|
||||||
import { sortOptions } from "$lib/utils.js";
|
|
||||||
import { page } from "$app/stores";
|
import { page } from "$app/stores";
|
||||||
import { enhance } from "$app/forms";
|
import { enhance } from "$app/forms";
|
||||||
import Modal from "$lib/components/Modal.svelte";
|
import Modal from "$lib/components/Modal.svelte";
|
||||||
|
|||||||
@@ -10,6 +10,30 @@ import DocsIndex from "$lib/templates/docs/DocsIndex.svelte";
|
|||||||
import DocsArticle from "$lib/templates/docs/DocsArticle.svelte";
|
import DocsArticle from "$lib/templates/docs/DocsArticle.svelte";
|
||||||
import { dev } from "$app/environment";
|
import { dev } from "$app/environment";
|
||||||
|
|
||||||
|
interface WebsiteData {
|
||||||
|
id: string;
|
||||||
|
content_type: "Blog" | "Docs";
|
||||||
|
favicon_image: string | null;
|
||||||
|
title: string;
|
||||||
|
logo_type: "text" | "image";
|
||||||
|
logo_text: string | null;
|
||||||
|
logo_image: string | null;
|
||||||
|
main_content: string;
|
||||||
|
additional_text: string;
|
||||||
|
accent_color_light_theme: string;
|
||||||
|
accent_color_dark_theme: string;
|
||||||
|
articles: {
|
||||||
|
cover_image: string | null;
|
||||||
|
title: string;
|
||||||
|
publication_date: string;
|
||||||
|
meta_description: string;
|
||||||
|
main_content: string;
|
||||||
|
}[];
|
||||||
|
categorized_articles: {
|
||||||
|
[key: string]: { title: string; publication_date: string; meta_description: string }[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ params, fetch, cookies, parent }) => {
|
export const load: PageServerLoad = async ({ params, fetch, cookies, parent }) => {
|
||||||
const websiteOverviewData = await fetch(
|
const websiteOverviewData = await fetch(
|
||||||
`${API_BASE_PREFIX}/website_overview?id=eq.${params.websiteId}`,
|
`${API_BASE_PREFIX}/website_overview?id=eq.${params.websiteId}`,
|
||||||
@@ -80,7 +104,7 @@ export const actions: Actions = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const generateStaticFiles = async (websiteData: any, isPreview: boolean = true) => {
|
const generateStaticFiles = async (websiteData: WebsiteData, isPreview: boolean = true) => {
|
||||||
let head = "";
|
let head = "";
|
||||||
let body = "";
|
let body = "";
|
||||||
|
|
||||||
@@ -96,7 +120,7 @@ const generateStaticFiles = async (websiteData: any, isPreview: boolean = true)
|
|||||||
logoType: websiteData.logo_type,
|
logoType: websiteData.logo_type,
|
||||||
logo:
|
logo:
|
||||||
websiteData.logo_type === "text"
|
websiteData.logo_type === "text"
|
||||||
? websiteData.logo_text
|
? (websiteData.logo_text ?? "")
|
||||||
: `${API_BASE_PREFIX}/rpc/retrieve_file?id=${websiteData.logo_image}`,
|
: `${API_BASE_PREFIX}/rpc/retrieve_file?id=${websiteData.logo_image}`,
|
||||||
mainContent: md(websiteData.main_content ?? "", false),
|
mainContent: md(websiteData.main_content ?? "", false),
|
||||||
articles: websiteData.articles ?? [],
|
articles: websiteData.articles ?? [],
|
||||||
@@ -116,7 +140,7 @@ const generateStaticFiles = async (websiteData: any, isPreview: boolean = true)
|
|||||||
logoType: websiteData.logo_type,
|
logoType: websiteData.logo_type,
|
||||||
logo:
|
logo:
|
||||||
websiteData.logo_type === "text"
|
websiteData.logo_type === "text"
|
||||||
? websiteData.logo_text
|
? (websiteData.logo_text ?? "")
|
||||||
: `${API_BASE_PREFIX}/rpc/retrieve_file?id=${websiteData.logo_image}`,
|
: `${API_BASE_PREFIX}/rpc/retrieve_file?id=${websiteData.logo_image}`,
|
||||||
mainContent: md(websiteData.main_content ?? "", false),
|
mainContent: md(websiteData.main_content ?? "", false),
|
||||||
categorizedArticles: websiteData.categorized_articles ?? [],
|
categorizedArticles: websiteData.categorized_articles ?? [],
|
||||||
@@ -161,7 +185,7 @@ const generateStaticFiles = async (websiteData: any, isPreview: boolean = true)
|
|||||||
logoType: websiteData.logo_type,
|
logoType: websiteData.logo_type,
|
||||||
logo:
|
logo:
|
||||||
websiteData.logo_type === "text"
|
websiteData.logo_type === "text"
|
||||||
? websiteData.logo_text
|
? (websiteData.logo_text ?? "")
|
||||||
: `${API_BASE_PREFIX}/rpc/retrieve_file?id=${websiteData.logo_image}`,
|
: `${API_BASE_PREFIX}/rpc/retrieve_file?id=${websiteData.logo_image}`,
|
||||||
coverImage: article.cover_image
|
coverImage: article.cover_image
|
||||||
? `${API_BASE_PREFIX}/rpc/retrieve_file?id=${article.cover_image}`
|
? `${API_BASE_PREFIX}/rpc/retrieve_file?id=${article.cover_image}`
|
||||||
@@ -184,7 +208,7 @@ const generateStaticFiles = async (websiteData: any, isPreview: boolean = true)
|
|||||||
logoType: websiteData.logo_type,
|
logoType: websiteData.logo_type,
|
||||||
logo:
|
logo:
|
||||||
websiteData.logo_type === "text"
|
websiteData.logo_type === "text"
|
||||||
? websiteData.logo_text
|
? (websiteData.logo_text ?? "")
|
||||||
: `${API_BASE_PREFIX}/rpc/retrieve_file?id=${websiteData.logo_image}`,
|
: `${API_BASE_PREFIX}/rpc/retrieve_file?id=${websiteData.logo_image}`,
|
||||||
mainContent: md(article.main_content ?? ""),
|
mainContent: md(article.main_content ?? ""),
|
||||||
categorizedArticles: websiteData.categorized_articles ?? [],
|
categorizedArticles: websiteData.categorized_articles ?? [],
|
||||||
|
|||||||
Reference in New Issue
Block a user