{"name":"vue-eslint-parser","version":"10.2.0","keywords":[],"author":{"name":"Toru Nagashima"},"license":"MIT","_id":"vue-eslint-parser@10.2.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":"cb53f89b14c7f5bf6a95c9532e3b2961ab619d61","tarball":"http://registry-npm.ywwl.com/vue-eslint-parser/download/vue-eslint-parser-10.2.0.tgz","fileCount":6,"integrity":"sha512-CydUvFOQKD928UzZhTp4pr2vWz1L+H99t7Pkln2QSPdvmURT0MoC4wUccfCnuEaihNsu9aYYyk+bep8rlfkUXw==","signatures":[{"sig":"MEUCIQDGOFu7Ka4dLbJHV0VSdTDkb+vzADCRTDWS2xwbdfL8OQIgeSY2iYXduf4EC6rALBWVtL1FHD7UzA0d9iMzY79z2Pg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1146032,"size":201653,"noattachment":false,"key":"/vue-eslint-parser/-/vue-eslint-parser-10.2.0.tgz"},"main":"index.js","types":"./index.d.ts","engines":{"node":"^18.18.0 || ^20.9.0 || >=21.1.0"},"funding":"https://github.com/sponsors/mysticatea","gitHead":"62321dbd75a5b962400c0f1201c1a61a0917e765","scripts":{"lint":"eslint src test package.json","test":"npm run -s test:mocha","build":"tsc --module es2015 && rollup -c -o index.js && dts-bundle --name vue-eslint-parser --main .temp/index.d.ts --out ../index.d.ts","clean":"rimraf .nyc_output .temp coverage index.*","watch":"run-p watch:*","pretest":"run-s build lint","version":"npm run -s build","coverage":"opener ./coverage/lcov-report/index.html","prebuild":"npm run -s clean","prewatch":"npm run -s clean","watch:tsc":"tsc --module es2015 --watch","preversion":"npm test","test:cover":"nyc mocha \"test/*.js\" --reporter dot --timeout 60000","test:debug":"mocha --require ts-node/register/transpile-only \"test/*.js\" --reporter dot --timeout 60000","test:mocha":"mocha --require ts-node/register \"test/*.js\" --reporter dot --timeout 60000","watch:test":"wait-on index.js && warun index.js \"test/*.js\" \"test/fixtures/ast/*/*.json\" \"test/fixtures/*\" --debounce 1000 --no-initial -- nyc mocha \"test/*.js\" --reporter dot --timeout 10000","postversion":"git push && git push --tags","watch:rollup":"wait-on .temp/index.js && rollup -c -o index.js --watch","update-fixtures":"ts-node --transpile-only scripts/update-fixtures-ast.js && ts-node --transpile-only scripts/update-fixtures-document-fragment.js","watch:update-ast":"wait-on index.js && warun index.js \"test/fixtures/ast/*/*.vue\" -- ts-node scripts/update-fixtures-ast.js","watch:coverage-report":"wait-on coverage/lcov-report/index.html && opener coverage/lcov-report/index.html"},"_npmUser":{"name":"ota-meshi","actor":{"name":"ota-meshi","type":"user","email":"otameshiyo23@gmail.com"},"email":"otameshiyo23@gmail.com"},"repository":{"url":"git+https://github.com/vuejs/vue-eslint-parser.git","type":"git"},"_npmVersion":"11.3.0","description":"The ESLint custom parser for `.vue` files.","directories":{},"_nodeVersion":"24.2.0","dependencies":{"debug":"^4.4.0","espree":"^10.3.0","semver":"^7.6.3","esquery":"^1.6.0","eslint-scope":"^8.2.0","eslint-visitor-keys":"^4.2.0"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^15.1.0","mocha":"^9.1.3","warun":"^1.0.0","eslint":"^9.19.0","opener":"^1.5.2","rimraf":"^3.0.2","rollup":"^2.60.0","ts-node":"^10.9.2","wait-on":"^6.0.0","chokidar":"^3.5.2","fs-extra":"^10.0.0","prettier":"^3.4.2","@eslint/js":"^9.19.0","dts-bundle":"^0.7.3","typescript":"~5.7.3","@babel/core":"^7.26.7","@types/node":"^18.8.4","cross-spawn":"^7.0.3","npm-run-all":"^4.1.5","@types/debug":"^4.1.7","@types/mocha":"^9.0.0","@types/estree":"^1.0.0","@types/semver":"^7.3.12","eslint-plugin-n":"^17.15.1","@eslint/eslintrc":"^3.2.0","eslint-plugin-jsonc":"^2.19.1","jsonc-eslint-parser":"^2.0.3","@babel/eslint-parser":"^7.26.5","eslint-plugin-unicorn":"^57.0.0","rollup-plugin-replace":"^2.2.0","eslint-plugin-prettier":"^5.2.3","rollup-plugin-sourcemaps":"^0.6.3","@typescript-eslint/parser":"^8.22.0","rollup-plugin-node-resolve":"^5.2.0","eslint-plugin-eslint-comments":"^3.2.0","@babel/plugin-syntax-decorators":"^7.25.9","@babel/plugin-syntax-typescript":"^7.25.9","eslint-plugin-node-dependencies":"^0.12.0","@typescript-eslint/eslint-plugin":"^8.22.0","@babel/plugin-syntax-pipeline-operator":"^7.26.7"},"peerDependencies":{"eslint":"^8.57.0 || ^9.0.0"},"_npmOperationalInternal":{"tmp":"tmp/vue-eslint-parser_10.2.0_1751371013571_0.9679888612441481","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":1751371013814,"_cnpm_publish_time":1751371013814,"dist-tags":{"experimental":"2.0.1-beta.3","latest":"10.4.2","next":"9.0.0"}}