We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
vue/attribute-hyphenation
.sync
Checklist
Tell us about your environment
Please show your full configuration:
I'am using antfu's @antfu/eslint-config
** Remember I've set the vue/v-on-event-hyphenation rule's config autofix tobe false.**
vue/v-on-event-hyphenation
autofix
false
import eslint from '@antfu/eslint-config'; export default eslint({ rules: { 'vue/attribute-hyphenation': ['error', 'never'], 'vue/v-on-event-hyphenation': ['error', 'never', { autofix: false }], }, vue: { vueVersion: 2, }, });
What did you do?
Suppose this:
<Hi :my-name.sync="name" />
Then running eslint . --fix
eslint . --fix
After the autofix of vue/attribute-hyphenation, code becomes:
<Hi :myName.sync="name" />
This code should not be autofixed, because .sync means this is actually a shorthand of:
<Hi :my-name="name" @update:my-name="name = $event" />
When it's autofixed to the this code:
It means:
<Hi :myName="name" @update:myName="name = $event" />
And this autofixed code would break, because the event name should be update:my-name, instead of update:myName.
update:my-name
update:myName
eslint-plugin-vue/lib/rules/attribute-hyphenation.js
Lines 99 to 108 in 66e3201
Maybe we can add another .sync check here(willing to contribute a PR for this), for example:
fix: (fixer) => { if (text.includes('_')) { return null } if (/^[A-Z]/.test(name)) { return null } + if(text.endsWith('.sync')) { + return null + } return fixer.replaceText( node.key, text.replace(name, caseConverter(name)) ) }
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
Checklist
Tell us about your environment
Please show your full configuration:
I'am using antfu's @antfu/eslint-config
** Remember I've set the
vue/v-on-event-hyphenation
rule's configautofix
tobefalse
.**What did you do?
Suppose this:
Then running
eslint . --fix
After the autofix of
vue/attribute-hyphenation
, code becomes:This code should not be autofixed, because
.sync
means this is actually a shorthand of:When it's autofixed to the this code:
It means:
And this autofixed code would break, because the event name should be
update:my-name
, instead ofupdate:myName
.Might be solution
eslint-plugin-vue/lib/rules/attribute-hyphenation.js
Lines 99 to 108 in 66e3201
Maybe we can add another
.sync
check here(willing to contribute a PR for this), for example:The text was updated successfully, but these errors were encountered: