|
| 1 | +import prettier from 'eslint-config-prettier'; |
1 | 2 | import js from '@eslint/js'; |
2 | | -import ts from 'typescript-eslint'; |
| 3 | +import { includeIgnoreFile } from '@eslint/compat'; |
3 | 4 | import svelte from 'eslint-plugin-svelte'; |
4 | | -import prettier from 'eslint-config-prettier'; |
5 | 5 | import globals from 'globals'; |
| 6 | +import { fileURLToPath } from 'node:url'; |
| 7 | +import ts from 'typescript-eslint'; |
| 8 | +import svelteConfig from './svelte.config.js'; |
| 9 | + |
| 10 | +const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url)); |
6 | 11 |
|
7 | | -/** @type {import('eslint').Linter.FlatConfig[]} */ |
8 | | -export default [ |
9 | | - js.configs.recommended, |
10 | | - ...ts.configs.recommended, |
11 | | - ...svelte.configs['flat/recommended'], |
12 | | - prettier, |
13 | | - ...svelte.configs['flat/prettier'], |
14 | | - { |
15 | | - languageOptions: { |
16 | | - globals: { |
17 | | - ...globals.browser, |
18 | | - ...globals.node |
19 | | - } |
20 | | - } |
21 | | - }, |
22 | | - { |
23 | | - files: ['**/*.svelte'], |
24 | | - languageOptions: { |
25 | | - parserOptions: { |
26 | | - parser: ts.parser |
27 | | - } |
28 | | - } |
29 | | - }, |
30 | | - { |
31 | | - ignores: ['build/', '.svelte-kit/', 'dist/'] |
32 | | - } |
33 | | -]; |
| 12 | +export default ts.config( |
| 13 | + includeIgnoreFile(gitignorePath), |
| 14 | + js.configs.recommended, |
| 15 | + ...ts.configs.recommended, |
| 16 | + ...svelte.configs.recommended, |
| 17 | + prettier, |
| 18 | + ...svelte.configs.prettier, |
| 19 | + { |
| 20 | + languageOptions: { |
| 21 | + globals: { ...globals.browser, ...globals.node }, |
| 22 | + }, |
| 23 | + rules: { |
| 24 | + 'no-undef': 'off', |
| 25 | + '@typescript-eslint/no-unused-vars': 'warn', |
| 26 | + }, |
| 27 | + }, |
| 28 | + { |
| 29 | + files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'], |
| 30 | + ignores: ['eslint.config.js', 'svelte.config.js'], |
| 31 | + languageOptions: { |
| 32 | + parserOptions: { |
| 33 | + projectService: true, |
| 34 | + extraFileExtensions: ['.svelte'], |
| 35 | + parser: ts.parser, |
| 36 | + svelteConfig, |
| 37 | + }, |
| 38 | + }, |
| 39 | + }, |
| 40 | +); |
0 commit comments