Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rules/attribute-hyphenation.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function getAttributeName(node) {
}

if (
node.key.name.name === 'bind' &&
(node.key.name.name === 'bind' || node.key.name.name === 'model') &&
node.key.argument &&
node.key.argument.type === 'VIdentifier'
) {
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/require-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ module.exports = {
return
}
const hasType =
prop.type === 'array' ? false : optionHasType(prop.value) ?? true
prop.type === 'array' ? false : (optionHasType(prop.value) ?? true)

if (!hasType) {
const { node, propName } = prop
Expand Down
47 changes: 47 additions & 0 deletions tests/lib/rules/attribute-hyphenation.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ ruleTester.run('attribute-hyphenation', rule, {
code: '<template><div><custom data-id="foo" aria-test="bar" slot-scope="{ data }" my-prop="prop"></custom></div></template>',
options: ['always']
},
{
filename: 'test.vue',
code: '<template><div><custom :my-prop="prop" v-model:foo-bar="fooBar"></custom></div></template>',
options: ['always']
},
{
filename: 'test.vue',
code: '<template><div><custom data-id="foo" aria-test="bar" slot-scope="{ data }" myProp="prop"></custom></div></template>',
Expand Down Expand Up @@ -209,6 +214,48 @@ ruleTester.run('attribute-hyphenation', rule, {
}
]
},
{
// https://github.com/vuejs/eslint-plugin-vue/issues/2510
filename: 'test.vue',
code: '<template><div><custom v-model:my-prop="prop"></custom></div></template>',
output:
'<template><div><custom v-model:myProp="prop"></custom></div></template>',
options: ['never'],
errors: [
{
message: "Attribute 'v-model:my-prop' can't be hyphenated.",
type: 'VDirectiveKey',
line: 1
}
]
},
{
filename: 'test.vue',
code: '<template><div><custom v-model:myProp="prop"></custom></div></template>',
output:
'<template><div><custom v-model:my-prop="prop"></custom></div></template>',
options: ['always'],
errors: [
{
message: "Attribute 'v-model:myProp' must be hyphenated.",
type: 'VDirectiveKey',
line: 1
}
]
},
{
filename: 'test.vue',
code: '<template><div><custom v-model:MyProp="prop"></custom></div></template>',
output: null,
options: ['always'],
errors: [
{
message: "Attribute 'v-model:MyProp' must be hyphenated.",
type: 'VDirectiveKey',
line: 1
}
]
},
{
filename: 'test.vue',
code: `
Expand Down