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