|
| 1 | +import prettier from 'eslint-config-prettier'; |
| 2 | +import { includeIgnoreFile } from '@eslint/compat'; |
| 3 | +import js from '@eslint/js'; |
| 4 | +import svelte from 'eslint-plugin-svelte'; |
| 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 | +import path from 'node:path'; |
| 10 | + |
| 11 | +const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url)); |
| 12 | + |
| 13 | +export default ts.config( |
| 14 | + includeIgnoreFile(gitignorePath), |
| 15 | + js.configs.recommended, |
| 16 | + ...ts.configs.recommendedTypeChecked, |
| 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: ['**/*.ts'], |
| 32 | + languageOptions: { |
| 33 | + parser: ts.parser, |
| 34 | + parserOptions: { |
| 35 | + projectService: true, |
| 36 | + tsconfigRootDir: import.meta.dirname |
| 37 | + } |
| 38 | + } |
| 39 | + }, |
| 40 | + { |
| 41 | + files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'], |
| 42 | + languageOptions: { |
| 43 | + parserOptions: { |
| 44 | + extraFileExtensions: ['.svelte'], |
| 45 | + parser: ts.parser, |
| 46 | + svelteConfig, |
| 47 | + projectService: true, |
| 48 | + tsconfigRootDir: import.meta.dirname |
| 49 | + } |
| 50 | + } |
| 51 | + }, |
| 52 | + { |
| 53 | + ignores: [ |
| 54 | + 'dist/', |
| 55 | + 'src/declarations', |
| 56 | + '*.config.js', |
| 57 | + '*.config.ts', |
| 58 | + '*.config.cjs', |
| 59 | + '*.config.mjs', |
| 60 | + '.svelte-kit', |
| 61 | + 'e2e/' |
| 62 | + ] |
| 63 | + } |
| 64 | +); |
0 commit comments