no-deprecated-vue-config-keycodes.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * @author Yosuke Ota
  3. * See LICENSE file in root directory for full license.
  4. */
  5. 'use strict'
  6. const utils = require('../utils')
  7. // ------------------------------------------------------------------------------
  8. // Rule Definition
  9. // ------------------------------------------------------------------------------
  10. module.exports = {
  11. meta: {
  12. type: 'problem',
  13. docs: {
  14. description:
  15. 'disallow using deprecated `Vue.config.keyCodes` (in Vue.js 3.0.0+)',
  16. categories: ['vue3-essential'],
  17. url: 'https://eslint.vuejs.org/rules/no-deprecated-vue-config-keycodes.html'
  18. },
  19. fixable: null,
  20. schema: [],
  21. messages: {
  22. unexpected: '`Vue.config.keyCodes` are deprecated.'
  23. }
  24. },
  25. /** @param {RuleContext} context */
  26. create(context) {
  27. return {
  28. /** @param {MemberExpression} node */
  29. "MemberExpression[property.type='Identifier'][property.name='keyCodes']"(
  30. node
  31. ) {
  32. const config = utils.skipChainExpression(node.object)
  33. if (
  34. config.type !== 'MemberExpression' ||
  35. config.property.type !== 'Identifier' ||
  36. config.property.name !== 'config' ||
  37. config.object.type !== 'Identifier' ||
  38. config.object.name !== 'Vue'
  39. ) {
  40. return
  41. }
  42. context.report({
  43. node,
  44. messageId: 'unexpected'
  45. })
  46. }
  47. }
  48. }
  49. }