no-textarea-mustache.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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: 'disallow mustaches in `<textarea>`',
  19. categories: ['vue3-essential', 'essential'],
  20. url: 'https://eslint.vuejs.org/rules/no-textarea-mustache.html'
  21. },
  22. fixable: null,
  23. schema: []
  24. },
  25. /** @param {RuleContext} context */
  26. create(context) {
  27. return utils.defineTemplateBodyVisitor(context, {
  28. /** @param {VExpressionContainer} node */
  29. "VElement[name='textarea'] VExpressionContainer"(node) {
  30. if (node.parent.type !== 'VElement') {
  31. return
  32. }
  33. context.report({
  34. node,
  35. loc: node.loc,
  36. message: "Unexpected mustache. Use 'v-model' instead."
  37. })
  38. }
  39. })
  40. }
  41. }