no-textarea-mustache.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. docs: {
  17. description: 'disallow mustaches in `<textarea>`',
  18. category: 'essential',
  19. url: 'https://github.com/vuejs/eslint-plugin-vue/blob/v4.7.1/docs/rules/no-textarea-mustache.md'
  20. },
  21. fixable: null,
  22. schema: []
  23. },
  24. create (context) {
  25. return utils.defineTemplateBodyVisitor(context, {
  26. "VElement[name='textarea'] VExpressionContainer" (node) {
  27. if (node.parent.type !== 'VElement') {
  28. return
  29. }
  30. context.report({
  31. node,
  32. loc: node.loc,
  33. message: "Unexpected mustache. Use 'v-model' instead."
  34. })
  35. }
  36. })
  37. }
  38. }