1import prettier from 'eslint-config-prettier';
2import { fileURLToPath } from 'node:url';
3import { includeIgnoreFile } from '@eslint/compat';
4import js from '@eslint/js';
5import svelte from 'eslint-plugin-svelte';
6import { defineConfig } from 'eslint/config';
7import globals from 'globals';
8import ts from 'typescript-eslint';
9import svelteConfig from './svelte.config.js';
10
11const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));
12
13export default defineConfig(
14 includeIgnoreFile(gitignorePath),
15 js.configs.recommended,
16 ...ts.configs.recommended,
17 ...svelte.configs.recommended,
18 prettier,
19 ...svelte.configs.prettier,
20 {
21 languageOptions: {
22 globals: { ...globals.browser, ...globals.node }
23 },
24 rules: {
25 // typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects.
26 // 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
27 'no-undef': 'off'
28 }
29 },
30 {
31 files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'],
32 languageOptions: {
33 parserOptions: {
34 projectService: true,
35 extraFileExtensions: ['.svelte'],
36 parser: ts.parser,
37 svelteConfig
38 }
39 }
40 }
41);