vue-eslint-parser is a custom ESLint parser specifically designed to handle `.vue` Single File Components (SFCs). Its primary function is to enable linting of the `<template>` section of Vue files, which traditional JavaScript parsers cannot process. This allows developers to catch errors in complex directives and expressions within their Vue templates. The package is currently at a stable version, 10.4.0, and maintains an active release cadence with frequent updates for enhancements, bug fixes, and infrastructure improvements, as seen in recent minor releases and patch fixes. A key differentiator is its ability to integrate with other parsers (like `@babel/eslint-parser` or `@typescript-eslint/parser`) for the `<script>` blocks, offering flexible configuration through `parserOptions.parser`. It also provides granular control over parsing features specific to Vue, such as the `parserOptions.vueFeatures` property, further enhancing its adaptability to diverse Vue project setups.
npm install vue-eslint-parserVerified import paths — ran on the pinned version, not inferred.
This configuration demonstrates how to set up `vue-eslint-parser` in a modern `eslint.config.js` file, enabling linting for `.vue` files and integrating `@typescript-eslint/parser` for `<script lang="ts">` blocks.
Upgrade your Node.js and ESLint installations to compatible versions, or remain on `vue-eslint-parser` v9.x if an upgrade is not feasible.
If using `@typescript-eslint/parser` and requiring type-aware linting in template expressions, explicitly configure `parserOptions.parser['<template>']` with the `project` option pointing to your `tsconfig.json`.
If you encounter unexpected parsing errors or rule conflicts, explicitly set `languageOptions.parserOptions.ecmaVersion` to your desired ECMAScript version (e.g., `2015`, `2020`) in your ESLint configuration.
Set `parserOptions.parser: { ts: require('@typescript-eslint/parser') }` (or `import tsParser from '@typescript-eslint/parser'` for ESM configs) in your ESLint configuration under the `languageOptions` for `.vue` files.Refer to the `vue-eslint-parser` documentation for `parserOptions.parser` for the correct object structure and available keys. Ensure you specify the appropriate parser for each language section you intend to lint within your Vue files.
Run `npm install --save-dev vue-eslint-parser eslint` or `yarn add -D vue-eslint-parser eslint` to install the required packages.
Configure `parserOptions.parser: { ts: '@typescript-eslint/parser' }` within your ESLint configuration's `languageOptions` for `.vue` files to correctly parse TypeScript syntax.Upgrade your Node.js environment to a compatible version (e.g., Node.js 18.18.0 or 20.9.0) or downgrade `vue-eslint-parser` to a v9.x release to match your current Node.js version.
Ensure you are using ESLint v8.x or later. For `parserOptions.parser` (especially nested parsers like `parserOptions.parser.ts`), try passing the string identifier `'@typescript-eslint/parser'` instead of the imported parser function if you are having issues with resolution.