no-deprecated-v-on-native-modifier.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * @author Yosuke Ota
  3. * See LICENSE file in root directory for full license.
  4. */
  5. 'use strict'
  6. // ------------------------------------------------------------------------------
  7. // Requirements
  8. // ------------------------------------------------------------------------------
  9. const utils = require('../utils')
  10. // ------------------------------------------------------------------------------
  11. // Rule Definition
  12. // ------------------------------------------------------------------------------
  13. module.exports = {
  14. meta: {
  15. type: 'problem',
  16. docs: {
  17. description:
  18. 'disallow using deprecated `.native` modifiers (in Vue.js 3.0.0+)',
  19. categories: ['vue3-essential'],
  20. url: 'https://eslint.vuejs.org/rules/no-deprecated-v-on-native-modifier.html'
  21. },
  22. fixable: null,
  23. schema: [],
  24. messages: {
  25. deprecated: "'.native' modifier on 'v-on' directive is deprecated."
  26. }
  27. },
  28. /** @param {RuleContext} context */
  29. create(context) {
  30. return utils.defineTemplateBodyVisitor(context, {
  31. /** @param {VIdentifier & {parent:VDirectiveKey} } node */
  32. "VAttribute[directive=true][key.name.name='on'] > VDirectiveKey > VIdentifier[name='native']"(
  33. node
  34. ) {
  35. const key = node.parent
  36. if (!key.modifiers.includes(node)) return
  37. context.report({
  38. node,
  39. messageId: 'deprecated'
  40. })
  41. }
  42. })
  43. }
  44. }