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.
41 lines
1.1 KiB
41 lines
1.1 KiB
/**
|
|
* @author Przemyslaw Falowski (@przemkow)
|
|
* @fileoverview This rule checks whether v-model used on custom component do not have an argument
|
|
*/
|
|
'use strict'
|
|
|
|
const utils = require('../utils')
|
|
|
|
module.exports = {
|
|
meta: {
|
|
type: 'problem',
|
|
docs: {
|
|
description:
|
|
'disallow adding an argument to `v-model` used in custom component',
|
|
categories: ['essential'],
|
|
url: 'https://eslint.vuejs.org/rules/no-v-model-argument.html'
|
|
},
|
|
fixable: null,
|
|
schema: [],
|
|
messages: {
|
|
vModelRequireNoArgument: "'v-model' directives require no argument."
|
|
}
|
|
},
|
|
/** @param {RuleContext} context */
|
|
create(context) {
|
|
return utils.defineTemplateBodyVisitor(context, {
|
|
/** @param {VDirective} node */
|
|
"VAttribute[directive=true][key.name.name='model']"(node) {
|
|
const element = node.parent.parent
|
|
|
|
if (node.key.argument && utils.isCustomComponent(element)) {
|
|
context.report({
|
|
node,
|
|
loc: node.loc,
|
|
messageId: 'vModelRequireNoArgument'
|
|
})
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|