require-component-is.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * @author Toru Nagashima
  3. * @copyright 2017 Toru Nagashima. All rights reserved.
  4. * See LICENSE file in root directory for full license.
  5. */
  6. 'use strict'
  7. // ------------------------------------------------------------------------------
  8. // Requirements
  9. // ------------------------------------------------------------------------------
  10. const utils = require('../utils')
  11. // ------------------------------------------------------------------------------
  12. // Rule Definition
  13. // ------------------------------------------------------------------------------
  14. module.exports = {
  15. meta: {
  16. type: 'problem',
  17. docs: {
  18. description: 'require `v-bind:is` of `<component>` elements',
  19. category: 'essential',
  20. url: 'https://eslint.vuejs.org/rules/require-component-is.html'
  21. },
  22. fixable: null,
  23. schema: []
  24. },
  25. create (context) {
  26. return utils.defineTemplateBodyVisitor(context, {
  27. "VElement[name='component']" (node) {
  28. if (!utils.hasDirective(node, 'bind', 'is')) {
  29. context.report({
  30. node,
  31. loc: node.loc,
  32. message: "Expected '<component>' elements to have 'v-bind:is' attribute."
  33. })
  34. }
  35. }
  36. })
  37. }
  38. }