English
Getting Started
eslint-plugin-vue-perfectionist provides configurable ESLint rules for Vue 3 scripts and templates. Follow these steps to register the plugin, enable rules, and run your first checks.
Development status
The API may change before the first stable release. Review release notes when upgrading.
Install
This plugin targets Vue >=3.5.42 <4, including the matching SFC compiler and SSR renderer. Older Vue versions are outside the supported range. Vue is an optional peer dependency: linting does not load the Vue runtime.
The package declares ESLint ^10.0.0 and vue-eslint-parser ^10.0.0 as peer dependencies and ships as ESM. Install them together:
shell
pnpm add -D eslint eslint-plugin-vue-perfectionist vue-eslint-parsershell
npm i -D eslint eslint-plugin-vue-perfectionist vue-eslint-parsershell
yarn add -D eslint eslint-plugin-vue-perfectionist vue-eslint-parserFor TypeScript SFCs, also install the script parser and TypeScript:
shell
pnpm add -D @typescript-eslint/parser typescript@6shell
npm i -D @typescript-eslint/parser typescript@6shell
yarn add -D @typescript-eslint/parser typescript@6Basic Usage
Register the plugin and enable the rules you want in eslint.config.mjs. The plugin provides rules only; there are no built-in configurations. This example supports JavaScript and TypeScript Vue SFCs:
js
import tsParser from '@typescript-eslint/parser'
import { defineConfig } from 'eslint/config'
import vuePerfectionist from 'eslint-plugin-vue-perfectionist'
import vueParser from 'vue-eslint-parser'
export default defineConfig([
{
files: ['**/*.vue'],
languageOptions: {
parser: vueParser,
parserOptions: {
parser: tsParser,
},
},
plugins: {
'vue-perfectionist': vuePerfectionist,
},
rules: {
'vue-perfectionist/callback-style': 'error',
'vue-perfectionist/define-macros-newline': 'error',
'vue-perfectionist/no-complex-template-expression': 'error',
'vue-perfectionist/no-template-type-assertion': 'error',
'vue-perfectionist/no-watcher-cleanup-after-await': 'error',
'vue-perfectionist/require-props-prefix': 'error',
},
},
])For JavaScript-only SFCs, omit the TypeScript parser import and parserOptions.parser. If your Vue configuration already supplies the parsers, add the plugin and your chosen rules to it.
Run ESLint
Run ESLint against your source files, adding --fix to apply supported fixes:
shell
pnpm exec eslint .
pnpm exec eslint . --fixFor composable return objects and consumer destructuring, enable sort-composable-return and sort-composable-destructure independently. Both default to state before methods, preserve within-group order, and fix only whitespace.
Require explicit local fields with require-composable-return-bindings. It allows aliases by default and reports inline expressions without fixes.
To keep returned state reactive when consumers destructure it, return a plain object of refs and enable no-reactive-composable-return.
For direct statements inside named composables, enable sort-composable-body. It shares setup sorting preferences and applies conservative movement fixes independently of member sorting.
Use consistent-template-element-layout for complete inline or expanded block layouts and separated block siblings. It defaults to formatter-compatible reporting; safe closing-tag fixes and component layout groups are opt-in.
Next Steps
- Choose rules: browse by purpose and check file scopes, defaults, and automatic fix support.
- Configuration: configure standalone JS/TS files, auto-imported Vue APIs, and public types.
- Rule Composition: combine related checks and understand fix boundaries and interactions with other plugins.
- Troubleshooting: diagnose inactive rules, missing fixes, and type-service configuration.