web/eslint.config.js

80 lines · 2074 bytes

 1import js from '@eslint/js';
 2import tseslint from 'typescript-eslint';
 3import eslintPluginAstro from 'eslint-plugin-astro';
 4import eslintPluginSvelte from 'eslint-plugin-svelte';
 5import svelteParser from 'svelte-eslint-parser';
 6import eslintConfigPrettier from 'eslint-config-prettier';
 7import globals from 'globals';
 8
 9export default [
10  // Global ignores
11  { ignores: ['dist/', '.astro/', 'node_modules/', '.vercel/'] },
12
13  // Base JS config
14  js.configs.recommended,
15
16  // TypeScript
17  ...tseslint.configs.recommended,
18
19  // Astro
20  ...eslintPluginAstro.configs.recommended,
21
22  // Svelte — with TypeScript parser for <script lang="ts">
23  ...eslintPluginSvelte.configs['flat/recommended'].map((config) =>
24    config.files
25      ? {
26          ...config,
27          languageOptions: {
28            ...config.languageOptions,
29            parser: svelteParser,
30            parserOptions: {
31              ...config.languageOptions?.parserOptions,
32              parser: tseslint.parser,
33            },
34          },
35        }
36      : config,
37  ),
38
39  // Global settings
40  {
41    languageOptions: {
42      globals: {
43        ...globals.browser,
44        ...globals.node,
45      },
46    },
47    rules: {
48      '@typescript-eslint/no-explicit-any': 'warn',
49      '@typescript-eslint/no-unused-vars': [
50        'warn',
51        { argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
52      ],
53      '@typescript-eslint/no-unused-expressions': 'off',
54      'no-console': 'off',
55      'no-case-declarations': 'off',
56      'no-useless-assignment': 'warn',
57    },
58  },
59
60  // Allow triple-slash references in env.d.ts (Astro convention)
61  {
62    files: ['src/env.d.ts'],
63    rules: {
64      '@typescript-eslint/triple-slash-reference': 'off',
65    },
66  },
67
68  // Lenient Svelte rules — existing code uses these patterns intentionally
69  {
70    files: ['**/*.svelte'],
71    rules: {
72      'svelte/no-at-html-tags': 'warn',
73      'svelte/require-each-key': 'warn',
74      'svelte/no-dom-manipulating': 'warn',
75    },
76  },
77
78  // Prettier must be last to override conflicting rules
79  eslintConfigPrettier,
80];