diff --git a/lib/rules/prop-name-casing.js b/lib/rules/prop-name-casing.js index 826197313..5ee9b78f1 100644 --- a/lib/rules/prop-name-casing.js +++ b/lib/rules/prop-name-casing.js @@ -24,20 +24,8 @@ function create(context) { return utils.executeOnVue(context, (obj) => { for (const item of utils.getComponentProps(obj)) { - if (item.propName == null) { - continue - } - const propName = - item.key.type === 'Literal' - ? item.key.value - : item.key.type === 'TemplateLiteral' - ? null - : item.propName - // TODO We should use propName. - // const propName = item.propName - - if (typeof propName !== 'string') { - // (boolean | null | number | RegExp) Literal + const propName = item.propName + if (propName == null) { continue } if (!checker(propName)) { diff --git a/tests/lib/rules/prop-name-casing.js b/tests/lib/rules/prop-name-casing.js index eb932b299..4815c4ebf 100644 --- a/tests/lib/rules/prop-name-casing.js +++ b/tests/lib/rules/prop-name-casing.js @@ -131,18 +131,6 @@ ruleTester.run('prop-name-casing', rule, { `, parserOptions }, - { - // TemplateLiteral computed property does not warn - filename: 'test.vue', - code: ` - export default { - props: { - [\`greeting-text\`]: String - } - } - `, - parserOptions - }, { // TemplateLiteral computed property does not warn filename: 'test.vue', @@ -275,18 +263,6 @@ ruleTester.run('prop-name-casing', rule, { `, parserOptions }, - { - // RegExp Literal computed property name - filename: 'test.vue', - code: ` - export default { - props: { - [/greeting-text/]: String - } - } - `, - parserOptions - }, { // Japanese characters filename: 'test.vue', @@ -578,6 +554,32 @@ ruleTester.run('prop-name-casing', rule, { options: ['snake_case'], parserOptions, errors: ['Prop "_itemName" is not in snake_case.'] + }, + { + // TemplateLiteral computed property + filename: 'test.vue', + code: ` + export default { + props: { + [\`greeting-text\`]: String + } + } + `, + parserOptions, + errors: ['Prop "greeting-text" is not in camelCase.'] + }, + { + // RegExp Literal computed property name + filename: 'test.vue', + code: ` + export default { + props: { + [/greeting-text/]: String + } + } + `, + parserOptions, + errors: ['Prop "/greeting-text/" is not in camelCase.'] } ] })