no-deprecated-html-element-is.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 the `is` attribute on HTML elements (in Vue.js 3.0.0+)',
  19. categories: ['vue3-essential'],
  20. url: 'https://eslint.vuejs.org/rules/no-deprecated-html-element-is.html'
  21. },
  22. fixable: null,
  23. schema: [],
  24. messages: {
  25. unexpected: 'The `is` attribute on HTML element are deprecated.'
  26. }
  27. },
  28. /** @param {RuleContext} context */
  29. create(context) {
  30. return utils.defineTemplateBodyVisitor(context, {
  31. /** @param {VDirective | VAttribute} node */
  32. "VAttribute[directive=true][key.name.name='bind'][key.argument.name='is'], VAttribute[directive=false][key.name='is']"(
  33. node
  34. ) {
  35. const element = node.parent.parent
  36. if (
  37. !utils.isHtmlWellKnownElementName(element.rawName) &&
  38. !utils.isSvgWellKnownElementName(element.rawName)
  39. ) {
  40. return
  41. }
  42. context.report({
  43. node,
  44. loc: node.loc,
  45. messageId: 'unexpected'
  46. })
  47. }
  48. })
  49. }
  50. }