ESLint Plugin for Vue Types

2.1.0 · maintenance · verified Sun Apr 19

eslint-plugin-vue-types integrates `vue-types` with `eslint-plugin-vue`, specifically addressing the `vue/require-default-prop` rule. It prevents ESLint from reporting errors for props defined using `vue-types` validators (e.g., `VueTypes.string` or `string().isRequired`). The plugin's current stable version is 2.1.0. It primarily serves environments using `eslint-plugin-vue` versions older than 7.0.0. For `eslint-plugin-vue@7` and later, this plugin is generally not needed as the upstream `vue/require-default-prop` rule inherently ignores call expressions and object properties, negating the problem this plugin solves. Its release cadence is sporadic, reacting to changes in its peer dependencies, especially `eslint-plugin-vue` and `vue-types`. A key differentiator is its focused scope on a single `vue-types`-specific rule extension.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates the `.eslintrc.json` configuration for `eslint-plugin-vue-types` and a Vue component showcasing how the plugin prevents `vue/require-default-prop` errors for `vue-types` definitions, including custom namespaces and import sources.

{
  "root": true,
  "env": {
    "node": true
  },
  "extends": [
    "plugin:vue/recommended",
    "plugin:vue-types/recommended"
  ],
  "parserOptions": {
    "ecmaVersion": 2020
  },
  "rules": {
    "vue/require-default-prop": "error" // Ensure the base rule is active
  },
  "settings": {
    "vue-types/namespace": ["AppTypes"],
    "vue-types/sources": ["./src/prop-validators"]
  }
}

// src/App.vue
<template>
  <div>{{ msg1 }} {{ msg2 }}</div>
</template>

<script>
import VueTypes, { string } from 'vue-types';
import { customProp } from './prop-validators';

const AppTypes = {
  theme: VueTypes.oneOf(['dark', 'light'])
};

export default {
  props: {
    msg1: string().isRequired, // No error with plugin
    msg2: VueTypes.string,     // No error with plugin
    msg3: AppTypes.theme,      // No error with custom namespace
    msg4: customProp().isRequired // No error with custom source
  }
};
</script>

// src/prop-validators.js
import VueTypes from 'vue-types';
export const customProp = () => VueTypes.bool;

view raw JSON →