|
| 1 | +import {defineConfig} from 'eslint/config' |
| 2 | +import {fileURLToPath} from 'node:url' |
| 3 | +import {includeIgnoreFile} from '@eslint/compat' |
| 4 | +import globals from 'globals' |
| 5 | +import js from '@eslint/js' |
| 6 | +import path from 'node:path' |
| 7 | +import prettier from 'eslint-config-prettier' |
| 8 | +import {createRequire} from 'node:module' |
| 9 | + |
| 10 | +import svelte from 'eslint-plugin-svelte' |
| 11 | +import tseslint from 'typescript-eslint' |
| 12 | + |
| 13 | +import type {Linter} from 'eslint' |
| 14 | + |
| 15 | +const studio = createRequire(import.meta.url)('@sanity/eslint-config-studio') as Linter.Config[] |
| 16 | + |
| 17 | +import appSvelteConfig from './sveltekit-app/svelte.config.js' |
| 18 | + |
| 19 | +const gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url)) |
| 20 | +const tsconfigRootDir = path.dirname(fileURLToPath(import.meta.url)) |
| 21 | + |
| 22 | +export default defineConfig( |
| 23 | + // Respect .gitignore |
| 24 | + includeIgnoreFile(gitignorePath), |
| 25 | + { |
| 26 | + ignores: [ |
| 27 | + 'eslint.config.ts', |
| 28 | + 'vite.config.ts', |
| 29 | + 'svelte.config.js', |
| 30 | + '**/sanity.cli.ts', |
| 31 | + '**/*.config.js', |
| 32 | + '**/*.config.ts', |
| 33 | + ], |
| 34 | + }, |
| 35 | + // Base JS + TS |
| 36 | + js.configs.recommended, |
| 37 | + ...tseslint.configs.recommended, |
| 38 | + |
| 39 | + // Svelte flat presets |
| 40 | + ...svelte.configs['flat/recommended'], |
| 41 | + ...svelte.configs['flat/prettier'], |
| 42 | + |
| 43 | + // Global language options |
| 44 | + { |
| 45 | + languageOptions: { |
| 46 | + globals: {...globals.browser, ...globals.node}, |
| 47 | + parserOptions: { |
| 48 | + // Let typescript-eslint resolve per-package projects automatically |
| 49 | + projectService: true, |
| 50 | + // optional (safe if you keep it) |
| 51 | + tsconfigRootDir, |
| 52 | + extraFileExtensions: ['.svelte'], |
| 53 | + }, |
| 54 | + }, |
| 55 | + }, |
| 56 | + |
| 57 | + // App config |
| 58 | + { |
| 59 | + files: ['sveltekit-app/**/*.svelte'], |
| 60 | + languageOptions: { |
| 61 | + parserOptions: { |
| 62 | + parser: tseslint.parser, |
| 63 | + svelteConfig: appSvelteConfig, |
| 64 | + }, |
| 65 | + }, |
| 66 | + }, |
| 67 | + // Studio config |
| 68 | + ...studio, |
| 69 | + |
| 70 | + // Repo rules |
| 71 | + { |
| 72 | + rules: { |
| 73 | + 'no-console': 'error', |
| 74 | + '@typescript-eslint/no-empty-object-type': 'off', |
| 75 | + }, |
| 76 | + }, |
| 77 | + |
| 78 | + // Keep last |
| 79 | + prettier, |
| 80 | +) |
0 commit comments