From d1badcea15ca7fd645de737ce8c78debdaa43f98 Mon Sep 17 00:00:00 2001 From: waynzh Date: Fri, 19 Jul 2024 15:59:33 +0800 Subject: [PATCH 1/2] fix(attribute-hyphenation): apply to v-model directive --- lib/rules/attribute-hyphenation.js | 2 +- tests/lib/rules/attribute-hyphenation.js | 47 ++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/lib/rules/attribute-hyphenation.js b/lib/rules/attribute-hyphenation.js index 0ef2a0420..99861c1e4 100644 --- a/lib/rules/attribute-hyphenation.js +++ b/lib/rules/attribute-hyphenation.js @@ -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' ) { diff --git a/tests/lib/rules/attribute-hyphenation.js b/tests/lib/rules/attribute-hyphenation.js index 4d867d15e..c29479eb2 100644 --- a/tests/lib/rules/attribute-hyphenation.js +++ b/tests/lib/rules/attribute-hyphenation.js @@ -26,6 +26,11 @@ ruleTester.run('attribute-hyphenation', rule, { code: '', options: ['always'] }, + { + filename: 'test.vue', + code: '', + options: ['always'] + }, { filename: 'test.vue', code: '', @@ -209,6 +214,48 @@ ruleTester.run('attribute-hyphenation', rule, { } ] }, + { + // https://github.com/vuejs/eslint-plugin-vue/issues/2510 + filename: 'test.vue', + code: '', + output: + '', + options: ['never'], + errors: [ + { + message: "Attribute 'v-model:my-prop' can't be hyphenated.", + type: 'VDirectiveKey', + line: 1 + } + ] + }, + { + filename: 'test.vue', + code: '', + output: + '', + options: ['always'], + errors: [ + { + message: "Attribute 'v-model:myProp' must be hyphenated.", + type: 'VDirectiveKey', + line: 1 + } + ] + }, + { + filename: 'test.vue', + code: '', + output: null, + options: ['always'], + errors: [ + { + message: "Attribute 'v-model:MyProp' must be hyphenated.", + type: 'VDirectiveKey', + line: 1 + } + ] + }, { filename: 'test.vue', code: ` From ec923fb2346a2f34bf8702c1d061b7583c60c94e Mon Sep 17 00:00:00 2001 From: waynzh Date: Fri, 19 Jul 2024 16:33:20 +0800 Subject: [PATCH 2/2] chore: lint fix --- lib/rules/require-prop-types.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rules/require-prop-types.js b/lib/rules/require-prop-types.js index 4102ad039..af2a956a4 100644 --- a/lib/rules/require-prop-types.js +++ b/lib/rules/require-prop-types.js @@ -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