eslint-plugin-vue-test-utils

Linting for Vue Test Utils
93,835
Install
npm install eslint-plugin-vue-test-utils
Latest Version:1.0.1
License:MIT
Last Updated:Jun 17, 2022
Links: npm
Maintainer: beproductiv

eslint-plugin-vue-test-utils

Linting for @vue/test-utils.

Installation

npm install --save-dev eslint eslint-plugin-vue-test-utils

Usage

Add vue-test-utils to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": ["vue-test-utils"]
}

Then configure the rules you want to use under the rules section.

{
    "rules": {
        "vue-test-utils/no-deprecated-wrapper-functions": "error"
    }
}

Alternatively, extend the recommended configuration:

{
    "extends": [
        "eslint-recommended",
        // ...
        "plugin:vue-test-utils/recommended"
    ]
}

The recommended configuration will enable all rules as errors. Specific rules can be overriden as described above.

Setting the VTU version

Some rules have different behavior depending on the version of VTU that is being used. If the plugin and VTU are not installed in the same directory (possible in some monorepo configurations), VTU's version will not be able to be auto-detected and you will get an error. In this case, you can set it manually in your .eslintrc:

{
    "settings": {
        "vtu": {
            "version": "1.3.0"
        }
    }
}

If your .eslintrc file is a Javascript file instead of JSON, you may be able to use require('@vue/test-utils/package.json').version to pick up the version directly from the installed package.

Supported Rules

See rules for a full list of rules enabled by this plugin.

Adding new rules

Create a new rule file, test file, and docs file in ./src/rules, ./test/src/rules, and ./docs/rules respectively. Import the rule file in ./src/index.js and add it to the list of rules exports and to the recommended config rules. Use the existing code as guidance. For more details on how to write a rule, here are some useful links to get you started:

Note that when exporting the rule, you use the unprefixed ID, but when adding the rule to the configuration, you need to use the fully-qualified name of the rule (in the format vue-test-utils/{id}).

License

MIT

Related Packages

eslint-plugin-vue-storefront

ESLint rules for Vue Storefront

39,292
@scayle/eslint-plugin-vue-composable

Rules to avoid unpleasant composable problems

207,394 4
@component-hook/eslint-plugin

ESLint config for component hook

8,834 4
eslint-plugin-test-id

This checks is data-test-id prop is present, on some tags which are useful for e...

10,384 17
eslint-plugin-vueunused

a eslint plugin for detecting unused code in vue single file component

939

Version History

Version Released License
1.0.1 MIT
1.0.0 MIT