|
| 1 | +import globals from "globals"; |
| 2 | +import svelte from "eslint-plugin-svelte"; |
| 3 | +import tseslint from "typescript-eslint"; |
| 4 | +import svelteConfig from "./svelte.config.js"; |
| 5 | +import stylistic from "@stylistic/eslint-plugin"; |
| 6 | +import js from "@eslint/js"; |
| 7 | + |
| 8 | +export default [ |
| 9 | + js.configs.recommended, |
| 10 | + ...tseslint.configs.recommended, |
| 11 | + ...svelte.configs.recommended, |
| 12 | + { |
| 13 | + plugins: { |
| 14 | + "@stylistic": stylistic, |
| 15 | + }, |
| 16 | + }, |
| 17 | + { |
| 18 | + languageOptions: { |
| 19 | + globals: { |
| 20 | + ...globals.browser, |
| 21 | + ...globals.node, // Add this if you are using SvelteKit in non-SPA mode |
| 22 | + }, |
| 23 | + }, |
| 24 | + }, |
| 25 | + { |
| 26 | + files: ["**/*.svelte", "**/*.svelte.ts", "**/*.svelte.js"], |
| 27 | + // See more details at: https://typescript-eslint.io/packages/parser/ |
| 28 | + languageOptions: { |
| 29 | + parserOptions: { |
| 30 | + projectService: true, |
| 31 | + extraFileExtensions: [".svelte"], // Add support for additional file extensions, such as .svelte |
| 32 | + parser: tseslint.parser, |
| 33 | + // Specify a parser for each language, if needed: |
| 34 | + // parser: { |
| 35 | + // ts: ts.parser, |
| 36 | + // js: espree, // Use espree for .js files (add: import espree from 'espree') |
| 37 | + // typescript: ts.parser |
| 38 | + // }, |
| 39 | + |
| 40 | + // We recommend importing and specifying svelte.config.js. |
| 41 | + // By doing so, some rules in eslint-plugin-svelte will automatically read the configuration and adjust their behavior accordingly. |
| 42 | + // While certain Svelte settings may be statically loaded from svelte.config.js even if you don’t specify it, |
| 43 | + // explicitly specifying it ensures better compatibility and functionality. |
| 44 | + // |
| 45 | + // If non-serializable properties are included, running ESLint with the --cache flag will fail. |
| 46 | + // In that case, please remove the non-serializable properties. (e.g. `svelteConfig: { ...svelteConfig, kit: { ...svelteConfig.kit, typescript: undefined }}`) |
| 47 | + svelteConfig |
| 48 | + }, |
| 49 | + } |
| 50 | + }, |
| 51 | + // { |
| 52 | + // "overrides": [ |
| 53 | + // { |
| 54 | + // "files": ["*.svelte"], |
| 55 | + // "rules": { |
| 56 | + // "svelte/indent": [ |
| 57 | + // "error", |
| 58 | + // { indent: 4 }, |
| 59 | + // ], |
| 60 | + // "indent": "off" |
| 61 | + // } |
| 62 | + // } |
| 63 | + // ], |
| 64 | + |
| 65 | + // }, |
| 66 | + { |
| 67 | + rules: { |
| 68 | + "indent": [ |
| 69 | + "error", |
| 70 | + 4, |
| 71 | + ], |
| 72 | + "svelte/indent": [ |
| 73 | + "error", |
| 74 | + { indent: 4 }, |
| 75 | + ], |
| 76 | + |
| 77 | + "linebreak-style": ["error", "unix"], |
| 78 | + "@stylistic/quotes": ["error", "double"], |
| 79 | + "@stylistic/semi": "error", |
| 80 | + }, |
| 81 | + }, |
| 82 | +]; |
0 commit comments