+ Add in ESLint support, with TS and Svelte included.
~ Resolve typing issues in both countdown, and in the healthcheck endpoint
This commit is contained in:
Nick Bland 2024-04-19 16:48:42 +10:00
parent f4ef664f0b
commit 97aa6cd24e
Signed by: NickBland
GPG Key ID: 31CADD9E5FDD798C
7 changed files with 55 additions and 16 deletions

View File

@ -3,6 +3,7 @@
"singleQuote": false, "singleQuote": false,
"printWidth": 90, "printWidth": 90,
"plugins": ["prettier-plugin-svelte"], "plugins": ["prettier-plugin-svelte"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }],
"semi": true, "semi": true,
"svelteSortOrder": "options-styles-scripts-markup", "svelteSortOrder": "options-styles-scripts-markup",
"svelteStrictMode": false, "svelteStrictMode": false,

BIN
bun.lockb

Binary file not shown.

37
eslint.config.js Normal file
View File

@ -0,0 +1,37 @@
import globals from "globals";
import js from "@eslint/js";
import eslintConfigPrettier from "eslint-config-prettier";
import tsEslint from "typescript-eslint";
import eslintPluginSvelte from "eslint-plugin-svelte";
import svelteParser from "svelte-eslint-parser";
export default tsEslint.config(
js.configs.recommended,
...tsEslint.configs.recommended,
...eslintPluginSvelte.configs["flat/recommended"],
eslintConfigPrettier,
...eslintPluginSvelte.configs["flat/prettier"],
{
files: ["**/*.svelte"],
languageOptions: {
ecmaVersion: 2022,
sourceType: "module",
globals: { ...globals.node, ...globals.browser },
parser: svelteParser,
parserOptions: {
parser: tsEslint.parser,
extraFileExtensions: [".svelte"],
},
},
},
{
ignores: [
"**/.svelte-kit",
"**/.vercel",
"**/.yarn",
"**/build",
"**/node_modules",
"**/package",
],
},
);

View File

@ -8,29 +8,32 @@
"preview": "vite preview", "preview": "vite preview",
"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 . && eslint .", "lint": "eslint './src/**/*.{js,ts,svelte}' --fix",
"format": "prettier --write ." "format": "prettier --write ."
}, },
"devDependencies": { "devDependencies": {
"@eslint/js": "^9.0.0",
"@sveltejs/adapter-auto": "^3.2.0", "@sveltejs/adapter-auto": "^3.2.0",
"@sveltejs/kit": "^2.5.5", "@sveltejs/kit": "^2.5.6",
"@sveltejs/vite-plugin-svelte": "^3.0.2", "@sveltejs/vite-plugin-svelte": "^3.1.0",
"@typescript-eslint/eslint-plugin": "^7.5.0",
"@typescript-eslint/parser": "^7.5.0",
"autoprefixer": "^10.4.19", "autoprefixer": "^10.4.19",
"daisyui": "latest", "daisyui": "latest",
"eslint": "^9.0.0", "eslint": "^9.0.0",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.36.0", "eslint-plugin-svelte": "^2.37.0",
"globals": "^15.0.0",
"postcss": "^8.4.38", "postcss": "^8.4.38",
"prettier": "^3.2.5", "prettier": "^3.2.5",
"prettier-plugin-svelte": "^3.2.3", "prettier-plugin-svelte": "^3.2.3",
"svelte": "^4.2.12", "svelte": "^4.2.15",
"svelte-check": "^3.6.9", "svelte-check": "^3.6.9",
"svelte-eslint-parser": "^0.34.1",
"svelte-preprocess": "^5.1.4",
"tailwindcss": "^3.4.3", "tailwindcss": "^3.4.3",
"tslib": "^2.6.2", "tslib": "^2.6.2",
"typescript": "^5.4.4", "typescript": "^5.4.5",
"vite": "^5.2.8" "typescript-eslint": "^7.7.0",
"vite": "^5.2.9"
}, },
"type": "module" "type": "module"
} }

View File

@ -2,7 +2,7 @@
import { onMount } from "svelte"; import { onMount } from "svelte";
const GRADUATION = new Date(1753797600000).valueOf(); const GRADUATION = new Date(1753797600000).valueOf();
let interval: NodeJS.Timer; let interval: ReturnType<typeof setInterval>;
let timeTo = Math.abs(GRADUATION - Date.now().valueOf()) / 1000; let timeTo = Math.abs(GRADUATION - Date.now().valueOf()) / 1000;

View File

@ -1,5 +1,3 @@
import type { RequestHandler } from "./$types"; export function GET() {
export const GET: RequestHandler = ({ url }) => {
return new Response(); return new Response();
}; }

View File

@ -1,11 +1,11 @@
import adapter from "@sveltejs/adapter-auto"; import adapter from "@sveltejs/adapter-auto";
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte"; import sveltePreprocess from "svelte-preprocess";
/** @type {import('@sveltejs/kit').Config} */ /** @type {import('@sveltejs/kit').Config} */
const config = { const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors // Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors // for more information about preprocessors
preprocess: vitePreprocess(), preprocess: sveltePreprocess(),
kit: { kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.