svelte-eslint-parser is the official ESLint parser designed specifically for Svelte applications. It processes `.svelte` files, including their template, script, and style sections, enabling ESLint to analyze and report issues within Svelte's unique syntax. The current stable version is 1.6.0. It follows a release cadence that aligns with new Svelte features and ESLint updates, with minor and patch releases occurring frequently to add support for new Svelte runes, syntax, and improve compatibility with recent ESLint versions. Its key differentiator is its deep integration with Svelte's AST, allowing it to provide a unified parsing experience for both the JavaScript/TypeScript logic and the Svelte-specific template markup, which is crucial for tools like `eslint-plugin-svelte` and `@intlify/eslint-plugin-svelte` to function effectively. The parser is essential for any Svelte project using ESLint for code quality and style enforcement.
npm install svelte-eslint-parserVerified import paths — ran on the pinned version, not inferred.
This configuration sets up ESLint with `svelte-eslint-parser` for Svelte 3/4/5 files, including TypeScript support within script blocks.
Update your `.eslintrc.*` or `package.json` configurations to use `eslint.config.js` and move parser settings into the `languageOptions` object as shown in the quickstart example.
Ensure your `languageOptions.parserOptions` for Svelte files includes `{ parser: '@typescript-eslint/parser', extraFileExtensions: ['.svelte'], project: './tsconfig.json' }`.Adjust the `files` array in your `eslint.config.js` to include `**/*.svelte.js` and `**/*.svelte.ts` for comprehensive coverage of Svelte 5 projects.
Migrate your ESLint configuration to the new flat config format (eslint.config.js) for full compatibility and future-proofing, following the official ESLint migration guide and the parser's documentation.
Run `npm install --save-dev svelte-eslint-parser eslint` to install the necessary packages.
Migrate to the `eslint.config.js` flat configuration format, or check the parser name for typos. If sticking with legacy config (not recommended), ensure ESLint and the parser are compatible versions.
In your `languageOptions.parserOptions`, ensure `sourceType: 'module'` is set for the files being parsed by `svelte-eslint-parser`.
Add `project: ['./tsconfig.json']` to your `languageOptions.parserOptions` when configuring `svelte-eslint-parser` to use `@typescript-eslint/parser` for script blocks. Also, ensure `extraFileExtensions: ['.svelte']` is present.