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.

60 lines
1.6 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 v-text / v-html on component',
// TODO We will change it in the next major version.
// categories: ['essential', 'vue3-essential'],
categories: undefined,
url: 'https://eslint.vuejs.org/rules/no-v-text-v-html-on-component.html'
},
fixable: null,
schema: [],
messages: {
disallow:
"Using {{directiveName}} on component may break component's content."
}
},
/** @param {RuleContext} context */
create(context) {
/**
* Verify for v-text and v-html directive
* @param {VDirective} node
*/
function verify(node) {
const element = node.parent.parent
if (utils.isCustomComponent(element)) {
context.report({
node,
loc: node.loc,
messageId: 'disallow',
data: {
directiveName: `v-${node.key.name.name}`
}
})
}
}
return utils.defineTemplateBodyVisitor(context, {
"VAttribute[directive=true][key.name.name='text']": verify,
"VAttribute[directive=true][key.name.name='html']": verify
})
}
}