1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

实现 连字符(脊柱式命名) Kebab Case / Spinal Case,驼峰脊柱式命名 Camel Kebab Case,连字符命名大写 Kebab Upper Case;完善测试用例;通过测试用例

This commit is contained in:
程序员小墨 2024-04-03 23:54:38 +08:00
parent e7b62379c9
commit 723d9148b9
8 changed files with 261 additions and 17 deletions

View File

@ -2,7 +2,7 @@
// 插件 id 及名称 // 插件 id 及名称
"name": "variable-conversion", "name": "variable-conversion",
"displayName": "Variable Conversion", "displayName": "Variable Conversion",
"description": "A variable naming conversion extension, support camel case, pascal case, kebab(spinal) case, snake case, snake upper case, upper case, lower case, camel snake case, and more. \n一个变量命名方式互相转换的 VSCode 插件,支持小驼峰(驼峰命名)、大驼峰(帕斯卡命名)、连字符(脊柱式命名)、下划线(蛇形命名)、驼峰蛇形命名、下划线大写、全大写、全小写等常用命名方式", "description": "A variable naming conversion extension, support camel case, pascal case, kebab(spinal) case, camel kebab case, kebab upper case, snake case, snake upper case, upper case, lower case, camel snake case, and more. \n一个变量命名方式互相转换的 VSCode 插件,支持小驼峰(驼峰命名)、大驼峰(帕斯卡命名)、连字符(脊柱式命名)、驼峰脊柱式命名、连字符命名大写、下划线(蛇形命名)、驼峰蛇形命名、下划线大写、全大写、全小写等常用命名方式",
// 版本号 // 版本号
"version": "0.0.1", "version": "0.0.1",
"engines": { "engines": {
@ -48,6 +48,14 @@
"command": "extension.toKebabCase", "command": "extension.toKebabCase",
"title": "连字符 / 脊柱式命名 (Kebab Case / Spinal Case) [ foo-bar ]" "title": "连字符 / 脊柱式命名 (Kebab Case / Spinal Case) [ foo-bar ]"
}, },
{
"command": "extension.toCamelKebabCase",
"title": "连字符命名大写 (Kebab Upper Case) [ Foo-Bar ]"
},
{
"command": "extension.toKebabUpperCase",
"title": "连字符命名大写 (Kebab Upper Case) [ FOO-BAR ]"
},
{ {
"command": "extension.toSnakeCase", "command": "extension.toSnakeCase",
"title": "下划线 / 蛇形命名 (Snake Case) [ foo_bar ]" "title": "下划线 / 蛇形命名 (Snake Case) [ foo_bar ]"
@ -100,6 +108,7 @@
// "enablement": "false" // "enablement": "false"
// } // }
], ],
// docs: https://code.visualstudio.com/docs/getstarted/keybindings#_accepted-keys
"keybindings": [ "keybindings": [
// 绑定快捷键 // 绑定快捷键
{ {
@ -137,7 +146,15 @@
}, },
{ {
"command": "extension.toKebabCase", "command": "extension.toKebabCase",
"group": "group-extension" "group": "group-kebab"
},
{
"command": "extension.toCamelKebabCase",
"group": "group-kebab"
},
{
"command": "extension.toKebabUpperCase",
"group": "group-kebab"
}, },
{ {
"command": "extension.toSnakeCase", "command": "extension.toSnakeCase",

View File

@ -1,7 +1,7 @@
{ {
"name": "variable-conversion", "name": "variable-conversion",
"displayName": "Variable Conversion", "displayName": "Variable Conversion",
"description": "A variable naming conversion extension, support camel case, pascal case, kebab(spinal) case, snake case, snake upper case, upper case, lower case, camel snake case, and more. \n一个变量命名方式互相转换的 VSCode 插件,支持小驼峰(驼峰命名)、大驼峰(帕斯卡命名)、连字符(脊柱式命名)、下划线(蛇形命名)、驼峰蛇形命名、下划线大写、全大写、全小写等常用命名方式", "description": "A variable naming conversion extension, support camel case, pascal case, kebab(spinal) case, camel kebab case, kebab upper case, snake case, snake upper case, upper case, lower case, camel snake case, and more. \n一个变量命名方式互相转换的 VSCode 插件,支持小驼峰(驼峰命名)、大驼峰(帕斯卡命名)、连字符(脊柱式命名)、驼峰脊柱式命名、连字符命名大写、下划线(蛇形命名)、驼峰蛇形命名、下划线大写、全大写、全小写等常用命名方式",
"version": "0.0.1", "version": "0.0.1",
"engines": { "engines": {
"vscode": "^1.87.0" "vscode": "^1.87.0"
@ -45,6 +45,14 @@
"command": "extension.toKebabCase", "command": "extension.toKebabCase",
"title": "连字符 / 脊柱式命名 (Kebab Case / Spinal Case) [ foo-bar ]" "title": "连字符 / 脊柱式命名 (Kebab Case / Spinal Case) [ foo-bar ]"
}, },
{
"command": "extension.toCamelKebabCase",
"title": "连字符命名大写 (Kebab Upper Case) [ Foo-Bar ]"
},
{
"command": "extension.toKebabUpperCase",
"title": "连字符命名大写 (Kebab Upper Case) [ FOO-BAR ]"
},
{ {
"command": "extension.toSnakeCase", "command": "extension.toSnakeCase",
"title": "下划线 / 蛇形命名 (Snake Case) [ foo_bar ]" "title": "下划线 / 蛇形命名 (Snake Case) [ foo_bar ]"
@ -97,7 +105,15 @@
}, },
{ {
"command": "extension.toKebabCase", "command": "extension.toKebabCase",
"group": "group-extension" "group": "group-kebab"
},
{
"command": "extension.toCamelKebabCase",
"group": "group-kebab"
},
{
"command": "extension.toKebabUpperCase",
"group": "group-kebab"
}, },
{ {
"command": "extension.toSnakeCase", "command": "extension.toSnakeCase",

View File

@ -76,6 +76,9 @@ export function activate(context: vscode.ExtensionContext) {
const commands: Array<{ command: string; convertFunction: ConvertFunction }> = [ const commands: Array<{ command: string; convertFunction: ConvertFunction }> = [
{ command: 'extension.toCamelCase', convertFunction: TextConversion.toCamelCase }, { command: 'extension.toCamelCase', convertFunction: TextConversion.toCamelCase },
{ command: 'extension.toPascalCase', convertFunction: TextConversion.toPascalCase }, { command: 'extension.toPascalCase', convertFunction: TextConversion.toPascalCase },
{ command: 'extension.toKebabCase', convertFunction: TextConversion.toKebabCase },
{ command: 'extension.toCamelKebabCase', convertFunction: TextConversion.toCamelKebabCase },
{ command: 'extension.toKebabUpperCase', convertFunction: TextConversion.toKebabUpperCase },
{ command: 'extension.toUpperCase', convertFunction: TextConversion.toUpperCase }, { command: 'extension.toUpperCase', convertFunction: TextConversion.toUpperCase },
{ command: 'extension.toLowerCase', convertFunction: TextConversion.toLowerCase }, { command: 'extension.toLowerCase', convertFunction: TextConversion.toLowerCase },
]; ];

View File

@ -72,6 +72,88 @@ export const toPascalCase: ConvertFunction = (str: string, eol: EOL): string =>
// return str.replace(/(^\w|_\w)/g, (g) => g.toUpperCase().replace('_', '')); // return str.replace(/(^\w|_\w)/g, (g) => g.toUpperCase().replace('_', ''));
}; };
/**
* / to Kebab Case / Spinal Case
*
* @param {string} str user selection
* @returns
* @since 2024-04-03
*/
export const toKebabCase: ConvertFunction = (str: string, eol: EOL): string => {
// Cut text 切割文本
const results: Array<TransformTextResult> = transformMutliLineText(str);
// console.log('results', results);
const transformedLines: Array<string> = [];
for (const result of results) {
const words = result.trimResult.split('|');
let isPreviousWordSpecial = true;
const transformedWords = [];
for (let index = 0; index < words.length; index++) {
const word = words[index];
const isCurrentWordSpecial = !/^[A-Za-z]+$/.test(word);
if (!isPreviousWordSpecial && !isCurrentWordSpecial) {
transformedWords.push('-');
}
transformedWords.push(word);
isPreviousWordSpecial = isCurrentWordSpecial;
}
const transformedLine = result.leadingSpace + transformedWords.join('') + result.trailingSpace;
transformedLines.push(transformedLine);
}
return transformedLines.join(eol);
};
/**
* to Camel Kebab Case
*
* @param {string} str user selection
* @returns
* @since 2024-04-03
*/
export const toCamelKebabCase: ConvertFunction = (str: string, eol: EOL): string => {
// Cut text 切割文本
const results: Array<TransformTextResult> = transformMutliLineText(str);
// console.log('results', results);
const transformedLines: Array<string> = [];
for (const result of results) {
const words = result.trimResult.split('|');
let isPreviousWordSpecial = true;
const transformedWords = [];
for (let index = 0; index < words.length; index++) {
const word = words[index];
const isCurrentWordSpecial = !/^[A-Za-z]+$/.test(word);
if (!isPreviousWordSpecial && !isCurrentWordSpecial) {
transformedWords.push('-');
}
const pascalCaseWord = word.charAt(0).toUpperCase() + word.slice(1);
transformedWords.push(pascalCaseWord);
isPreviousWordSpecial = isCurrentWordSpecial;
}
const transformedLine = result.leadingSpace + transformedWords.join('') + result.trailingSpace;
transformedLines.push(transformedLine);
}
return transformedLines.join(eol);
};
/**
* to Kebab Upper Case
*
* @param {string} str user selection
* @returns
* @since 2024-04-03
*/
export const toKebabUpperCase: ConvertFunction = (str: string, eol: EOL): string => {
return toKebabCase(str, eol).toUpperCase();
};
/** /**
* to Upper Case * to Upper Case
* *

View File

@ -6,7 +6,7 @@ import * as vscode from 'vscode';
import testGroups from './test-case'; import testGroups from './test-case';
import { TestCase, TestCaseGroup } from '../type-definition/test-case-type'; import { TestCase, TestCaseGroup } from '../type-definition/test-case-type';
import { transformMutliLineText, transformText } from '../main-code/variable-transform'; import { transformMutliLineText, transformText } from '../main-code/variable-transform';
import { toCamelCase, toLowerCase, toPascalCase, toUpperCase } from '../main-code/variable-conversion'; import { toCamelCase, toCamelKebabCase, toKebabCase, toKebabUpperCase, toLowerCase, toPascalCase, toUpperCase } from '../main-code/variable-conversion';
import { TransformTextResult } from '../type-definition/variable-transform-type'; import { TransformTextResult } from '../type-definition/variable-transform-type';
// import * as myExtension from '../../extension'; // import * as myExtension from '../../extension';
@ -59,6 +59,9 @@ suite('Extension Test: run test case', () => {
if (testCase.output.lowerCase !== undefined) { if (testCase.output.lowerCase !== undefined) {
assert.strictEqual(testCase.output.lowerCase, toLowerCase(input, eol)); assert.strictEqual(testCase.output.lowerCase, toLowerCase(input, eol));
} }
assert.strictEqual(testCase.output.kebabCase, toKebabCase(input, eol));
assert.strictEqual(testCase.output.camelkebabCase, toCamelKebabCase(input, eol));
assert.strictEqual(testCase.output.kebabUpperCase, toKebabUpperCase(input, eol));
} }
} }
}); });

View File

@ -21,6 +21,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: '', pascalCase: '',
upperCase: '', upperCase: '',
lowerCase: '', lowerCase: '',
kebabCase: '',
camelkebabCase: '',
kebabUpperCase: '',
}, },
}, },
{ {
@ -35,6 +38,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: ' ', pascalCase: ' ',
upperCase: ' ', upperCase: ' ',
lowerCase: ' ', lowerCase: ' ',
kebabCase: ' ',
camelkebabCase: ' ',
kebabUpperCase: ' ',
}, },
}, },
{ {
@ -50,6 +56,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: ' \r\n ', pascalCase: ' \r\n ',
upperCase: ' \r\n ', upperCase: ' \r\n ',
lowerCase: ' \r\n ', lowerCase: ' \r\n ',
kebabCase: ' \r\n ',
camelkebabCase: ' \r\n ',
kebabUpperCase: ' \r\n ',
}, },
}, },
{ {
@ -65,6 +74,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: ' X \r\nY ', pascalCase: ' X \r\nY ',
upperCase: ' X \r\nY ', upperCase: ' X \r\nY ',
lowerCase: ' x \r\ny ', lowerCase: ' x \r\ny ',
kebabCase: ' x \r\ny ',
camelkebabCase: ' X \r\nY ',
kebabUpperCase: ' X \r\nY ',
}, },
}, },
{ {
@ -80,6 +92,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: ' \n ', pascalCase: ' \n ',
upperCase: ' \n ', upperCase: ' \n ',
lowerCase: ' \n ', lowerCase: ' \n ',
kebabCase: ' \n ',
camelkebabCase: ' \n ',
kebabUpperCase: ' \n ',
}, },
}, },
{ {
@ -95,6 +110,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: ' A\nB ', pascalCase: ' A\nB ',
upperCase: ' A\nB ', upperCase: ' A\nB ',
lowerCase: ' a\nb ', lowerCase: ' a\nb ',
kebabCase: ' a\nb ',
camelkebabCase: ' A\nB ',
kebabUpperCase: ' A\nB ',
}, },
}, },
// 输入长文本 // 输入长文本
@ -120,6 +138,15 @@ const testGroups: Array<TestCaseGroup> = [
lowerCase: lowerCase:
"china's factory activity expanded in march after five consecutive months of contraction, an official survey revealed on sunday, adding to a run of indicators that suggest the stabilization of the world's second-largest economy." "china's factory activity expanded in march after five consecutive months of contraction, an official survey revealed on sunday, adding to a run of indicators that suggest the stabilization of the world's second-largest economy."
, ,
kebabCase:
"china's-factory-activity-expanded-in-march-after-five-consecutive-months-of-contraction,an-official-survey-revealed-on-sunday,adding-to-a-run-of-indicators-that-suggest-the-stabilization-of-the-world's-second-largest-economy."
,
camelkebabCase:
"China'S-Factory-Activity-Expanded-In-March-After-Five-Consecutive-Months-Of-Contraction,An-Official-Survey-Revealed-On-Sunday,Adding-To-A-Run-Of-Indicators-That-Suggest-The-Stabilization-Of-The-World'S-Second-Largest-Economy."
,
kebabUpperCase:
"CHINA'S-FACTORY-ACTIVITY-EXPANDED-IN-MARCH-AFTER-FIVE-CONSECUTIVE-MONTHS-OF-CONTRACTION,AN-OFFICIAL-SURVEY-REVEALED-ON-SUNDAY,ADDING-TO-A-RUN-OF-INDICATORS-THAT-SUGGEST-THE-STABILIZATION-OF-THE-WORLD'S-SECOND-LARGEST-ECONOMY."
,
}, },
}, },
// 输入包含数字 // 输入包含数字
@ -135,6 +162,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: 'Entity2Map', pascalCase: 'Entity2Map',
upperCase: 'ENTITY2MAP', upperCase: 'ENTITY2MAP',
lowerCase: 'entity2map', lowerCase: 'entity2map',
kebabCase: 'entity2map',
camelkebabCase: 'Entity2Map',
kebabUpperCase: 'ENTITY2MAP',
}, },
}, },
// 输入包含换行 // 输入包含换行
@ -153,6 +183,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: 'HowDoYou\bDo?\n HowDoYou\tDo!', pascalCase: 'HowDoYou\bDo?\n HowDoYou\tDo!',
upperCase: 'HOW DO YOU\bDO?\n HOW DO YOU\tDO!', upperCase: 'HOW DO YOU\bDO?\n HOW DO YOU\tDO!',
lowerCase: 'how do you\bdo?\n how do you\tdo!', lowerCase: 'how do you\bdo?\n how do you\tdo!',
kebabCase: 'how-do-you\bdo?\n how-do-you\tdo!',
camelkebabCase: 'How-Do-You\bDo?\n How-Do-You\tDo!',
kebabUpperCase: 'HOW-DO-YOU\bDO?\n HOW-DO-YOU\tDO!',
}, },
}, },
// 非英文字符,特殊字符 // 非英文字符,特殊字符
@ -170,6 +203,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: '今天是星期日', pascalCase: '今天是星期日',
upperCase: '今天是星期日', upperCase: '今天是星期日',
lowerCase: '今天是星期日', lowerCase: '今天是星期日',
kebabCase: '今天是星期日',
camelkebabCase: '今天是星期日',
kebabUpperCase: '今天是星期日',
}, },
}, },
{ {
@ -186,6 +222,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: '担心你DAf=Coffee—爸妈不在家— ', pascalCase: '担心你DAf=Coffee—爸妈不在家— ',
upperCase: '--担心你DAF_=COFFEE—爸妈不在家_— ', upperCase: '--担心你DAF_=COFFEE—爸妈不在家_— ',
lowerCase: '--担心你daf_=coffee—爸妈不在家_— ', lowerCase: '--担心你daf_=coffee—爸妈不在家_— ',
kebabCase: '担心你d-af=coffee—爸妈不在家— ',
camelkebabCase: '担心你D-Af=Coffee—爸妈不在家— ',
kebabUpperCase: '担心你D-AF=COFFEE—爸妈不在家— ',
}, },
}, },
{ {
@ -202,6 +241,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: '🥰ACup/OfCoffee🍻,Please!. ', pascalCase: '🥰ACup/OfCoffee🍻,Please!. ',
upperCase: '🥰 A-CUP/_OF COFFEE🍻,-_PLEASE!. ', upperCase: '🥰 A-CUP/_OF COFFEE🍻,-_PLEASE!. ',
lowerCase: '🥰 a-cup/_of coffee🍻,-_please!. ', lowerCase: '🥰 a-cup/_of coffee🍻,-_please!. ',
kebabCase: '🥰a-cup/of-coffee🍻,please!. ',
camelkebabCase: '🥰A-Cup/Of-Coffee🍻,Please!. ',
kebabUpperCase: '🥰A-CUP/OF-COFFEE🍻,PLEASE!. ',
}, },
}, },
{ {
@ -218,6 +260,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: 'TakeARest😊HaPPy,😢TriSte,Enfadado,驚きました,❤️,笑,😎COol,😳Embarrassed', pascalCase: 'TakeARest😊HaPPy,😢TriSte,Enfadado,驚きました,❤️,笑,😎COol,😳Embarrassed',
upperCase: 'TAKEAREST😊HAPPY,😢TRISTE,ENFADADO, 驚きました,❤️, 笑, 😎COOL, 😳-EMBARRASSED', upperCase: 'TAKEAREST😊HAPPY,😢TRISTE,ENFADADO, 驚きました,❤️, 笑, 😎COOL, 😳-EMBARRASSED',
lowerCase: 'takearest😊happy,😢triste,enfadado, 驚きました,❤️, 笑, 😎cool, 😳-embarrassed', lowerCase: 'takearest😊happy,😢triste,enfadado, 驚きました,❤️, 笑, 😎cool, 😳-embarrassed',
kebabCase: 'take-a-rest😊ha-p-py,😢tri-ste,enfadado,驚きました,❤️,笑,😎c-ool,😳embarrassed',
camelkebabCase: 'Take-A-Rest😊Ha-P-Py,😢Tri-Ste,Enfadado,驚きました,❤️,笑,😎C-Ool,😳Embarrassed',
kebabUpperCase: 'TAKE-A-REST😊HA-P-PY,😢TRI-STE,ENFADADO,驚きました,❤️,笑,😎C-OOL,😳EMBARRASSED',
}, },
}, },
{ {
@ -234,6 +279,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: ' NHDAs+90Usz&* ', pascalCase: ' NHDAs+90Usz&* ',
upperCase: ' NHDAS--+90-USZ&* ', upperCase: ' NHDAS--+90-USZ&* ',
lowerCase: ' nhdas--+90-usz&* ', lowerCase: ' nhdas--+90-usz&* ',
kebabCase: ' n-h-d-as+90usz&* ',
camelkebabCase: ' N-H-D-As+90Usz&* ',
kebabUpperCase: ' N-H-D-AS+90USZ&* ',
}, },
}, },
{ {
@ -250,6 +298,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: '担心你鸿DAf=Coffee—— ', pascalCase: '担心你鸿DAf=Coffee—— ',
upperCase: '--担心你鸿DAF_=COFFEE—_— ', upperCase: '--担心你鸿DAF_=COFFEE—_— ',
lowerCase: '--担心你鸿daf_=coffee—_— ', lowerCase: '--担心你鸿daf_=coffee—_— ',
kebabCase: '担心你鸿d-af=coffee—— ',
camelkebabCase: '担心你鸿D-Af=Coffee—— ',
kebabUpperCase: '担心你鸿D-AF=COFFEE—— ',
}, },
}, },
{ {
@ -266,6 +317,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: 'FsdiSdacsaf+Desd', pascalCase: 'FsdiSdacsaf+Desd',
upperCase: 'FSDI_SDACSAF+DESD', upperCase: 'FSDI_SDACSAF+DESD',
lowerCase: 'fsdi_sdacsaf+desd', lowerCase: 'fsdi_sdacsaf+desd',
kebabCase: 'fsdi-sdacsaf+desd',
camelkebabCase: 'Fsdi-Sdacsaf+Desd',
kebabUpperCase: 'FSDI-SDACSAF+DESD',
}, },
}, },
// add more cases... // add more cases...
@ -292,6 +346,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: 'FooBar', pascalCase: 'FooBar',
// upperCase: 'FOO--BAR', // upperCase: 'FOO--BAR',
// lowerCase: 'foo--bar', // lowerCase: 'foo--bar',
kebabCase: 'foo-bar',
camelkebabCase: 'Foo-Bar',
kebabUpperCase: 'FOO-BAR',
}, },
}, },
{ {
@ -313,6 +370,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: 'TestCase', pascalCase: 'TestCase',
// upperCase: 'TEST CASE', // upperCase: 'TEST CASE',
// lowerCase: 'test case', // lowerCase: 'test case',
kebabCase: 'test-case',
camelkebabCase: 'Test-Case',
kebabUpperCase: 'TEST-CASE',
}, },
}, },
{ {
@ -331,6 +391,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: 'Apple', pascalCase: 'Apple',
upperCase: 'APPLE', upperCase: 'APPLE',
lowerCase: 'apple', lowerCase: 'apple',
kebabCase: 'apple',
camelkebabCase: 'Apple',
kebabUpperCase: 'APPLE',
}, },
}, },
{ {
@ -347,6 +410,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: 'PineApple', pascalCase: 'PineApple',
upperCase: 'PINEAPPLE', upperCase: 'PINEAPPLE',
lowerCase: 'pineapple', lowerCase: 'pineapple',
kebabCase: 'pine-apple',
camelkebabCase: 'Pine-Apple',
kebabUpperCase: 'PINE-APPLE',
}, },
}, },
{ {
@ -372,6 +438,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: 'HaveANiceDay!', pascalCase: 'HaveANiceDay!',
// upperCase: 'HAVE A NICE DAY!', // upperCase: 'HAVE A NICE DAY!',
// lowerCase: 'have a nice day!', // lowerCase: 'have a nice day!',
kebabCase: 'have-a-nice-day!',
camelkebabCase: 'Have-A-Nice-Day!',
kebabUpperCase: 'HAVE-A-NICE-DAY!',
}, },
}, },
{ {
@ -395,6 +464,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: ' ANiceDay! ', pascalCase: ' ANiceDay! ',
// upperCase: ' A NICE DAY! ', // upperCase: ' A NICE DAY! ',
// lowerCase: ' a nice day! ', // lowerCase: ' a nice day! ',
kebabCase: ' a-nice-day! ',
camelkebabCase: ' A-Nice-Day! ',
kebabUpperCase: ' A-NICE-DAY! ',
}, },
}, },
{ {
@ -412,6 +484,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: ' ANiceDay', pascalCase: ' ANiceDay',
// upperCase: ' A NICE-DAY-', // upperCase: ' A NICE-DAY-',
// lowerCase: ' a nice-day-', // lowerCase: ' a nice-day-',
kebabCase: ' a-nice-day',
camelkebabCase: ' A-Nice-Day',
kebabUpperCase: ' A-NICE-DAY',
}, },
}, },
{ {
@ -428,6 +503,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: 'TomLikesEatIceCream.', pascalCase: 'TomLikesEatIceCream.',
upperCase: 'TOMLIKES EAT ICECREAM.', upperCase: 'TOMLIKES EAT ICECREAM.',
lowerCase: 'tomlikes eat icecream.', lowerCase: 'tomlikes eat icecream.',
kebabCase: 'tom-likes-eat-ice-cream.',
camelkebabCase: 'Tom-Likes-Eat-Ice-Cream.',
kebabUpperCase: 'TOM-LIKES-EAT-ICE-CREAM.',
}, },
}, },
{ {
@ -445,6 +523,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: ' Apple2Tree ', pascalCase: ' Apple2Tree ',
upperCase: ' APPLE2-TREE ', upperCase: ' APPLE2-TREE ',
lowerCase: ' apple2-tree ', lowerCase: ' apple2-tree ',
kebabCase: ' apple2tree ',
camelkebabCase: ' Apple2Tree ',
kebabUpperCase: ' APPLE2TREE ',
}, },
}, },
{ {
@ -461,6 +542,9 @@ const testGroups: Array<TestCaseGroup> = [
pascalCase: ' JuliusCaesar,WilliamShakespeare,AlbertEinstein,MarieCurie,WolfgangAmadeusMozart,VincentVanGogh. ', pascalCase: ' JuliusCaesar,WilliamShakespeare,AlbertEinstein,MarieCurie,WolfgangAmadeusMozart,VincentVanGogh. ',
upperCase: ' JULIUS_CAESAR, WILLIAM_SHAKESPEARE, ALBERT_EINSTEIN, MARIE_CURIE, WOLFGANGAMADEUSMOZART, VINCENT-VAN-GOGH. ', upperCase: ' JULIUS_CAESAR, WILLIAM_SHAKESPEARE, ALBERT_EINSTEIN, MARIE_CURIE, WOLFGANGAMADEUSMOZART, VINCENT-VAN-GOGH. ',
lowerCase: ' julius_caesar, william_shakespeare, albert_einstein, marie_curie, wolfgangamadeusmozart, vincent-van-gogh. ', lowerCase: ' julius_caesar, william_shakespeare, albert_einstein, marie_curie, wolfgangamadeusmozart, vincent-van-gogh. ',
kebabCase: ' julius-caesar,william-shakespeare,albert-einstein,marie-curie,wolfgang-amadeus-mozart,vincent-van-gogh. ',
camelkebabCase: ' Julius-Caesar,William-Shakespeare,Albert-Einstein,Marie-Curie,Wolfgang-Amadeus-Mozart,Vincent-Van-Gogh. ',
kebabUpperCase: ' JULIUS-CAESAR,WILLIAM-SHAKESPEARE,ALBERT-EINSTEIN,MARIE-CURIE,WOLFGANG-AMADEUS-MOZART,VINCENT-VAN-GOGH. ',
}, },
}, },
{ {
@ -491,6 +575,18 @@ const testGroups: Array<TestCaseGroup> = [
' &quot;you&quot; (or &quot;your&quot;) shall mean an individual or legal entity\n' + ' &quot;you&quot; (or &quot;your&quot;) shall mean an individual or legal entity\n' +
' exercising permissions granted by this license.' ' exercising permissions granted by this license.'
, ,
kebabCase:
' &quot;you&quot;(or&quot;your&quot;)shall-mean-an-individual-or-legal-entity\n' +
' exercising-permissions-granted-by-this-license.'
,
camelkebabCase:
' &Quot;You&Quot;(Or&Quot;Your&Quot;)Shall-Mean-An-Individual-Or-Legal-Entity\n' +
' Exercising-Permissions-Granted-By-This-License.'
,
kebabUpperCase:
' &QUOT;YOU&QUOT;(OR&QUOT;YOUR&QUOT;)SHALL-MEAN-AN-INDIVIDUAL-OR-LEGAL-ENTITY\n' +
' EXERCISING-PERMISSIONS-GRANTED-BY-THIS-LICENSE.'
,
}, },
}, },
// add more cases... // add more cases...
@ -522,6 +618,9 @@ const testGroups: Array<TestCaseGroup> = [
// pascalCase: '', // pascalCase: '',
// upperCase: '', // upperCase: '',
// lowerCase: '', // lowerCase: '',
// kebabCase: '',
// camelkebabCase: '',
// kebabUpperCase: '',
// }, // },
// }, // },
// add more cases... // add more cases...

View File

@ -8,6 +8,7 @@
* Test: * Test:
* - Add test case type definition in src/type-definition/test-case-type.ts * - Add test case type definition in src/type-definition/test-case-type.ts
* - Add test case in src/test/test-case.ts * - Add test case in src/test/test-case.ts
* - Add test code in src/test/extension.test.ts
* *
* Docs: * Docs:
* - Add type definition in below `SupportCase` enum * - Add type definition in below `SupportCase` enum
@ -46,6 +47,26 @@ export enum SupportCase {
*/ */
KEBAB_CASE, KEBAB_CASE,
/**
*
* Camel Kebab Case
* e.g. Foo-Bar
*
* @alias: camelkebabCase / CamelKebabCase / camel kebab case / camel_kebab_case / CAMEL_UPPER_CASE
* @since 2024-04-03
*/
CAMEL_UPPER_CASE,
/**
*
* Kebab Upper Case
* e.g. FOO-BAR
*
* @alias: kebabUpperCase / KebabUpperCase / kebab upper case / kebab_upper_case / KEBAB_UPPER_CASE
* @since 2024-04-03
*/
KEBAB_UPPER_CASE,
/** /**
* 线 / * 线 /
* Snake Case * Snake Case

View File

@ -16,5 +16,8 @@ export type TestCase = {
pascalCase: string pascalCase: string
upperCase?: string upperCase?: string
lowerCase?: string lowerCase?: string
kebabCase: string
camelkebabCase: string
kebabUpperCase: string
} }
}; };