1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- /**
- * @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
- })
- }
- }
|