Gathering detailed insights and metrics for vue-eslint-parser
Gathering detailed insights and metrics for vue-eslint-parser
Gathering detailed insights and metrics for vue-eslint-parser
Gathering detailed insights and metrics for vue-eslint-parser
vue-eslint-parser-template-tokenizer-pug
This is an internal library. If you just want to lint your pug templates, use [eslint-plugin-vue-pug](https://github.com/rashfael/eslint-plugin-vue-pug).
@vue-vine/eslint-parser
ESLint parser for Vue Vine
eslint-plugin-tsvue-parser
Used for the JS/TS hybrid project, make vue+ts become another extension
typescript-eslint-parser-for-extra-files
An experimental ESLint custom parser for Vue, Svelte, and Astro for use with TypeScript. It provides type information in combination with each framework's ESLint custom parser.
The ESLint custom parser for `.vue` files.
npm install vue-eslint-parser
Typescript
Module System
Min. Node Version
Node Version
NPM Version
93.9
Supply Chain
94.7
Quality
77.9
Maintenance
100
Vulnerability
98.6
License
TypeScript (71.84%)
JavaScript (28.16%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
785,228,027
Last Day
829,241
Last Week
4,372,365
Last Month
18,350,548
Last Year
199,867,347
MIT License
458 Stars
392 Commits
75 Forks
12 Watchers
2 Branches
80 Contributors
Updated on Jan 29, 2025
Minified
Minified + Gzipped
Latest Version
9.4.3
Package Id
vue-eslint-parser@9.4.3
Unpacked Size
1.08 MB
Size
193.58 kB
File Count
6
NPM Version
10.5.2
Node Version
20.13.0
Published on
Jun 01, 2024
Cumulative downloads
Total Downloads
Last Day
-0.8%
829,241
Compared to previous day
Last Week
5.3%
4,372,365
Compared to previous week
Last Month
47.1%
18,350,548
Compared to previous month
Last Year
18.1%
199,867,347
Compared to previous year
1
40
The ESLint custom parser for .vue
files.
This 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 would catch some of the mistakes.
1npm install --save-dev eslint vue-eslint-parser
parser
option into your .eslintrc.*
file.--ext .vue
CLI option.1{ 2 "extends": "eslint:recommended", 3 "parser": "vue-eslint-parser" 4}
1$ eslint "src/**/*.{js,vue}" 2# or 3$ eslint src --ext .vue
parserOptions
has the same properties as what espree, the default parser of ESLint, is supporting.
For example:
1{ 2 "parser": "vue-eslint-parser", 3 "parserOptions": { 4 "sourceType": "module", 5 "ecmaVersion": 2018, 6 "ecmaFeatures": { 7 "globalReturn": false, 8 "impliedStrict": false, 9 "jsx": false 10 } 11 } 12}
You can use parserOptions.parser
property to specify a custom parser to parse <script>
tags.
Other properties than parser would be given to the specified parser.
For example:
1{ 2 "parser": "vue-eslint-parser", 3 "parserOptions": { 4 "parser": "@babel/eslint-parser", 5 "sourceType": "module" 6 } 7}
1{ 2 "parser": "vue-eslint-parser", 3 "parserOptions": { 4 "parser": "@typescript-eslint/parser", 5 "sourceType": "module" 6 } 7}
You can also specify an object and change the parser separately for <script lang="...">
.
1{ 2 "parser": "vue-eslint-parser", 3 "parserOptions": { 4 "parser": { 5 // Script parser for `<script>` 6 "js": "espree", 7 8 // Script parser for `<script lang="ts">` 9 "ts": "@typescript-eslint/parser", 10 11 // Script parser for vue directives (e.g. `v-if=` or `:attribute=`) 12 // and vue interpolations (e.g. `{{variable}}`). 13 // If not specified, the parser determined by `<script lang ="...">` is used. 14 "<template>": "espree", 15 } 16 } 17}
When using JavaScript configuration (.eslintrc.js
), you can also give the parser object directly.
1const tsParser = require("@typescript-eslint/parser") 2const espree = require("espree") 3 4module.exports = { 5 parser: "vue-eslint-parser", 6 parserOptions: { 7 // Single parser 8 parser: tsParser, 9 // Multiple parser 10 parser: { 11 js: espree, 12 ts: tsParser, 13 } 14 }, 15}
If the parserOptions.parser
is false
, the vue-eslint-parser
skips parsing <script>
tags completely.
This is useful for people who use the language ESLint community doesn't provide custom parser implementation.
You can use parserOptions.vueFeatures
property to specify how to parse related to Vue features.
For example:
1{ 2 "parser": "vue-eslint-parser", 3 "parserOptions": { 4 "vueFeatures": { 5 "filter": true, 6 "interpolationAsNonHTML": true, 7 "styleCSSVariableInjection": true, 8 "customMacros": [] 9 } 10 } 11}
You 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.
For example:
1{ 2 "parser": "vue-eslint-parser", 3 "parserOptions": { 4 "vueFeatures": { 5 "filter": false 6 } 7 } 8}
If you specify false
, it can be parsed in the same way as Vue 3.
The following template parses as a bitwise operation.
1<template> 2 <div>{{ a | b }}</div> 3</template>
However, the following template that are valid in Vue 2 cannot be parsed.
1<template> 2 <div>{{ a | valid:filter }}</div> 3</template>
You 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
.
For example:
1{ 2 "parser": "vue-eslint-parser", 3 "parserOptions": { 4 "vueFeatures": { 5 "interpolationAsNonHTML": true 6 } 7 } 8}
If you specify true
, it can be parsed in the same way as Vue 3.
The following template can be parsed well.
1<template> 2 <div>{{a<b}}</div> 3</template>
But, it cannot be parsed with Vue 2.
If 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
.
See also to here.
Specifies an array of names of custom macros other than Vue standard macros.
For example, if you have a custom macro defineFoo()
and you want it processed by the parser, specify ["defineFoo"]
.
Note that this option only works in <script setup>
.
This is an experimental feature. It may be changed or deleted without notice in the minor version.
You can use parserOptions.templateTokenizer
property to specify custom tokenizers to parse <template lang="...">
tags.
For example to enable parsing of pug templates:
1{ 2 "parser": "vue-eslint-parser", 3 "parserOptions": { 4 "templateTokenizer": { 5 // template tokenizer for `<template lang="pug">` 6 "pug": "vue-eslint-parser-template-tokenizer-pug", 7 } 8 } 9}
This 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.
If you just want pug support, use eslint-plugin-vue-pug instead, which uses this option internally.
See implementing-custom-template-tokenizers.md for information on creating your own template tokenizer.
parserServices
to traverse <template>
.
defineTemplateBodyVisitor(templateVisitor, scriptVisitor, options)
... returns ESLint visitor to traverse <template>
.getTemplateBodyTokenStore()
... returns ESLint TokenStore
to get the tokens of <template>
.getDocumentFragment()
... returns the root VDocumentFragment
.defineCustomBlocksVisitor(context, customParser, rule, scriptVisitor)
... returns ESLint visitor that parses and traverses the contents of the custom block.defineDocumentVisitor(documentVisitor, options)
... returns ESLint visitor to traverses the document.<template>
AST specification.defineTemplateBodyVisitor(templateBodyVisitor, scriptVisitor, options)
Arguments
templateBodyVisitor
... Event handlers for <template>
.scriptVisitor
... Event handlers for <script>
or scripts. (optional)options
... Options. (optional)
templateBodyTriggerSelector
... Script AST node selector that triggers the templateBodyVisitor. Default is "Program:exit"
. (optional)1import { AST } from "vue-eslint-parser" 2 3export function create(context) { 4 return context.parserServices.defineTemplateBodyVisitor( 5 // Event handlers for <template>. 6 { 7 VElement(node: AST.VElement): void { 8 //... 9 } 10 }, 11 // Event handlers for <script> or scripts. (optional) 12 { 13 Program(node: AST.ESLintProgram): void { 14 //... 15 } 16 }, 17 // Options. (optional) 18 { 19 templateBodyTriggerSelector: "Program:exit" 20 } 21 ) 22}
Some rules make warnings due to the outside of <script>
tags.
Please disable those rules for .vue
files as necessary.
Welcome contributing!
Please use GitHub's Issues/PRs.
If you want to write code, please execute npm install && npm run setup
after you cloned this repository.
The npm install
command installs dependencies.
The npm run setup
command initializes ESLint as git submodules for tests.
npm test
runs tests and measures coverage.npm run build
compiles TypeScript source code to index.js
, index.js.map
, and index.d.ts
.npm run coverage
shows the coverage result of npm test
command with the default browser.npm run clean
removes the temporary files which are created by npm test
and npm run build
.npm run lint
runs ESLint.npm run setup
setups submodules to develop.npm run update-fixtures
updates files in test/fixtures/ast
directory based on test/fixtures/ast/*/source.vue
files.npm run watch
runs build
, update-fixtures
, and tests with --watch
option.No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
6 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 5
Reason
Found 1/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More