
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
svelte-eslint-parser
Advanced tools
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.
npm install --save-dev eslint svelte-eslint-parser
eslint.config.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,
},
},
];
eslint "src/**/*.{js,svelte}"
The parserOptions for this parser generally match what espree—ESLint's default parser—supports.
For example:
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,
},
},
},
},
];
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.
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,
},
},
},
];
<script>If you use @typescript-eslint/parser for TypeScript within <script> of .svelte files, additional configuration is needed. For example:
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,
},
},
},
];
To switch parsers for each language, provide an object:
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,
},
},
},
},
];
If you use eslint.config.js, you can specify a svelte.config.js file via parserOptions.svelteConfig.
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.
You can configure how Svelte-specific features are parsed via parserOptions.svelteFeatures.
For example:
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,
},
},
},
},
];
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:
{
"eslint.validate": ["javascript", "javascriptreact", "svelte"]
}
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.
FAQs
Svelte parser for ESLint
The npm package svelte-eslint-parser receives a total of 501,120 weekly downloads. As such, svelte-eslint-parser popularity was classified as popular.
We found that svelte-eslint-parser demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.