no-textarea-mustache.js 1006 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. const utils = require('../utils')
  8. module.exports = {
  9. meta: {
  10. type: 'problem',
  11. docs: {
  12. description: 'disallow mustaches in `<textarea>`',
  13. categories: ['vue3-essential', 'vue2-essential'],
  14. url: 'https://eslint.vuejs.org/rules/no-textarea-mustache.html'
  15. },
  16. fixable: null,
  17. schema: [],
  18. messages: {
  19. unexpected: "Unexpected mustache. Use 'v-model' instead."
  20. }
  21. },
  22. /** @param {RuleContext} context */
  23. create(context) {
  24. return utils.defineTemplateBodyVisitor(context, {
  25. /** @param {VExpressionContainer} node */
  26. "VElement[rawName='textarea'] VExpressionContainer"(node) {
  27. if (node.parent.type !== 'VElement') {
  28. return
  29. }
  30. context.report({
  31. node,
  32. loc: node.loc,
  33. messageId: 'unexpected'
  34. })
  35. }
  36. })
  37. }
  38. }