Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Latest commit

 

History

History
98 lines (69 loc) · 2.33 KB

README.md

File metadata and controls

98 lines (69 loc) · 2.33 KB

eslint-plugin-vue-types

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

This plugin should be used alongside eslint-plugin-vue to validate usages of vue-types on prop definitions (see this issue for details).

Requirements

  • ESLint >=3.18.0.
    • >=4.7.0 to use eslint --fix.
    • >=4.14.0 to use with babel-eslint.
  • Node.js >=4.0.0

Installation

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

Usage

This plugin provides the following eslint-plugin-vue rule:

Default usage

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

module.exports = {
  extends: [
    // ...
    'plugin:vue/strongly-recommended'
    'plugin:vue-types/strongly-recommended'
  ],
  //...
}

Custom vue-types namespaces

By default vue-types/require-default-prop will not report vue-types 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 definition in a namespace and add it to the plugin's whitelist:

// .eslint.rc.js
module.exports = {
  extends: [
    // ...
    'plugin:vue/strongly-recommended'
    'plugin:vue-types/strongly-recommended'
  ],
  settings: {
    'vue-types/namespace': ['VueTypes', '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
  }

}

License

MIT

Copyright (c) 2018 Marco Solazzi