This ESLint plugin integrates Prettier formatting specifically for Vue Single File Components (SFCs). At version 5.0.0, it is actively maintained and provides a robust solution for ensuring consistent code style in Vue projects. It includes all functionalities of `eslint-plugin-prettier` but extends them to properly handle the unique structure of Vue SFCs. Its key differentiators include the ability to process and format custom blocks (e.g., `<docs>`, `<config>`) within Vue SFCs, which `eslint-plugin-prettier` does not support. It also offers granular control over whether `<template>`, `<script>`, or `<style>` blocks should be processed by Prettier, allowing developers to disable formatting for specific sections if needed. While no explicit release cadence is documented, it typically updates to support new versions of ESLint, Prettier, and Vue. It is designed to be the sole Prettier-ESLint integration for Vue projects, superseding the general `eslint-plugin-prettier`.
npm install eslint-plugin-prettier-vueVerified import paths — ran on the pinned version, not inferred.
Demonstrates installation of the plugin and its dependencies, followed by the essential `.eslintrc.js` configuration including recommended presets and custom block handling.
Upgrade your Node.js environment to version 16 or later.
Remove `plugin:prettier/recommended` from your `extends` array and any `'prettier/prettier'` rules if `eslint-plugin-prettier-vue` is active. This plugin's recommended configuration handles Prettier integration.
Carefully review the `SFCBlocks` settings in your `.eslintrc.js`. Ensure `template`, `script`, and `style` are set to `true` if you want Prettier to handle them. For custom blocks, specify `lang` (e.g., `docs: { lang: 'markdown' }`) or `false` to ignore them.Ensure `npm install eslint-plugin-prettier-vue` has been run and `'plugin:prettier-vue/recommended'` is present in your `.eslintrc.js` `extends` array.
Remove `plugin:prettier/recommended` from `extends` and any `prettier/prettier` rule. Ensure `plugin:prettier-vue/recommended` is the *last* entry in your `extends` array to ensure it correctly overrides other formatting-related rules.
Add or update the `customBlocks` configuration in `settings['prettier-vue'].SFCBlocks` within your `.eslintrc.js` to specify the `lang` (e.g., `markdown`, `json`, `js`, `ts`) for each custom block you wish to format. For example: `customBlocks: { docs: { lang: 'markdown' } }`.