{"name":"svelte-eslint-parser","version":"0.18.2","keywords":["svelte","sveltejs","eslint","parser"],"author":{"url":"https://github.com/ota-meshi","name":"Yosuke Ota"},"license":"MIT","_id":"svelte-eslint-parser@0.18.2","maintainers":[{"name":"ota-meshi","email":"otameshiyo23@gmail.com"}],"contributors":[{"url":"https://github.com/JounQin","name":"JounQin"}],"homepage":"https://github.com/ota-meshi/svelte-eslint-parser#readme","bugs":{"url":"https://github.com/ota-meshi/svelte-eslint-parser/issues"},"dist":{"shasum":"7913c017b2019f496018a666c1c1e2f29e1c330d","tarball":"http://registry-npm.ywwl.com/svelte-eslint-parser/download/svelte-eslint-parser-0.18.2.tgz","fileCount":59,"integrity":"sha512-8zLD1u176i001zCQ3lBaK1G8s8/2LTiUZBPEzKjDsf0pXlHKThWrfahLh6EF7lQ3MxcV4IJRESC1qjkHRMe+KQ==","signatures":[{"sig":"MEYCIQCqG0fMdjfXhTrYaKGh+0pvIM8kEjICbKrt6OPr3LmiFgIhAPVarHSPptD2rAZOLHmNVWgZhoJ77WX79Bia9vOgKRm+","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":185248,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjFnUxACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmox8w/9EXOjMIOcX440mGbfSBDH1p3sqhzjeTrdUiQ6MQUidqRE5eS0\r\niau0GCEZOwfairggghVL4StfU056Bbowve1Qvfnr3WeJ3QOF3ihyn7TkMNua\r\n8gi3F6s1oWeyAz2gvkbi1n9JdjOl4K/r/pNxdhTwcxwVwyNqVgn62ov4zwYV\r\nP9ROgfhYqZxIq9lZibvjgYYgOZ8oYYerZTSDeRDMSv9zxNAuApVKrtOZ8PUg\r\nxswGiQEFGVuwkYKiMoAarvmwUgJbVr0/ldDJZ7RCdWiUR25yaZSlgLNXsZNq\r\nteannpuuN/chhVebzS6cWMuBbWMpzz7NHAzkOgQlYeQrSYjylf9HGerbpPNE\r\ntzu6rQZE5Qdx72/VW6BA17AFqTVZ1XFW2+gJ1GU0OF2I54tukr7nOSnuJGC6\r\nVZRqAtZac+Uc1XSrkR55S3uK/4fmpL9a5XEBABzcLdF4Ki/yp8tBMw0/JWH+\r\na9I0H95YujSmyJ0t2f4QmaCwbP8+bfxO9QXpXX5yAOHP7xIlNr6pwlSBBN8i\r\nvv4FYlrK2IVFeej6RzOAvCiEOiMzLZMCMSuaGu1wMW/NlzOyut4RctHcxpOU\r\n5ib3+nfljmcnrgfUVJugobI481F2Ogx5xzwT2/7VyxOhTzWIeOZRHgy5E6Qx\r\nQKvB2VEjkTecCdKdynsLZqA7Zs/dyWBBlbY=\r\n=FHjp\r\n-----END PGP SIGNATURE-----\r\n","size":37791,"noattachment":false,"key":"/svelte-eslint-parser/-/svelte-eslint-parser-0.18.2.tgz"},"main":"lib/index.js","types":"./lib/index.d.ts","engines":{"node":"^12.22.0 || ^14.17.0 || >=16.0.0"},"funding":"https://github.com/sponsors/ota-meshi","gitHead":"534e8855ebe6a36748cf5600cead60bf9d6b1c7f","scripts":{"ts":"node -r esbuild-register","lint":"eslint . --ext .js,.ts,.json,.yaml,.yml,.svelte","test":"yarn mocha \"tests/src/**/*.ts\" --reporter dot --timeout 60000","build":"tsc --project ./tsconfig.build.json","clean":"rimraf .nyc_output lib coverage","cover":"nyc --reporter=lcov yarn test","debug":"yarn mocha \"tests/src/**/*.ts\" --reporter dot --timeout 60000","mocha":"yarn ts ./node_modules/mocha/bin/mocha.js","release":"changeset publish","prebuild":"yarn clean","benchmark":"yarn ts benchmark/index.ts","eslint-fix":"yarn lint --fix","prerelease":"yarn clean && yarn build","preversion":"yarn lint && yarn test","update-fixtures":"yarn ts ./tools/update-fixtures.ts","eslint-playground":"eslint tests/fixtures --ext .svelte --config .eslintrc-for-playground.js --format codeframe"},"_npmUser":{"name":"ota-meshi","email":"otameshiyo23@gmail.com"},"repository":{"url":"git+https://github.com/ota-meshi/svelte-eslint-parser.git","type":"git"},"_npmVersion":"8.15.0","description":"Svelte parser for ESLint","directories":{},"_nodeVersion":"16.17.0","dependencies":{"espree":"^9.0.0","eslint-scope":"^7.0.0","eslint-visitor-keys":"^3.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"packageManager":"yarn@1.22.19","devDependencies":{"nyc":"^15.1.0","chai":"^4.3.4","mocha":"^10.0.0","eslint":"^8.2.0","semver":"^7.3.5","svelte":"^3.46.1","esbuild":"^0.15.0","code-red":"^0.2.3","prettier":"^2.0.5","benchmark":"^2.1.4","typescript":"~4.8.0","@types/chai":"^4.3.0","@types/node":"^16.0.0","@types/mocha":"^9.0.0","magic-string":"^0.26.0","@types/eslint":"^8.0.0","@types/semver":"^7.3.9","estree-walker":"^3.0.0","@changesets/cli":"^2.24.2","@types/benchmark":"^2.1.1","esbuild-register":"^3.3.3","locate-character":"^2.0.5","eslint-plugin-vue":"^9.0.0","eslint-plugin-yml":"^1.0.0","vue-eslint-parser":"^9.0.0","eslint-plugin-node":"^11.1.0","@types/eslint-scope":"^3.7.0","eslint-plugin-jsonc":"^2.0.0","prettier-plugin-pkg":"^0.17.0","eslint-plugin-regexp":"^1.5.0","eslint-plugin-svelte":"^2.0.0","eslint-plugin-svelte3":"^4.0.0","string-replace-loader":"^3.0.3","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^4.0.0","prettier-plugin-svelte":"^2.5.0","@ota-meshi/eslint-plugin":"^0.12.0","mocha-chai-jest-snapshot":"^1.1.3","@typescript-eslint/parser":"^5.4.0","@types/eslint-visitor-keys":"^1.0.0","@changesets/changelog-github":"^0.4.6","eslint-plugin-eslint-comments":"^3.2.0","eslint-plugin-node-dependencies":"^0.9.0","@typescript-eslint/eslint-plugin":"^5.4.0","eslint-plugin-json-schema-validator":"^4.0.0"},"peerDependencies":{"svelte":"^3.37.0"},"_npmOperationalInternal":{"tmp":"tmp/svelte-eslint-parser_0.18.2_1662416177530_0.3341440559742195","host":"s3://npm-registry-packages"},"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&colorB=green&suffix=/day&query=$.downloads&uri=https://api.npmjs.org//downloads/point/last-day/svelte-eslint-parser&maxAge=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<div align=\"center\">\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</div>\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: 2024,\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 `<script>` 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 `<script>`\n\nIf you use `@typescript-eslint/parser` for TypeScript within `<script>` 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 `<script>` in `.svelte` as TypeScript by adding the following configuration.\n      parserOptions: {\n        parser: tsParser,\n      },\n    },\n  },\n];\n```\n\n#### Using JSDoc types in JavaScript\n\nThe configuration above also supports JSDoc type annotations in JavaScript\n`<script>` blocks (with no `lang`, `lang=\"js\"`, or `lang=\"javascript\"`) and\n`.svelte.js` files. Configure `parserOptions.project` or\n`parserOptions.projectService` to enable type-aware lint rules.\n\n```svelte\n<script>\n  /** @param {number} value */\n  function increment(value) {\n    return value + 1;\n  }\n</script>\n\n{increment(1)}\n```\n\nWhen using multiple parsers, assign `@typescript-eslint/parser` to the `js`\nentry as well as `ts` to enable JSDoc type information in ordinary `<script>`\nblocks. JavaScript configured to use Espree continues to use Espree.\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## Experimental\n\n### `ts.sys.readFile` hook for type-aware Svelte lint\n\n> ⚠️ **Experimental.** Opt-in only; behavior may change or be removed.\n\nSpeeds up type-aware lint of `.svelte` files. Your ESLint config must\nalready list `.svelte` via `parserOptions.extraFileExtensions`.\n\n```sh\nSVELTE_ESLINT_PARSER_EXPERIMENTAL_TS_SYS_HOOK=1 \\\n  eslint --no-cache --concurrency auto .\n```\n\nWhen enabled, the hook also resolves `.svelte` import specifiers to the\nimported component's virtual module, so type-aware rules see a component's\nreal prop, event, and slot types across files. `import Foo from \"./Foo.svelte\"`\nis resolved through a virtual `Foo.svelte.ts` companion that the hook serves\nfrom the same translation — no `tsconfig` changes are required. If a real\n`Foo.svelte.ts` (a Svelte runes module) exists on disk, it always takes\nprecedence and the hook leaves it untouched. In that case component prop types\nare not available for that component, because plain TypeScript resolution picks\nthe module instead of the component. To avoid this name collision, enable the\n`svelte/no-conflicting-module-names` rule from `eslint-plugin-svelte` (v3.22.0\nor later), which reports a `Foo.svelte` and `Foo.svelte.ts` pair.\n\nComponent typing currently requires a TypeScript `<script>` and supports\nSvelte 3, 4, and 5. Props come from `$props()` annotations or destructuring\nin runes mode, and from `$$Props` or exported `let` bindings in legacy mode.\nDefaulted props are optional. Explicit `$$Events` and `$$Slots` declarations\nsupply event and slot types; otherwise those types remain permissive.\n\nThis is not a full replacement for Svelte's generated component declarations.\nUnannotated props without defaults use `any`, rest props keep the prop type\nopen, and generic parameters are represented by their constraints rather than\npreserving a generic component signature. Instance exports and slot types\ninferred from template markup are not synthesized. JavaScript-only components\ndo not receive this TypeScript translation.\n\nCaveat: rules that read raw TypeScript diagnostics\n(`program.getSemanticDiagnostics()` and friends) report positions inside\nthe parser's virtual shim — a pre-existing property of type-aware Svelte\nlint, not specific to the hook.\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","publish_time":1662416177712,"_cnpm_publish_time":1662416177712,"dist-tags":{"latest":"1.10.1","next":"1.0.0-next.13"}}