From 1b4b3dbf5a584daa99162371514f970b92c6c975 Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Tue, 9 Feb 2021 16:50:27 +0900 Subject: [PATCH] Improved autofix of vue/no-deprecated-slot-attribute rule when slot name contains `_`. --- lib/rules/syntaxes/slot-attribute.js | 4 +- .../lib/rules/no-deprecated-slot-attribute.js | 57 +++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/lib/rules/syntaxes/slot-attribute.js b/lib/rules/syntaxes/slot-attribute.js index 1ce27484d..8b4392746 100644 --- a/lib/rules/syntaxes/slot-attribute.js +++ b/lib/rules/syntaxes/slot-attribute.js @@ -23,8 +23,8 @@ module.exports = { return true } const slotName = slotAttr.value.value - // If non-Latin characters are included it can not be converted. - return !/[^a-z]/i.test(slotName) + // If other than alphanumeric, underscore and hyphen characters are included it can not be converted. + return !/[^\w\-]/u.test(slotName) } /** diff --git a/tests/lib/rules/no-deprecated-slot-attribute.js b/tests/lib/rules/no-deprecated-slot-attribute.js index 4d75508a4..ab08c4aff 100644 --- a/tests/lib/rules/no-deprecated-slot-attribute.js +++ b/tests/lib/rules/no-deprecated-slot-attribute.js @@ -348,6 +348,63 @@ tester.run('no-deprecated-slot-attribute', rule, { line: 4 } ] + }, + { + code: ` + `, + output: ` + `, + errors: ['`slot` attributes are deprecated.'] + }, + { + code: ` + `, + output: ` + `, + errors: ['`slot` attributes are deprecated.'] + }, + { + code: ` + `, + output: ` + `, + errors: ['`slot` attributes are deprecated.'] } ] })