|
| 1 | +// eslint.config.js |
| 2 | +import js from '@eslint/js'; |
| 3 | +import svelte from 'eslint-plugin-svelte'; |
| 4 | +import globals from 'globals'; |
| 5 | +import ts from 'typescript-eslint'; |
| 6 | +import svelteConfig from './svelte.config.js'; |
| 7 | +import eslintConfigPrettier from "eslint-config-prettier/flat"; |
| 8 | +import importPlugin from "eslint-plugin-import" |
| 9 | + |
| 10 | +export default ts.config( |
| 11 | + js.configs.recommended, |
| 12 | + ...ts.configs.recommended, |
| 13 | + ...svelte.configs.recommended, |
| 14 | + { |
| 15 | + languageOptions: { |
| 16 | + globals: { |
| 17 | + ...globals.browser, |
| 18 | + ...globals.node |
| 19 | + } |
| 20 | + } |
| 21 | + }, |
| 22 | + { |
| 23 | + files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'], |
| 24 | + // See more details at: https://typescript-eslint.io/packages/parser/ |
| 25 | + languageOptions: { |
| 26 | + parserOptions: { |
| 27 | + projectService: true, |
| 28 | + extraFileExtensions: ['.svelte'], // Add support for additional file extensions, such as .svelte |
| 29 | + parser: ts.parser, |
| 30 | + // Specify a parser for each language, if needed: |
| 31 | + // parser: { |
| 32 | + // ts: ts.parser, |
| 33 | + // js: espree, // Use espree for .js files (add: import espree from 'espree') |
| 34 | + // typescript: ts.parser |
| 35 | + // }, |
| 36 | + |
| 37 | + // We recommend importing and specifying svelte.config.js. |
| 38 | + // By doing so, some rules in eslint-plugin-svelte will automatically read the configuration and adjust their behavior accordingly. |
| 39 | + // While certain Svelte settings may be statically loaded from svelte.config.js even if you don’t specify it, |
| 40 | + // explicitly specifying it ensures better compatibility and functionality. |
| 41 | + svelteConfig |
| 42 | + } |
| 43 | + } |
| 44 | + }, |
| 45 | + { |
| 46 | + ...importPlugin.flatConfigs.recommended, |
| 47 | + ...importPlugin.flatConfigs.typescript, |
| 48 | + rules: { |
| 49 | + "import/order": [ |
| 50 | + "error", |
| 51 | + { |
| 52 | + pathGroups: [ |
| 53 | + { |
| 54 | + pattern: "@/**", |
| 55 | + group: "external", |
| 56 | + position: "after", |
| 57 | + }, |
| 58 | + ], |
| 59 | + "newlines-between": "always", |
| 60 | + "named": true, |
| 61 | + alphabetize: { order: "asc" }, |
| 62 | + }, |
| 63 | + ], |
| 64 | + "import/first": "error", |
| 65 | + "import/extensions": ["error", "never", { "svg": "always", "png": "always", "jpg": "always", "webp": "always", "svelte": "always", "css": "always" }], |
| 66 | + "@typescript-eslint/consistent-type-imports": "error", |
| 67 | + }, |
| 68 | + }, |
| 69 | + eslintConfigPrettier, |
| 70 | + { |
| 71 | + rules: { |
| 72 | + // Override or add rule settings here, such as: |
| 73 | + // 'svelte/rule-name': 'error' |
| 74 | + } |
| 75 | + } |
| 76 | +); |
0 commit comments