{"id":14962380,"url":"https://github.com/sveltejs/svelte-eslint-parser","last_synced_at":"2025-05-15T16:07:42.046Z","repository":{"id":38419213,"uuid":"360739293","full_name":"sveltejs/svelte-eslint-parser","owner":"sveltejs","description":"Svelte parser for ESLint","archived":false,"fork":false,"pushed_at":"2025-05-13T20:24:47.000Z","size":11705,"stargazers_count":102,"open_issues_count":9,"forks_count":23,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-13T21:40:03.495Z","etag":null,"topics":["eslint","eslint-custom-parser","eslint-parser","parser","svelte","sveltejs"],"latest_commit_sha":null,"homepage":"https://sveltejs.github.io/svelte-eslint-parser/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sveltejs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"open_collective":"svelte","github":["ota-meshi","JounQin"],"patreon":"1stG","custom":["https://opencollective.com/rxts"]}},"created_at":"2021-04-23T02:23:45.000Z","updated_at":"2025-05-06T23:54:19.000Z","dependencies_parsed_at":"2024-01-29T20:48:22.792Z","dependency_job_id":"b914739e-f2c5-4f86-b5ec-8f661fc84824","html_url":"https://github.com/sveltejs/svelte-eslint-parser","commit_stats":{"total_commits":670,"total_committers":9,"mean_commits":74.44444444444444,"dds":0.5119402985074627,"last_synced_commit":"1908a376842143cf633fe838d5b833d1ef2e9d7e"},"previous_names":[],"tags_count":133,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sveltejs%2Fsvelte-eslint-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sveltejs%2Fsvelte-eslint-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sveltejs%2Fsvelte-eslint-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sveltejs%2Fsvelte-eslint-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sveltejs","download_url":"https://codeload.github.com/sveltejs/svelte-eslint-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254039892,"owners_count":22004382,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eslint","eslint-custom-parser","eslint-parser","parser","svelte","sveltejs"],"created_at":"2024-09-24T13:29:52.217Z","updated_at":"2025-05-15T16:07:41.996Z","avatar_url":"https://github.com/sveltejs.png","language":"TypeScript","funding_links":["https://opencollective.com/svelte","https://github.com/sponsors/ota-meshi","https://github.com/sponsors/JounQin","https://patreon.com/1stG","https://opencollective.com/rxts"],"categories":[],"sub_categories":[],"readme":"[![NPM license](https://img.shields.io/npm/l/svelte-eslint-parser.svg)](https://www.npmjs.com/package/svelte-eslint-parser)\n[![NPM version](https://img.shields.io/npm/v/svelte-eslint-parser.svg)](https://www.npmjs.com/package/svelte-eslint-parser)\n[![NPM downloads](https://img.shields.io/badge/dynamic/json.svg?label=downloads\u0026colorB=green\u0026suffix=/day\u0026query=$.downloads\u0026uri=https://api.npmjs.org//downloads/point/last-day/svelte-eslint-parser\u0026maxAge=3600)](http://www.npmtrends.com/svelte-eslint-parser)\n[![NPM downloads](https://img.shields.io/npm/dw/svelte-eslint-parser.svg)](http://www.npmtrends.com/svelte-eslint-parser)\n[![NPM downloads](https://img.shields.io/npm/dm/svelte-eslint-parser.svg)](http://www.npmtrends.com/svelte-eslint-parser)\n[![NPM downloads](https://img.shields.io/npm/dy/svelte-eslint-parser.svg)](http://www.npmtrends.com/svelte-eslint-parser)\n[![NPM downloads](https://img.shields.io/npm/dt/svelte-eslint-parser.svg)](http://www.npmtrends.com/svelte-eslint-parser)\n[![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)\n[![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)\n\n\u003cdiv align=\"center\"\u003e\n\n# svelte-eslint-parser\n\n## [Svelte](https://svelte.dev/) parser for [ESLint](https://eslint.org/).\n\n[Live DEMO](https://sveltejs.github.io/svelte-eslint-parser/playground) •\n[Discord](https://svelte.dev/chat)\n\n\u003c/div\u003e\n\n## Motivation\n\nThe `svelte-eslint-parser` aims to make it easy to create your own ESLint rules for [Svelte](https://svelte.dev/).\n\n[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/).\n\n### ESLint Plugins Using svelte-eslint-parser\n\n#### [eslint-plugin-svelte](https://sveltejs.github.io/eslint-plugin-svelte/)\n\nESLint plugin for Svelte.  \nProvides a variety of template-based checks using the Svelte AST.\n\n#### [@intlify/eslint-plugin-svelte](https://github.com/intlify/eslint-plugin-svelte)\n\nESLint plugin for internationalization (i18n) in Svelte applications, offering helpful i18n-related rules.\n\n---\n\n## Installation\n\n```bash\nnpm install --save-dev eslint svelte-eslint-parser\n```\n\n---\n\n## Usage\n\n### ESLint Config (`eslint.config.js`)\n\n```js\nimport js from \"@eslint/js\";\nimport svelteParser from \"svelte-eslint-parser\";\n\nexport default [\n  js.configs.recommended,\n  {\n    files: [\n      \"**/*.svelte\",\n      \"*.svelte\",\n      // Need to specify the file extension for Svelte 5 with rune symbols\n      \"**/*.svelte.js\",\n      \"*.svelte.js\",\n      \"**/*.svelte.ts\",\n      \"*.svelte.ts\",\n    ],\n    languageOptions: {\n      parser: svelteParser,\n    },\n  },\n];\n```\n\n### CLI\n\n```bash\neslint \"src/**/*.{js,svelte}\"\n```\n\n---\n\n## Options\n\nThe [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.\n\nFor example:\n\n```js\nimport svelteParser from \"svelte-eslint-parser\";\n\nexport default [\n  // ...\n  {\n    files: [\n      // Set .svelte/.js/.ts files. See above for more details.\n    ],\n    languageOptions: {\n      parser: svelteParser,\n      parserOptions: {\n        sourceType: \"module\",\n        ecmaVersion: 2021,\n        ecmaFeatures: {\n          globalReturn: false,\n          impliedStrict: false,\n          jsx: false,\n        },\n      },\n    },\n  },\n];\n```\n\n### parserOptions.parser\n\nUse the `parserOptions.parser` property to define a custom parser for `\u003cscript\u003e` tags. Any additional parser options (besides the parser itself) are passed along to the specified parser.\n\n```js\nimport tsParser from \"@typescript-eslint/parser\";\n\nexport default [\n  {\n    files: [\n      // Set .svelte/.js/.ts files. See above for more details.\n    ],\n    languageOptions: {\n      parser: svelteParser,\n      parserOptions: {\n        parser: tsParser,\n      },\n    },\n  },\n];\n```\n\n#### Using TypeScript in `\u003cscript\u003e`\n\nIf you use `@typescript-eslint/parser` for TypeScript within `\u003cscript\u003e` of `.svelte` files, additional configuration is needed. For example:\n\n```js\nimport tsParser from \"@typescript-eslint/parser\";\n\nexport default [\n  // Other config for non-Svelte files\n  {\n    languageOptions: {\n      parser: tsParser,\n      parserOptions: {\n        project: \"path/to/your/tsconfig.json\",\n        extraFileExtensions: [\".svelte\"],\n      },\n    },\n  },\n  // Svelte config\n  {\n    files: [\n      // Set .svelte/.js/.ts files. See above for more details.\n    ],\n    languageOptions: {\n      parser: svelteParser,\n      // Parse the `\u003cscript\u003e` in `.svelte` as TypeScript by adding the following configuration.\n      parserOptions: {\n        parser: tsParser,\n      },\n    },\n  },\n];\n```\n\n#### Multiple parsers\n\nTo switch parsers for each language, provide an object:\n\n```js\nimport tsParser from \"@typescript-eslint/parser\";\nimport espree from \"espree\";\n\nexport default [\n  {\n    files: [\n      // Set .svelte/.js/.ts files. See above for more details.\n    ],\n    languageOptions: {\n      parser: svelteParser,\n      parserOptions: {\n        parser: {\n          ts: tsParser,\n          js: espree,\n          typescript: tsParser,\n        },\n      },\n    },\n  },\n];\n```\n\n### parserOptions.svelteConfig\n\nIf you use `eslint.config.js`, you can specify a `svelte.config.js` file via `parserOptions.svelteConfig`.\n\n```js\nimport svelteConfig from \"./svelte.config.js\";\n\nexport default [\n  {\n    files: [\n      // Set .svelte/.js/.ts files. See above for more details.\n    ],\n    languageOptions: {\n      parser: svelteParser,\n      parserOptions: {\n        svelteConfig,\n      },\n    },\n  },\n];\n```\n\nIf `parserOptions.svelteConfig` is not set, the parser attempts to statically read some config from `svelte.config.js`.\n\n### parserOptions.svelteFeatures\n\nYou can configure how Svelte-specific features are parsed via `parserOptions.svelteFeatures`.\n\nFor example:\n\n```js\nexport default [\n  {\n    files: [\n      // Set .svelte/.js/.ts files. See above for more details.\n    ],\n    languageOptions: {\n      parser: svelteParser,\n      parserOptions: {\n        svelteFeatures: {\n          // This is for Svelte 5. The default is true.\n          // If false, ESLint won't recognize rune symbols.\n          // If not specified, the parser tries to read compilerOptions.runes from `svelte.config.js`.\n          // If `parserOptions.svelteConfig` is not given and static analysis fails, it defaults to true.\n          runes: true,\n        },\n      },\n    },\n  },\n];\n```\n\n---\n\n## Editor Integrations\n\n### Visual Studio Code\n\nUse the [dbaeumer.vscode-eslint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) extension provided by Microsoft.\n\nBy default, it only targets `*.js` and `*.jsx`, so you need to configure `.svelte` file support. For example, in **.vscode/settings.json**:\n\n```json\n{\n  \"eslint.validate\": [\"javascript\", \"javascriptreact\", \"svelte\"]\n}\n```\n\n---\n\n## Usage for Custom Rules / Plugins\n\n- 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/).\n- 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).\n- Several rules are [already implemented] in [`eslint-plugin-svelte`], and their source code can be a helpful reference.\n\n---\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a PR on GitHub.  \nFor internal details, see [internal-mechanism.md](./docs/internal-mechanism.md).\n\n---\n\n## License\n\nSee [LICENSE](LICENSE) (MIT) for rights and limitations.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsveltejs%2Fsvelte-eslint-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsveltejs%2Fsvelte-eslint-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsveltejs%2Fsvelte-eslint-parser/lists"}