Skip to content

Commit

Permalink
fix(attribute-hyphenation): skip auto-fix when suffixed with .sync (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
kricsleo authored Sep 2, 2024
1 parent a4aed0a commit ddc0525
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rules/attribute-hyphenation.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ module.exports = {
return null
}

if (text.endsWith('.sync')) {
return null
}

if (/^[A-Z]/.test(name)) {
return null
}
Expand Down
36 changes: 36 additions & 0 deletions tests/lib/rules/attribute-hyphenation.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ ruleTester.run('attribute-hyphenation', rule, {
filename: 'test.vue',
code: '<template><div><custom :attr_ff="prop"></custom></div></template>',
options: ['never']
},
{
filename: 'test.vue',
code: '<template><div><custom :my-name.sync="prop"></custom></div></template>',
options: ['always']
},
{
filename: 'test.vue',
code: '<template><div><custom :myName.sync="prop"></custom></div></template>',
options: ['never']
}
],

Expand Down Expand Up @@ -367,6 +377,32 @@ ruleTester.run('attribute-hyphenation', rule, {
line: 1
}
]
},
{
filename: 'test.vue',
code: '<template><div><custom :myAge.sync="prop"></custom></div></template>',
output: null,
options: ['always'],
errors: [
{
message: "Attribute ':myAge.sync' must be hyphenated.",
type: 'VDirectiveKey',
line: 1
}
]
},
{
filename: 'test.vue',
code: '<template><div><custom :my-age.sync="prop"></custom></div></template>',
output: null,
options: ['never'],
errors: [
{
message: "Attribute ':my-age.sync' can't be hyphenated.",
type: 'VDirectiveKey',
line: 1
}
]
}
]
})

0 comments on commit ddc0525

Please sign in to comment.