{"name":"vue-eslint-parser","version":"10.3.0","keywords":[],"author":{"name":"Toru Nagashima"},"license":"MIT","_id":"vue-eslint-parser@10.3.0","maintainers":[{"name":"mysticatea","email":"public@mysticatea.dev"},{"name":"ota-meshi","email":"otameshiyo23@gmail.com"}],"homepage":"https://github.com/vuejs/vue-eslint-parser#readme","bugs":{"url":"https://github.com/vuejs/vue-eslint-parser/issues"},"dist":{"shasum":"581eef6b67504b4e1efb9208febc9cda52cadd6b","tarball":"http://registry-npm.ywwl.com/vue-eslint-parser/download/vue-eslint-parser-10.3.0.tgz","fileCount":6,"integrity":"sha512-Aj1cCjD3HQjp5B8cLr6zJjISEOkr0MCrqvwLg3MeyGDjKlL8uMFLKfVbP7Te09cG9Y9KmzJwwnD7hf884CpcOg==","signatures":[{"sig":"MEUCIQDbcQoM06hnDwFY7Nx+v1D8JsBEhlnHCocRC+nCANqN9wIgGW5WtLkXmURypJ8LirSK3sSTtHphUQZRG1Xn92vs8bI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1048090,"size":206288,"noattachment":false,"key":"/vue-eslint-parser/-/vue-eslint-parser-10.3.0.tgz"},"main":"./dist/index.cjs","types":"./dist/index.d.cts","engines":{"node":"^18.18.0 || ^20.9.0 || >=21.1.0"},"exports":{".":"./dist/index.cjs","./package.json":"./package.json"},"funding":"https://github.com/sponsors/mysticatea","gitHead":"fb0c8c6332a5ee9f8e793d67a90ad4c95f3817f1","scripts":{"dev":"tsdown --watch","lint":"eslint src test package.json","test":"vitest","build":"tsdown","version":"npm run -s build","coverage":"vitest --coverage --ui","preversion":"npm test -- run","test:cover":"vitest --coverage","postversion":"git push && git push --tags"},"_npmUser":{"name":"ota-meshi","email":"otameshiyo23@gmail.com"},"repository":{"url":"git+https://github.com/vuejs/vue-eslint-parser.git","type":"git"},"_npmVersion":"11.6.2","description":"The ESLint custom parser for `.vue` files.","directories":{},"_nodeVersion":"24.13.0","dependencies":{"debug":"^4.4.0","espree":"^10.3.0 || ^11.0.0","semver":"^7.6.3","esquery":"^1.6.0","eslint-scope":"^8.2.0 || ^9.0.0","eslint-visitor-keys":"^4.2.0 || ^5.0.0"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^6.3.5","eslint":"^10.0.0","tsdown":"^0.20.3","vitest":"^3.2.4","ts-node":"^10.9.2","prettier":"^3.4.2","@eslint/js":"^9.19.0","@vitest/ui":"^3.2.4","typescript":"~5.7.3","@babel/core":"^7.26.7","@types/node":"^18.8.4","@types/debug":"^4.1.7","@types/estree":"^1.0.0","@types/semver":"^7.3.12","eslint-plugin-n":"^17.15.1","@eslint/eslintrc":"^3.2.0","@vitest/coverage-v8":"^3.2.4","eslint-plugin-jsonc":"^2.19.1","jsonc-eslint-parser":"^2.0.3","@babel/eslint-parser":"^7.28.6","eslint-plugin-unicorn":"^57.0.0","eslint-plugin-prettier":"^5.2.3","@typescript-eslint/parser":"^8.55.0","@babel/plugin-syntax-decorators":"^7.25.9","@babel/plugin-syntax-typescript":"^7.25.9","eslint-plugin-node-dependencies":"^1.3.0","@typescript-eslint/eslint-plugin":"^8.55.0","@babel/plugin-syntax-pipeline-operator":"^7.26.7","@eslint-community/eslint-plugin-eslint-comments":"^4.6.0"},"peerDependencies":{"eslint":"^8.57.0 || ^9.0.0 || ^10.0.0"},"_npmOperationalInternal":{"tmp":"tmp/vue-eslint-parser_10.3.0_1770978303360_0.6511376645884788","host":"s3://npm-registry-packages-npm-production"},"readme":"# vue-eslint-parser\n\n[![npm version](https://img.shields.io/npm/v/vue-eslint-parser.svg)](https://www.npmjs.com/package/vue-eslint-parser)\n[![Downloads/month](https://img.shields.io/npm/dm/vue-eslint-parser.svg)](http://www.npmtrends.com/vue-eslint-parser)\n[![Build Status](https://github.com/vuejs/vue-eslint-parser/workflows/CI/badge.svg)](https://github.com/vuejs/vue-eslint-parser/actions)\n\nThe ESLint custom parser for `.vue` files.\n\n## ⤴️ Motivation\n\nThis parser allows us to lint the `<template>` of `.vue` files. We can make mistakes easily on `<template>` if we use complex directives and expressions in the template. This parser and the rules of [eslint-plugin-vue](https://github.com/vuejs/eslint-plugin-vue) would catch some of the mistakes.\n\n## 💿 Installation\n\n```bash\nnpm install --save-dev eslint vue-eslint-parser\n```\n\n## 📖 Usage\n\nWrite `parser` option into your `eslint.config.*` file.\n\n```js\nimport vueParser from \"vue-eslint-parser\"\nexport default [\n    js.configs.recommended,\n    {\n        files: [\"*.vue\", \"**/*.vue\"],\n        languageOptions: {\n            parser: vueParser,\n        },\n    }\n]\n```\n\n## 🔧 Options\n\n`parserOptions` has the same properties as what [espree](https://github.com/eslint/espree#usage), the default parser of ESLint, is supporting.\nFor example:\n\n```js\nimport vueParser from \"vue-eslint-parser\"\nexport default [\n    {\n        files: [\"*.vue\", \"**/*.vue\"],\n        languageOptions: {\n            parser: vueParser,\n            sourceType: \"module\",\n            ecmaVersion: \"latest\",\n            parserOptions: {\n                ecmaFeatures: {\n                    globalReturn: false,\n                    impliedStrict: false,\n                    jsx: false\n                }\n            }\n        },\n    }\n]\n```\n\n### parserOptions.parser\n\nYou can use `parserOptions.parser` property to specify a custom parser to parse `<script>` tags.\nOther properties than parser would be given to the specified parser.\nFor example:\n\n```js\nimport vueParser from \"vue-eslint-parser\"\nimport babelParser from \"@babel/eslint-parser\"\nexport default [\n    {\n        files: [\"*.vue\", \"**/*.vue\"],\n        languageOptions: {\n            parser: vueParser,\n            parserOptions: {\n                parser: babelParser,\n            }\n        },\n    }\n]\n```\n\n```js\nimport vueParser from \"vue-eslint-parser\"\nimport tsParser from \"@typescript-eslint/parser\"\nexport default [\n    {\n        files: [\"*.vue\", \"**/*.vue\"],\n        languageOptions: {\n            parser: vueParser,\n            parserOptions: {\n                parser: tsParser,\n            }\n        },\n    }\n]\n```\n\nYou can also specify an object and change the parser separately for `<script lang=\"...\">`.\n\n```js\nimport vueParser from \"vue-eslint-parser\"\nimport tsParser from \"@typescript-eslint/parser\"\nexport default [\n    {\n        files: [\"*.vue\", \"**/*.vue\"],\n        languageOptions: {\n            parser: vueParser,\n            parserOptions: {\n                \"parser\": {\n                    // Script parser for `<script>`\n                    \"js\": \"espree\",\n\n                    // Script parser for `<script lang=\"ts\">`\n                    \"ts\": tsParser,\n\n                    // Script parser for vue directives (e.g. `v-if=` or `:attribute=`)\n                    // and vue interpolations (e.g. `{{variable}}`).\n                    // If not specified, the parser determined by `<script lang =\"...\">` is used.\n                    \"<template>\": \"espree\",\n                }\n            }\n        },\n    }\n]\n```\n\nIf the `parserOptions.parser` is `false`, the `vue-eslint-parser` skips parsing `<script>` tags completely.\nThis is useful for people who use the language ESLint community doesn't provide custom parser implementation.\n\n### parserOptions.vueFeatures\n\nYou can use `parserOptions.vueFeatures` property to specify how to parse related to Vue features.\nFor example:\n\n```js\nimport vueParser from \"vue-eslint-parser\"\nexport default [\n    {\n        files: [\"*.vue\", \"**/*.vue\"],\n        languageOptions: {\n            parser: vueParser,\n            parserOptions: {\n                vueFeatures: {\n                    filter: true,\n                    interpolationAsNonHTML: true,\n                    styleCSSVariableInjection: true,\n                    customMacros: []\n                }\n            }\n        },\n    }\n]\n```\n\n### parserOptions.vueFeatures.filter\n\nYou can use `parserOptions.vueFeatures.filter` property to specify whether to parse the Vue2 filter. If you specify `false`, the parser does not parse `|` as a filter.\nFor example:\n\n```json\n{\n    \"parserOptions\": {\n        \"vueFeatures\": {\n            \"filter\": false\n        }\n    }\n}\n```\n\nIf you specify `false`, it can be parsed in the same way as Vue 3.\nThe following template parses as a bitwise operation.\n\n```vue\n<template>\n  <div>{{ a | b }}</div>\n</template>\n```\n\nHowever, the following template that are valid in Vue 2 cannot be parsed.\n\n```vue\n<template>\n  <div>{{ a | valid:filter }}</div>\n</template>\n```\n\n### parserOptions.vueFeatures.interpolationAsNonHTML\n\nYou can use `parserOptions.vueFeatures.interpolationAsNonHTML` property to specify whether to parse the interpolation as HTML. If you specify `true`, the parser handles the interpolation as non-HTML (However, you can use HTML escaping in the interpolation). Default is `true`.\nFor example:\n\n```json\n{\n    \"parserOptions\": {\n        \"vueFeatures\": {\n            \"interpolationAsNonHTML\": true\n        }\n    }\n}\n```\n\nIf you specify `true`, it can be parsed in the same way as Vue 3.\nThe following template can be parsed well.\n\n```vue\n<template>\n  <div>{{a<b}}</div>\n</template>\n```\n\nBut, it cannot be parsed with Vue 2.\n\n### parserOptions.vueFeatures.styleCSSVariableInjection\n\nIf set to `true`, to parse expressions in `v-bind` CSS functions inside `<style>` tags. `v-bind()` is parsed into the `VExpressionContainer` AST node and held in the `VElement` of `<style>`. Default is `true`.\n\nSee also to [here](https://github.com/vuejs/rfcs/blob/master/active-rfcs/0043-sfc-style-variables.md).\n\n### parserOptions.vueFeatures.customMacros\n\nSpecifies an array of names of custom macros other than Vue standard macros.  \nFor example, if you have a custom macro `defineFoo()` and you want it processed by the parser, specify `[\"defineFoo\"]`.\n\nNote that this option only works in `<script setup>`.\n\n### parserOptions.templateTokenizer\n\n**This is an experimental feature. It may be changed or deleted without notice in the minor version.**\n\nYou can use `parserOptions.templateTokenizer` property to specify custom tokenizers to parse `<template lang=\"...\">` tags.\n\nFor example to enable parsing of pug templates:\n\n```jsonc\n{\n    \"parserOptions\": {\n        \"templateTokenizer\": {\n             // template tokenizer for `<template lang=\"pug\">`\n            \"pug\": \"vue-eslint-parser-template-tokenizer-pug\",\n        }\n    }\n}\n```\n\nThis option is only intended for plugin developers. **Be careful** when using this option directly, as it may change behaviour of rules you might have enabled.  \nIf you just want **pug** support, use [eslint-plugin-vue-pug](https://github.com/rashfael/eslint-plugin-vue-pug) instead, which uses this option internally.\n\nSee [implementing-custom-template-tokenizers.md](./docs/implementing-custom-template-tokenizers.md) for information on creating your own template tokenizer.\n\n## 🎇 Usage for custom rules / plugins\n\n- This parser provides `parserServices` to traverse `<template>`.\n    - `defineTemplateBodyVisitor(templateVisitor, scriptVisitor, options)` ... returns ESLint visitor to traverse `<template>`.\n    - `getTemplateBodyTokenStore()` ... returns ESLint `TokenStore` to get the tokens of `<template>`.\n    - `getDocumentFragment()` ... returns the root `VDocumentFragment`.\n    - `defineCustomBlocksVisitor(context, customParser, rule, scriptVisitor)` ... returns ESLint visitor that parses and traverses the contents of the custom block.\n    - `defineDocumentVisitor(documentVisitor, options)` ... returns ESLint visitor to traverses the document.\n- [ast.md](./docs/ast.md) is `<template>` AST specification.\n- [mustache-interpolation-spacing.js](https://github.com/vuejs/eslint-plugin-vue/blob/b434ff99d37f35570fa351681e43ba2cf5746db3/lib/rules/mustache-interpolation-spacing.js) is an example.\n- Check your version of ESLint as the location of `defineTemplateBodyVisitor` was moved from `context` to `context.sourceCode` after major version `9.x`\n\n### `defineTemplateBodyVisitor(templateBodyVisitor, scriptVisitor, options)`\n\n*Arguments*\n\n- `templateBodyVisitor` ... Event handlers for `<template>`.\n- `scriptVisitor` ... Event handlers for `<script>` or scripts. (optional)\n- `options` ... Options. (optional)\n  - `templateBodyTriggerSelector` ... Script AST node selector that triggers the templateBodyVisitor. Default is `\"Program:exit\"`. (optional)\n\n```ts\nimport { AST } from \"vue-eslint-parser\"\n\nexport function create(context) {\n    return context.sourceCode.parserServices.defineTemplateBodyVisitor(\n        // Event handlers for <template>.\n        {\n            VElement(node: AST.VElement): void {\n                //...\n            }\n        },\n        // Event handlers for <script> or scripts. (optional)\n        {\n            Program(node: AST.ESLintProgram): void {\n                //...\n            }\n        },\n        // Options. (optional)\n        {\n            templateBodyTriggerSelector: \"Program:exit\"\n        }\n    )\n}\n```\n\n## ⚠️ Known Limitations\n\nSome rules make warnings due to the outside of `<script>` tags.\nPlease disable those rules for `.vue` files as necessary.\n\n- [eol-last](http://eslint.org/docs/rules/eol-last)\n- [linebreak-style](http://eslint.org/docs/rules/linebreak-style)\n- [max-len](http://eslint.org/docs/rules/max-len)\n- [max-lines](http://eslint.org/docs/rules/max-lines)\n- [no-trailing-spaces](http://eslint.org/docs/rules/no-trailing-spaces)\n- [unicode-bom](http://eslint.org/docs/rules/unicode-bom)\n- Other rules which are using the source code text instead of AST might be confused as well.\n\n## 📰 Changelog\n\n- [GitHub Releases](https://github.com/vuejs/vue-eslint-parser/releases)\n\n## 🍻 Contributing\n\nWelcome contributing!\n\nPlease use GitHub's Issues/PRs.\n\nIf you want to write code, please execute `npm install` after you cloned this repository.\nThe `npm install` command installs dependencies.\n\n### Development Tools\n\n- `npm test` runs tests and measures coverage.\n- `npm run build` compiles TypeScript source code to `index.js`, `index.js.map`, and `index.d.ts` in `dist`.\n- `npm run coverage` shows the coverage result of `npm test` command with the default browser.\n- `npm run lint` runs ESLint.\n- `npm run update-fixtures` updates files in `test/fixtures/ast` directory based on `test/fixtures/ast/*/source.vue` files.\n- `npm run watch` runs `build`, `update-fixtures`, and tests with `--watch` option.\n","publish_time":1770978303584,"_cnpm_publish_time":1770978303584,"dist-tags":{"experimental":"2.0.1-beta.3","latest":"10.4.2","next":"9.0.0"}}