Registry / testing / eslint-plugin-svelte

eslint-plugin-svelte

JSON →
library3.17.1jsnpmunverified

Official ESLint plugin for Svelte that leverages AST from svelte-eslint-parser. Current stable version is 3.17.1, with active release cadence (multiple minor/patch releases per month). Provides 80+ rules covering accessibility, best practices, style, and Svelte-specific patterns. Supports Svelte 3, 4, and 5. Requires ESLint v8.57.1+, v9+ or v10+. Ships TypeScript definitions. Recommended over deprecated eslint-plugin-svelte3. Integrates with flat config (eslint.config.js) and provides recommended configs.

npm install eslint-plugin-svelte
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-SVEL
E
eslint-plugin-svelte
testingjavascriptv3.17.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import svelte from 'eslint-plugin-svelte'
const svelte = require('eslint-plugin-svelte')
ESM-only since v3; CommonJS require will fail. Use default import to get the plugin object for flat config.
defineConfig
import { defineConfig } from 'eslint/config'
defineConfig is from eslint package, not from eslint-plugin-svelte. Common mistake is to import it from eslint-plugin-svelte.
configs
import svelte from 'eslint-plugin-svelte'; export default [... svelte.configs.recommended, ...]
import { configs } from 'eslint-plugin-svelte'
configs is a property of the default export, not a named export. Use svelte.configs.recommended.

Flat config using TypeScript-ESLint parser for Svelte files and recommending both TypeScript and Svelte rules.

// eslint.config.js import svelte from 'eslint-plugin-svelte'; import globals from 'globals'; import ts from 'typescript-eslint'; export default [ { ignores: ['build/', 'dist/', 'node_modules/'] }, ...ts.configs.recommended, ...svelte.configs.recommended, { languageOptions: { globals: { ...globals.browser, ...globals.node } } }, { files: ['**/*.svelte', '**/*.svelte.ts'], languageOptions: { parserOptions: { parser: ts.parser } } } ];
Debug
Known issues
breakingeslint-plugin-svelte >= 2.0.0 no longer supports CommonJS require(). Use ESM imports only.
fix
Use `import svelte from 'eslint-plugin-svelte'` in eslint.config.js.
affects: >=2.0.0
deprecatedeslint-plugin-svelte3 is deprecated. Use eslint-plugin-svelte instead.
fix
Uninstall eslint-plugin-svelte3 and install eslint-plugin-svelte. See migration guide.
affects: all
gotchaFlat config (eslint.config.js) is required for v3+. The plugin no longer supports .eslintrc files.
fix
Migrate to eslint.config.js with `import svelte from 'eslint-plugin-svelte'`.
affects: >=3.0.0
gotchasvelte.config.js must be imported in eslint.config.js if using runes or Svelte 5 features; otherwise parser may fail.
fix
Add `import svelteConfig from './svelte.config.js'` and set `parserOptions.svelteConfig`.
affects: >=3.0.0
gotchaWhen using TypeScript, you must set `parserOptions.parser` to the TypeScript parser (e.g., `typescript-eslint/parser`).
fix
In eslint.config.js for `.svelte` files, add `languageOptions: { parserOptions: { parser: ts.parser } }`.
affects: all
Errors
Common errors & fixes
Error: Cannot find module 'eslint-plugin-svelte'
Plugin is not installed or is in devDependencies but ESLint is running globally or in different context.
fix
Run `npm install --save-dev eslint-plugin-svelte` or ensure ESLint is run from the project root with correct node_modules.
Configuration for rule 'svelte/valid-compile' is invalid: Value "error" is not allowed.
The rule 'valid-compile' does not exist; it was renamed or removed in v3.
fix
Use 'svelte/valid-prop' or check rule list. Remove 'svelte/valid-compile' from config.
ESLint couldn't determine the plugin 'svelte' uniquely. This may be caused by an incorrectly installed plugin.
Multiple versions or conflicting installations of eslint-plugin-svelte (e.g., both CJS and ESM).
fix
Ensure only one version is installed: `npm dedupe` or `npx eslint --ext .svelte --resolve-plugins-relative-to .`
Parsing error: Unexpected token '{'
The parser (svelte-eslint-parser) is not configured correctly; often missing parserOptions.svelteConfig for Svelte 5 runes.
fix
Set parserOptions.svelteConfig in eslint.config.js: `parserOptions: { svelteConfig: './svelte.config.js' }`.
Error: Unexpected top-level token in Svelte component
Using a Svelte 5 rune ($state, $derived) without proper parser support or svelte.config.js import.
fix
Update svelte-eslint-parser and eslint-plugin-svelte to latest, and import svelte.config.js in eslint.config.js.
Upgrade
Version history
3.17.1latest on npm
Audit
Dependencies
eslintrequiredpeer dependency: requires ESLint v8.57.1+, v9+ or v10+
svelterequiredpeer dependency: requires Svelte 3.37+, 4.x, or 5.x
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-svelte — npm install eslint-plugin-svelte · libregistry