Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix(attribute-hyphenation): apply to v-model directive #2511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 2, 2024
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 2 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 2 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 47 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
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.