The `eslint-plugin-vue-test-utils` package is an ESLint plugin dedicated to enforcing best practices and identifying potential issues when using the `@vue/test-utils` library for testing Vue components. It helps developers maintain high-quality and future-proof test suites by flagging deprecated API usages, inconsistent patterns, and common anti-patterns. The current stable version is 1.0.1, indicating a mature initial release. While a strict release cadence isn't explicitly stated, the recent v1.0.1 release with multiple feature additions and documentation improvements suggests active development. Its core differentiator lies in its specialized focus on `@vue/test-utils`, providing rules that are context-aware of VTU's API changes and version-specific behaviors, often with autofixing capabilities. This enables smoother upgrades of `@vue/test-utils` and helps keep test code consistent without needing manual audits for deprecated features. It complements broader ESLint Vue plugins by offering specific, targeted linting for testing concerns.
npm install eslint-plugin-vue-test-utilsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to install the plugin, configure it in an `.eslintrc.js` file to use its recommended rules, and manually specify individual rules. It also shows the option to set the Vue Test Utils version manually, which is crucial for correct linting in certain project setups.
Manually set the Vue Test Utils version in your `.eslintrc` settings: `{"settings": {"vtu": {"version": "1.3.0"}}}`. You can dynamically read the version using `require('@vue/test-utils/package.json').version` in a JavaScript `.eslintrc` file.Ensure your Node.js environment meets the specified requirement. Upgrade Node.js to version 14.x or 16+.
Always address warnings and errors reported by the plugin, especially those related to deprecated features. Consult the `@vue/test-utils` migration guide for major version upgrades.
Run `npm install --save-dev eslint-plugin-vue-test-utils` or `yarn add --dev eslint-plugin-vue-test-utils`. Verify the package is listed in `devDependencies`.
Check the plugin's documentation for the specific rule (`./docs/rules/index.md` in the package) to understand its accepted options and their formats. Correct your `.eslintrc` rule configuration.
Ensure `@vue/test-utils` is correctly installed in your project. If it's installed in a non-standard location (e.g., a hoisted monorepo `node_modules`), adjust the `require` path or provide a static version string.