1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- 'use strict'
- const utils = require('../utils')
- module.exports = {
- meta: {
- type: 'problem',
- docs: {
- description: 'disallow v-text / v-html on component',
-
-
- 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."
- }
- },
-
- create(context) {
-
- 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
- })
- }
- }
|