{"id":19953,"library":"eslint-plugin-svelte","title":"eslint-plugin-svelte","description":"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.","status":"active","version":"3.17.1","language":"javascript","source_language":"en","source_url":"https://github.com/sveltejs/eslint-plugin-svelte","tags":["javascript","eslint","eslint-plugin","eslintplugin","svelte","sveltejs","typescript"],"install":[{"cmd":"npm install eslint-plugin-svelte","lang":"bash","label":"npm"},{"cmd":"yarn add eslint-plugin-svelte","lang":"bash","label":"yarn"},{"cmd":"pnpm add eslint-plugin-svelte","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency: requires ESLint v8.57.1+, v9+ or v10+","package":"eslint","optional":false},{"reason":"peer dependency: requires Svelte 3.37+, 4.x, or 5.x","package":"svelte","optional":false}],"imports":[{"note":"ESM-only since v3; CommonJS require will fail. Use default import to get the plugin object for flat config.","wrong":"const svelte = require('eslint-plugin-svelte')","symbol":"default","correct":"import svelte from 'eslint-plugin-svelte'"},{"note":"defineConfig is from eslint package, not from eslint-plugin-svelte. Common mistake is to import it from eslint-plugin-svelte.","wrong":"","symbol":"defineConfig","correct":"import { defineConfig } from 'eslint/config'"},{"note":"configs is a property of the default export, not a named export. Use svelte.configs.recommended.","wrong":"import { configs } from 'eslint-plugin-svelte'","symbol":"configs","correct":"import svelte from 'eslint-plugin-svelte'; export default [... svelte.configs.recommended, ...]"}],"quickstart":{"code":"// eslint.config.js\nimport svelte from 'eslint-plugin-svelte';\nimport globals from 'globals';\nimport ts from 'typescript-eslint';\n\nexport default [\n  {\n    ignores: ['build/', 'dist/', 'node_modules/']\n  },\n  ...ts.configs.recommended,\n  ...svelte.configs.recommended,\n  {\n    languageOptions: {\n      globals: {\n        ...globals.browser,\n        ...globals.node\n      }\n    }\n  },\n  {\n    files: ['**/*.svelte', '**/*.svelte.ts'],\n    languageOptions: {\n      parserOptions: {\n        parser: ts.parser\n      }\n    }\n  }\n];","lang":"typescript","description":"Flat config using TypeScript-ESLint parser for Svelte files and recommending both TypeScript and Svelte rules."},"warnings":[{"fix":"Use `import svelte from 'eslint-plugin-svelte'` in eslint.config.js.","message":"eslint-plugin-svelte >= 2.0.0 no longer supports CommonJS require(). Use ESM imports only.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Uninstall eslint-plugin-svelte3 and install eslint-plugin-svelte. See migration guide.","message":"eslint-plugin-svelte3 is deprecated. Use eslint-plugin-svelte instead.","severity":"deprecated","affected_versions":"all"},{"fix":"Migrate to eslint.config.js with `import svelte from 'eslint-plugin-svelte'`.","message":"Flat config (eslint.config.js) is required for v3+. The plugin no longer supports .eslintrc files.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"Add `import svelteConfig from './svelte.config.js'` and set `parserOptions.svelteConfig`.","message":"svelte.config.js must be imported in eslint.config.js if using runes or Svelte 5 features; otherwise parser may fail.","severity":"gotcha","affected_versions":">=3.0.0"},{"fix":"In eslint.config.js for `.svelte` files, add `languageOptions: { parserOptions: { parser: ts.parser } }`.","message":"When using TypeScript, you must set `parserOptions.parser` to the TypeScript parser (e.g., `typescript-eslint/parser`).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run `npm install --save-dev eslint-plugin-svelte` or ensure ESLint is run from the project root with correct node_modules.","cause":"Plugin is not installed or is in devDependencies but ESLint is running globally or in different context.","error":"Error: Cannot find module 'eslint-plugin-svelte'"},{"fix":"Use 'svelte/valid-prop' or check rule list. Remove 'svelte/valid-compile' from config.","cause":"The rule 'valid-compile' does not exist; it was renamed or removed in v3.","error":"Configuration for rule 'svelte/valid-compile' is invalid: Value \"error\" is not allowed."},{"fix":"Ensure only one version is installed: `npm dedupe` or `npx eslint --ext .svelte --resolve-plugins-relative-to .`","cause":"Multiple versions or conflicting installations of eslint-plugin-svelte (e.g., both CJS and ESM).","error":"ESLint couldn't determine the plugin 'svelte' uniquely. This may be caused by an incorrectly installed plugin."},{"fix":"Set parserOptions.svelteConfig in eslint.config.js: `parserOptions: { svelteConfig: './svelte.config.js' }`.","cause":"The parser (svelte-eslint-parser) is not configured correctly; often missing parserOptions.svelteConfig for Svelte 5 runes.","error":"Parsing error: Unexpected token '{'"},{"fix":"Update svelte-eslint-parser and eslint-plugin-svelte to latest, and import svelte.config.js in eslint.config.js.","cause":"Using a Svelte 5 rune ($state, $derived) without proper parser support or svelte.config.js import.","error":"Error: Unexpected top-level token in Svelte component"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}