The project uses a flat ESLint configuration based on typescript-eslint. It integrates support for Svelte, TypeScript, and Prettier, and enforces specific code organization patterns using eslint-plugin-perfectionist.
Key features include:
- Svelte Support: Configured to parse
.svelte, .svelte.ts, and .svelte.js files using the Svelte parser and the project's svelte.config.js. - Global Variables: Includes
browser and node globals, and explicitly defines Picture as a readonly global. - Custom Import Sorting: Uses
perfectionist/sort-imports with custom groups to handle Svelte-specific patterns:svelte-internal: Matches imports from $types (e.g., import type { PageServerLoad } from './$types.js';).alias-imports: Matches alias imports ending in .js, .ts, or .svelte (e.g., import Component from '$lib/component.svelte';).
- Strictness:
no-console is an error, but allows warn, error, and info.- Unused variables (
@typescript-eslint/no-unused-vars) are warnings, but allow variables/arguments starting with an underscore (_).
// Summary of active rules and patterns
export default tseslint.config(
// ... recommended configs
{
rules: {
'@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
'no-console': ['error', { allow: ['warn', 'error', 'info'] }],
'perfectionist/sort-imports': [
'error',
{
customGroups: {
type: { 'svelte-internal': ['.\/\$types'] },
value: { 'alias-imports': ['^\$?.*(\.js|\.ts|\.svelte)$'] }
},
groups: ['svelte-internal', 'type', ['alias-imports'], ['builtin', 'external'], 'internal-type', 'internal', ['parent-type', 'sibling-type', 'index-type'], ['parent', 'sibling', 'index'], 'object', 'unknown']
}
]
}
}
);