Gathering detailed insights and metrics for svelte-eslint-parser
Gathering detailed insights and metrics for svelte-eslint-parser
Gathering detailed insights and metrics for svelte-eslint-parser
Gathering detailed insights and metrics for svelte-eslint-parser
npm install svelte-eslint-parser
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (86.03%)
Svelte (9.23%)
JavaScript (4.47%)
Dockerfile (0.21%)
HTML (0.07%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
109 Stars
802 Commits
23 Forks
5 Watchers
16 Branches
15 Contributors
Updated on Jul 12, 2025
Latest Version
1.2.0
Package Id
svelte-eslint-parser@1.2.0
Unpacked Size
333.02 kB
Size
67.26 kB
File Count
109
NPM Version
10.8.2
Node Version
20.19.1
Published on
May 15, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
48
The svelte-eslint-parser
aims to make it easy to create your own ESLint rules for Svelte.
eslint-plugin-svelte is an ESLint plugin built upon this parser, and it already implements some rules.
ESLint plugin for Svelte.
Provides a variety of template-based checks using the Svelte AST.
ESLint plugin for internationalization (i18n) in Svelte applications, offering helpful i18n-related rules.
1npm install --save-dev eslint svelte-eslint-parser
eslint.config.js
)1import js from "@eslint/js"; 2import svelteParser from "svelte-eslint-parser"; 3 4export default [ 5 js.configs.recommended, 6 { 7 files: [ 8 "**/*.svelte", 9 "*.svelte", 10 // Need to specify the file extension for Svelte 5 with rune symbols 11 "**/*.svelte.js", 12 "*.svelte.js", 13 "**/*.svelte.ts", 14 "*.svelte.ts", 15 ], 16 languageOptions: { 17 parser: svelteParser, 18 }, 19 }, 20];
1eslint "src/**/*.{js,svelte}"
The parserOptions for this parser generally match what espree—ESLint's default parser—supports.
For example:
1import svelteParser from "svelte-eslint-parser"; 2 3export default [ 4 // ... 5 { 6 files: [ 7 // Set .svelte/.js/.ts files. See above for more details. 8 ], 9 languageOptions: { 10 parser: svelteParser, 11 parserOptions: { 12 sourceType: "module", 13 ecmaVersion: 2021, 14 ecmaFeatures: { 15 globalReturn: false, 16 impliedStrict: false, 17 jsx: false, 18 }, 19 }, 20 }, 21 }, 22];
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.
1import tsParser from "@typescript-eslint/parser"; 2 3export default [ 4 { 5 files: [ 6 // Set .svelte/.js/.ts files. See above for more details. 7 ], 8 languageOptions: { 9 parser: svelteParser, 10 parserOptions: { 11 parser: tsParser, 12 }, 13 }, 14 }, 15];
<script>
If you use @typescript-eslint/parser
for TypeScript within <script>
of .svelte
files, additional configuration is needed. For example:
1import tsParser from "@typescript-eslint/parser"; 2 3export default [ 4 // Other config for non-Svelte files 5 { 6 languageOptions: { 7 parser: tsParser, 8 parserOptions: { 9 project: "path/to/your/tsconfig.json", 10 extraFileExtensions: [".svelte"], 11 }, 12 }, 13 }, 14 // Svelte config 15 { 16 files: [ 17 // Set .svelte/.js/.ts files. See above for more details. 18 ], 19 languageOptions: { 20 parser: svelteParser, 21 // Parse the `<script>` in `.svelte` as TypeScript by adding the following configuration. 22 parserOptions: { 23 parser: tsParser, 24 }, 25 }, 26 }, 27];
To switch parsers for each language, provide an object:
1import tsParser from "@typescript-eslint/parser"; 2import espree from "espree"; 3 4export default [ 5 { 6 files: [ 7 // Set .svelte/.js/.ts files. See above for more details. 8 ], 9 languageOptions: { 10 parser: svelteParser, 11 parserOptions: { 12 parser: { 13 ts: tsParser, 14 js: espree, 15 typescript: tsParser, 16 }, 17 }, 18 }, 19 }, 20];
If you use eslint.config.js
, you can specify a svelte.config.js
file via parserOptions.svelteConfig
.
1import svelteConfig from "./svelte.config.js"; 2 3export default [ 4 { 5 files: [ 6 // Set .svelte/.js/.ts files. See above for more details. 7 ], 8 languageOptions: { 9 parser: svelteParser, 10 parserOptions: { 11 svelteConfig, 12 }, 13 }, 14 }, 15];
If parserOptions.svelteConfig
is not set, the parser attempts to statically read some config from svelte.config.js
.
You can configure how Svelte-specific features are parsed via parserOptions.svelteFeatures
.
For example:
1export default [ 2 { 3 files: [ 4 // Set .svelte/.js/.ts files. See above for more details. 5 ], 6 languageOptions: { 7 parser: svelteParser, 8 parserOptions: { 9 svelteFeatures: { 10 // This is for Svelte 5. The default is true. 11 // If false, ESLint won't recognize rune symbols. 12 // If not specified, the parser tries to read compilerOptions.runes from `svelte.config.js`. 13 // If `parserOptions.svelteConfig` is not given and static analysis fails, it defaults to true. 14 runes: true, 15 }, 16 }, 17 }, 18 }, 19];
Use the 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:
1{ 2 "eslint.validate": ["javascript", "javascriptreact", "svelte"] 3}
eslint-plugin-svelte
], and their source code can be a helpful reference.Contributions are welcome! Please open an issue or submit a PR on GitHub.
For internal details, see internal-mechanism.md.
See LICENSE (MIT) for rights and limitations.
No vulnerabilities found.
No security vulnerabilities found.