vue hello world项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.0 KiB

3 years ago
/**
* @author Yosuke Ota
* See LICENSE file in root directory for full license.
*/
'use strict'
// ------------------------------------------------------------------------------
// Requirements
// ------------------------------------------------------------------------------
const utils = require('../utils')
// ------------------------------------------------------------------------------
// Rule Definition
// ------------------------------------------------------------------------------
module.exports = {
meta: {
type: 'problem',
docs: {
description:
'disallow using deprecated the `is` attribute on HTML elements (in Vue.js 3.0.0+)',
categories: ['vue3-essential'],
url: 'https://eslint.vuejs.org/rules/no-deprecated-html-element-is.html'
},
fixable: null,
schema: [],
messages: {
unexpected: 'The `is` attribute on HTML element are deprecated.'
}
},
/** @param {RuleContext} context */
create(context) {
/** @param {VElement} node */
function isValidElement(node) {
return (
!utils.isHtmlWellKnownElementName(node.rawName) &&
!utils.isSvgWellKnownElementName(node.rawName)
)
}
return utils.defineTemplateBodyVisitor(context, {
/** @param {VDirective} node */
"VAttribute[directive=true][key.name.name='bind'][key.argument.name='is']"(
node
) {
if (isValidElement(node.parent.parent)) {
return
}
context.report({
node,
loc: node.loc,
messageId: 'unexpected'
})
},
/** @param {VAttribute} node */
"VAttribute[directive=false][key.name='is']"(node) {
if (isValidElement(node.parent.parent)) {
return
}
if (node.value && node.value.value.startsWith('vue:')) {
// Usage on native elements 3.1+
return
}
context.report({
node,
loc: node.loc,
messageId: 'unexpected'
})
}
})
}
}