v-model-custom-modifiers.js 933 B

123456789101112131415161718192021222324252627282930313233
  1. /**
  2. * @author Yosuke Ota
  3. * See LICENSE file in root directory for full license.
  4. */
  5. 'use strict'
  6. // ------------------------------------------------------------------------------
  7. // Helpers
  8. // ------------------------------------------------------------------------------
  9. const BUILTIN_MODIFIERS = new Set(['lazy', 'number', 'trim'])
  10. module.exports = {
  11. supported: '>=3.0.0',
  12. /** @param {RuleContext} context @returns {TemplateListener} */
  13. createTemplateBodyVisitor(context) {
  14. return {
  15. /** @param {VDirectiveKey} node */
  16. "VAttribute[directive=true] > VDirectiveKey[name.name='model'][modifiers.length>0]"(
  17. node
  18. ) {
  19. for (const modifier of node.modifiers) {
  20. if (!BUILTIN_MODIFIERS.has(modifier.name)) {
  21. context.report({
  22. node: modifier,
  23. messageId: 'forbiddenVModelCustomModifiers'
  24. })
  25. }
  26. }
  27. }
  28. }
  29. }
  30. }