From ddc0525f5a74460b4225819ddc28ae383d1eb060 Mon Sep 17 00:00:00 2001
From: kricsleo <32707098+kricsleo@users.noreply.github.com>
Date: Mon, 2 Sep 2024 17:52:42 +0800
Subject: [PATCH] fix(attribute-hyphenation): skip auto-fix when suffixed with
`.sync` (#2533)
---
lib/rules/attribute-hyphenation.js | 4 +++
tests/lib/rules/attribute-hyphenation.js | 36 ++++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/lib/rules/attribute-hyphenation.js b/lib/rules/attribute-hyphenation.js
index 0ef2a0420..54ac77791 100644
--- a/lib/rules/attribute-hyphenation.js
+++ b/lib/rules/attribute-hyphenation.js
@@ -101,6 +101,10 @@ module.exports = {
return null
}
+ if (text.endsWith('.sync')) {
+ return null
+ }
+
if (/^[A-Z]/.test(name)) {
return null
}
diff --git a/tests/lib/rules/attribute-hyphenation.js b/tests/lib/rules/attribute-hyphenation.js
index 4d867d15e..16f6e4e10 100644
--- a/tests/lib/rules/attribute-hyphenation.js
+++ b/tests/lib/rules/attribute-hyphenation.js
@@ -70,6 +70,16 @@ ruleTester.run('attribute-hyphenation', rule, {
filename: 'test.vue',
code: '
',
options: ['never']
+ },
+ {
+ filename: 'test.vue',
+ code: '
',
+ options: ['always']
+ },
+ {
+ filename: 'test.vue',
+ code: '
',
+ options: ['never']
}
],
@@ -367,6 +377,32 @@ ruleTester.run('attribute-hyphenation', rule, {
line: 1
}
]
+ },
+ {
+ filename: 'test.vue',
+ code: '
',
+ output: null,
+ options: ['always'],
+ errors: [
+ {
+ message: "Attribute ':myAge.sync' must be hyphenated.",
+ type: 'VDirectiveKey',
+ line: 1
+ }
+ ]
+ },
+ {
+ filename: 'test.vue',
+ code: '
',
+ output: null,
+ options: ['never'],
+ errors: [
+ {
+ message: "Attribute ':my-age.sync' can't be hyphenated.",
+ type: 'VDirectiveKey',
+ line: 1
+ }
+ ]
}
]
})