npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eslint-plugin-vue-types

v2.1.0

Published

eslint-plugin-vue integration plugin for vue-types

Downloads

5,536

Readme

eslint-plugin-vue-types

ESLint plugin for vue-types and eslint-plugin-vue

eslint-plugin-vue version note

Since eslint-plugin-vue@7, the vue/require-default-prop rule ignores props assignment by call expressions (VueTypes.arrayOf(String)) or object properties (VueTypes.array). So you don't need this plugin anymore.

If you are using an older version of eslint-plugin-vue consider upgrading it.

--- Original Documentation ---

Warning: This is the documentation for eslint-plugin-vue-types@^2.0.0. The documentation for v.1 is available here.

This plugin should be used alongside eslint-plugin-vue to allow the usage of vue-types validators as valid prop definitions with the [] rule (see vue-types#29 and vue-types#179 for details).

Requirements

  • ESLint >=5.0.0.
  • Node.js >=10.0.0

Installation

npm install --save-dev eslint eslint-plugin-vue eslint-plugin-vue-types

Usage

This plugin provides a single rule: vue-types/require-default-prop.

The rule extends vue/require-default-prop preventing it from reporting errors for props defined with VueTypes namespaced validators (like VueTypes.string or VueTypes.oneOf([...])). It also allows individually imported validators.

In your eslint configuration add plugin:vue-types/recommended after any plugin:vue/* preset.

{
  "extends": ["plugin:vue/recommended", "plugin:vue-types/recommended"]
}

This will filter errors for prop definitions like:

import VueTypes, { string } from 'vue-types'

export default {
  props: {
    msg1: string().isRequired, // no error reported
    msg2: VueTypes.string, // no error reported
    msg3: VueTypes.shape({}).loose.isRequired, // no error reported
  },
}

Note: For this plugin to work properly, ensure that the .isRequired flag always comes last in the chain:

import { shape } from 'vue-types'

export default {
  props: {
    msg1: shape({ ... }).loose.isRequired, // no error reported

    msg2: shape({}).isRequired.loose, // ERROR!
  },
}

Customization

Custom namespaces

By default vue-types/require-default-prop will not report VueTypes validators when used with the VueTypes namespace.

import VueTypes from 'vue-types'

const theme = VueTypes.oneOf(['dark', 'light'])

export default {
  props: {
    name: VueTypes.string, // <-- not an error
    theme, // <-- error
  },
}

To prevent this error you can wrap custom validators in a namespace and add it to the plugin's allowed namespaces:

// .eslintrc.json
{
  "extends": ["plugin:vue/recommended", "plugin:vue-types/recommended"],
  "settings": {
    "vue-types/namespace": ["AppTypes"]
  }
}
import VueTypes from 'vue-types'

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

export default {
  props: {
    name: VueTypes.string, // <-- not an error
    theme: AppTypes.theme, // <-- not an error
  },
}

Custom import sources

By default vue-types/require-default-prop will not report VueTypes individual validators when imported from the vue-types module.

To extend this feature to other modules, include them in the vue-types/sources setting:

// .eslintrc.json
{
  "extends": ["plugin:vue/recommended", "plugin:vue-types/recommended"],
  "settings": {
    "vue-types/sources": ["~/utils/prop-types"]
  }
}
import { string } from 'vue-types'
import { myValidator } from '~/utils/prop-types'

export default {
  props: {
    name: string(), // <-- not an error
    msg: myValidator(), // <-- custom validator, not an error
  },
}

Note: This feature is only available for static import statements.

License

MIT

Copyright (c) 2018-2021 Marco Solazzi