From 1d3448cbf52f24f395dcceb0d71d12c61e6da2da Mon Sep 17 00:00:00 2001 From: HorizonCode Date: Fri, 4 Jul 2025 22:15:53 +0200 Subject: [PATCH] chore: add eslint config --- eslint.config.js | 40 ++++++++++++++++++++++++++++++++++++++++ package.json | 9 ++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 eslint.config.js diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..43e40d6 --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,40 @@ +import prettier from 'eslint-config-prettier'; +import { includeIgnoreFile } from '@eslint/compat'; +import js from '@eslint/js'; +import svelte from 'eslint-plugin-svelte'; +import globals from 'globals'; +import { fileURLToPath } from 'node:url'; +import ts from 'typescript-eslint'; +import svelteConfig from './svelte.config.js'; + +const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url)); + +export default ts.config( + includeIgnoreFile(gitignorePath), + js.configs.recommended, + ...ts.configs.recommended, + ...svelte.configs.recommended, + prettier, + ...svelte.configs.prettier, + { + languageOptions: { + globals: { ...globals.browser, ...globals.node }, + }, + rules: { + // typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects. + // see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors + 'no-undef': 'off', + }, + }, + { + files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'], + languageOptions: { + parserOptions: { + projectService: true, + extraFileExtensions: ['.svelte'], + parser: ts.parser, + svelteConfig, + }, + }, + } +); diff --git a/package.json b/package.json index f65be5f..563288b 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "tauri": "tauri", "update-logo": "bun run tauri icon ./static/logo.png", "format": "prettier --write .", - "lint": "prettier --check ." + "lint": "prettier --check . && eslint ." }, "license": "MIT", "dependencies": { @@ -40,6 +40,8 @@ "svelte-confetti": "^2.0.0" }, "devDependencies": { + "@eslint/compat": "^1.2.5", + "@eslint/js": "^9.18.0", "@lucide/svelte": "^0.482.0", "@sveltejs/adapter-static": "3.0.8", "@sveltejs/kit": "2.22.2", @@ -49,6 +51,10 @@ "autoprefixer": "10.4.21", "bits-ui": "^1.4.7", "clsx": "2.1.1", + "eslint": "^9.18.0", + "eslint-config-prettier": "^10.0.1", + "eslint-plugin-svelte": "^3.0.0", + "globals": "^16.0.0", "mode-watcher": "^1.0.6", "prettier": "^3.4.2", "prettier-plugin-svelte": "^3.3.3", @@ -62,6 +68,7 @@ "tailwindcss-animate": "1.0.7", "tslib": "2.8.1", "typescript": "5.8.3", + "typescript-eslint": "^8.20.0", "vite": "7.0.0", "vite-plugin-devtools-json": "^0.2.0" }