import path from 'node:path'; import { includeIgnoreFile } from '@eslint/compat'; import js from '@eslint/js'; import { defineConfig } from 'eslint/config'; import prettier from 'eslint-config-prettier'; import simpleImportSort from 'eslint-plugin-simple-import-sort'; import svelte from 'eslint-plugin-svelte'; import globals from 'globals'; import ts from 'typescript-eslint'; import svelteConfig from './svelte.config.js'; const gitignorePath = path.resolve(import.meta.dirname, '.gitignore'); const prettierignorePath = path.resolve(import.meta.dirname, '.prettierignore'); export default defineConfig( includeIgnoreFile(gitignorePath), includeIgnoreFile(prettierignorePath), js.configs.recommended, ts.configs.recommended, svelte.configs.recommended, prettier, svelte.configs.prettier, { languageOptions: { globals: { ...globals.browser, ...globals.node } }, plugins: { 'simple-import-sort': simpleImportSort, }, rules: { // typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects. // 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 'no-undef': 'off', 'simple-import-sort/imports': [ 'error', { groups: [ ['^node:'], ['^@?\\w'], ['^\\$app/'], ['^\\$lib/'], ['^\\$'], ['^\\.\\./'], ['^\\./'], ], }, ], 'simple-import-sort/exports': 'error', }, }, { files: ['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js'], languageOptions: { parserOptions: { projectService: true, extraFileExtensions: ['.svelte'], parser: ts.parser, svelteConfig, }, }, rules: { 'svelte/sort-attributes': [ 'error', { order: [ 'this', 'bind:this', 'id', 'name', 'slot', { match: '/^--/u', sort: 'alphabetical' }, ['style', '/^style:/u'], 'class', { match: '/^class:/u', sort: 'alphabetical' }, { match: [ '!/:/u', '!/^(?:this|id|name|slot|style|class)$/u', '!/^--/u', '!/^on[a-z]/u', ], sort: 'alphabetical', }, ['/^bind:/u', '!bind:this', '/^on:/u', '/^on[a-z]/u'], { match: '/^use:/u', sort: 'alphabetical' }, { match: '/^transition:/u', sort: 'alphabetical' }, { match: '/^in:/u', sort: 'alphabetical' }, { match: '/^out:/u', sort: 'alphabetical' }, { match: '/^animate:/u', sort: 'alphabetical' }, { match: '/^let:/u', sort: 'alphabetical' }, ], }, ], }, }, );