# svelte-eslint-parser

> Svelte parser for ESLint

Latest version **1.8.1** (published 2026-08-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install svelte-eslint-parser
pnpm add svelte-eslint-parser
yarn add svelte-eslint-parser
bun add svelte-eslint-parser
```

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.8.1 |
| Published | 2026-08-15 |
| First published | 2021-04-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^18.18.0 \|\| ^20.9.0 \|\| >=21.1.0 |
| Dependencies | 7 |
| Unpacked size | 362.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 123 |
| Author | Yosuke Ota |
| Maintainers | conduitry, ota-meshi, svelte-admin, baseballyama |
| Keywords | svelte, sveltejs, eslint, parser |

## Links

- npm: https://www.npmjs.com/package/svelte-eslint-parser
- Repository: https://github.com/sveltejs/svelte-eslint-parser
- Homepage: https://github.com/sveltejs/svelte-eslint-parser#readme
- Issues: https://github.com/sveltejs/svelte-eslint-parser/issues
- Funding: https://github.com/sponsors/ota-meshi
- npm.io page: https://npm.io/package/svelte-eslint-parser

## Dependencies (7)

- [espree](https://npm.io/package/espree.md) ^10.0.0
- [semver](https://npm.io/package/semver.md) ^7.7.2
- [postcss](https://npm.io/package/postcss.md) ^8.4.49
- [eslint-scope](https://npm.io/package/eslint-scope.md) ^8.2.0
- [postcss-scss](https://npm.io/package/postcss-scss.md) ^4.0.9
- [eslint-visitor-keys](https://npm.io/package/eslint-visitor-keys.md) ^4.0.0
- [postcss-selector-parser](https://npm.io/package/postcss-selector-parser.md) ^7.0.0

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.8.1 (latest) — 2026-08-15
- 1.0.0-next.13 (next) — 2025-01-16
- 1.8.0 — 2026-06-04
- 1.7.1 — 2026-06-02
- 1.7.0 — 2026-05-30
- 1.6.1 — 2026-05-05
- 1.6.0 — 2026-03-05
- 1.5.1 — 2026-02-24
- 1.5.0 — 2026-02-24
- 1.4.1 — 2025-12-04
- 1.4.0 — 2025-10-19
- 1.3.3 — 2025-09-21
- 1.3.2 — 2025-09-10
- 1.3.1 — 2025-08-02
- 1.3.0 — 2025-07-16
- … 133 more at https://npm.io/package/svelte-eslint-parser/versions

## README

[![NPM license](https://img.shields.io/npm/l/svelte-eslint-parser.svg)](https://www.npmjs.com/package/svelte-eslint-parser)
[![NPM version](https://img.shields.io/npm/v/svelte-eslint-parser.svg)](https://www.npmjs.com/package/svelte-eslint-parser)
[![NPM downloads](https://img.shields.io/badge/dynamic/json.svg?label=downloads&colorB=green&suffix=/day&query=$.downloads&uri=https://api.npmjs.org//downloads/point/last-day/svelte-eslint-parser&maxAge=3600)](http://www.npmtrends.com/svelte-eslint-parser)
[![NPM downloads](https://img.shields.io/npm/dw/svelte-eslint-parser.svg)](http://www.npmtrends.com/svelte-eslint-parser)
[![NPM downloads](https://img.shields.io/npm/dm/svelte-eslint-parser.svg)](http://www.npmtrends.com/svelte-eslint-parser)
[![NPM downloads](https://img.shields.io/npm/dy/svelte-eslint-parser.svg)](http://www.npmtrends.com/svelte-eslint-parser)
[![NPM downloads](https://img.shields.io/npm/dt/svelte-eslint-parser.svg)](http://www.npmtrends.com/svelte-eslint-parser)
[![Build Status](https://github.com/sveltejs/svelte-eslint-parser/workflows/CI/badge.svg?branch=main)](https://github.com/sveltejs/svelte-eslint-parser/actions?query=workflow%3ACI)
[![Coverage Status](https://coveralls.io/repos/github/sveltejs/svelte-eslint-parser/badge.svg?branch=main)](https://coveralls.io/github/sveltejs/svelte-eslint-parser?branch=main)

<div align="center">

# svelte-eslint-parser

## [Svelte](https://svelte.dev/) parser for [ESLint](https://eslint.org/)

[Live DEMO](https://sveltejs.github.io/svelte-eslint-parser/playground) •
[Discord](https://svelte.dev/chat)

</div>

## Motivation

The `svelte-eslint-parser` aims to make it easy to create your own ESLint rules for [Svelte](https://svelte.dev/).

[eslint-plugin-svelte](https://github.com/sveltejs/eslint-plugin-svelte) is an ESLint plugin built upon this parser, and it already [implements some rules](https://sveltejs.github.io/eslint-plugin-svelte/rules/).

### ESLint Plugins Using svelte-eslint-parser

#### [eslint-plugin-svelte](https://sveltejs.github.io/eslint-plugin-svelte/)

ESLint plugin for Svelte.  
Provides a variety of template-based checks using the Svelte AST.

#### [@intlify/eslint-plugin-svelte](https://github.com/intlify/eslint-plugin-svelte)

ESLint plugin for internationalization (i18n) in Svelte applications, offering helpful i18n-related rules.

---

## Installation

```bash
npm install --save-dev eslint svelte-eslint-parser
```

---

## Usage

### ESLint Config (`eslint.config.js`)

```js
import js from "@eslint/js";
import svelteParser from "svelte-eslint-parser";

export default [
  js.configs.recommended,
  {
    files: [
      "**/*.svelte",
      "*.svelte",
      // Need to specify the file extension for Svelte 5 with rune symbols
      "**/*.svelte.js",
      "*.svelte.js",
      "**/*.svelte.ts",
      "*.svelte.ts",
    ],
    languageOptions: {
      parser: svelteParser,
    },
  },
];
```

### CLI

```bash
eslint "src/**/*.{js,svelte}"
```

---

## Options

The [parserOptions](https://eslint.org/docs/latest/use/configure/parser#configure-parser-options) for this parser generally match what [espree](https://github.com/eslint/espree#usage)—ESLint's default parser—supports.

For example:

```js
import svelteParser from "svelte-eslint-parser";

export default [
  // ...
  {
    files: [
      // Set .svelte/.js/.ts files. See above for more details.
    ],
    languageOptions: {
      parser: svelteParser,
      parserOptions: {
        sourceType: "module",
        ecmaVersion: 2024,
        ecmaFeatures: {
          globalReturn: false,
          impliedStrict: false,
          jsx: false,
        },
      },
    },
  },
];
```

### parserOptions.parser

Use the `parserOptions.parser` property to define a custom parser for `<script>` tags. Any additional parser options (besides the parser itself) are passed along to the specified parser.

```js
import tsParser from "@typescript-eslint/parser";

export default [
  {
    files: [
      // Set .svelte/.js/.ts files. See above for more details.
    ],
    languageOptions: {
      parser: svelteParser,
      parserOptions: {
        parser: tsParser,
      },
    },
  },
];
```

#### Using TypeScript in `<script>`

If you use `@typescript-eslint/parser` for TypeScript within `<script>` of `.svelte` files, additional configuration is needed. For example:

```js
import tsParser from "@typescript-eslint/parser";

export default [
  // Other config for non-Svelte files
  {
    languageOptions: {
      parser: tsParser,
      parserOptions: {
        project: "path/to/your/tsconfig.json",
        extraFileExtensions: [".svelte"],
      },
    },
  },
  // Svelte config
  {
    files: [
      // Set .svelte/.js/.ts files. See above for more details.
    ],
    languageOptions: {
      parser: svelteParser,
      // Parse the `<script>` in `.svelte` as TypeScript by adding the following configuration.
      parserOptions: {
        parser: tsParser,
      },
    },
  },
];
```

#### Multiple parsers

To switch parsers for each language, provide an object:

```js
import tsParser from "@typescript-eslint/parser";
import espree from "espree";

export default [
  {
    files: [
      // Set .svelte/.js/.ts files. See above for more details.
    ],
    languageOptions: {
      parser: svelteParser,
      parserOptions: {
        parser: {
          ts: tsParser,
          js: espree,
          typescript: tsParser,
        },
      },
    },
  },
];
```

### parserOptions.svelteConfig

If you use `eslint.config.js`, you can specify a `svelte.config.js` file via `parserOptions.svelteConfig`.

```js
import svelteConfig from "./svelte.config.js";

export default [
  {
    files: [
      // Set .svelte/.js/.ts files. See above for more details.
    ],
    languageOptions: {
      parser: svelteParser,
      parserOptions: {
        svelteConfig,
      },
    },
  },
];
```

If `parserOptions.svelteConfig` is not set, the parser attempts to statically read some config from `svelte.config.js`.

### parserOptions.svelteFeatures

You can configure how Svelte-specific features are parsed via `parserOptions.svelteFeatures`.

For example:

```js
export default [
  {
    files: [
      // Set .svelte/.js/.ts files. See above for more details.
    ],
    languageOptions: {
      parser: svelteParser,
      parserOptions: {
        svelteFeatures: {
          // This is for Svelte 5. The default is true.
          // If false, ESLint won't recognize rune symbols.
          // If not specified, the parser tries to read compilerOptions.runes from `svelte.config.js`.
          // If `parserOptions.svelteConfig` is not given and static analysis fails, it defaults to true.
          runes: true,
        },
      },
    },
  },
];
```

---

## Experimental

### `ts.sys.readFile` hook for type-aware Svelte lint

> ⚠️ **Experimental.** Opt-in only; behavior may change or be removed.

Speeds up type-aware lint of `.svelte` files. Your ESLint config must
already list `.svelte` via `parserOptions.extraFileExtensions`.

```sh
SVELTE_ESLINT_PARSER_EXPERIMENTAL_TS_SYS_HOOK=1 \
  eslint --no-cache --concurrency auto .
```

Caveat: rules that read raw TypeScript diagnostics
(`program.getSemanticDiagnostics()` and friends) report positions inside
the parser's virtual shim — a pre-existing property of type-aware Svelte
lint, not specific to the hook.

---

## Editor Integrations

### Visual Studio Code

Use the [dbaeumer.vscode-eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) extension provided by Microsoft.

By default, it only targets `*.js` and `*.jsx`, so you need to configure `.svelte` file support. For example, in **.vscode/settings.json**:

```json
{
  "eslint.validate": ["javascript", "javascriptreact", "svelte"]
}
```

---

## Usage for Custom Rules / Plugins

- See [AST.md](./docs/AST.md) for the AST specification. You can explore it on the [Live DEMO](https://sveltejs.github.io/svelte-eslint-parser/).
- This parser generates its own [ScopeManager](https://eslint.org/docs/developer-guide/scope-manager-interface). Check the [Live DEMO](https://sveltejs.github.io/svelte-eslint-parser/scope).
- Several rules are [already implemented] in [`eslint-plugin-svelte`], and their source code can be a helpful reference.

---

## Contributing

Contributions are welcome! Please open an issue or submit a PR on GitHub.  
For internal details, see [internal-mechanism.md](./docs/internal-mechanism.md).

---

## License

See [LICENSE](LICENSE) (MIT) for rights and limitations.

---
_Source: https://npm.io/package/svelte-eslint-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
