diff --git a/projects/standard-rulesets/src/naming-changes/__tests__/__snapshots__/naming-changes.test.ts.snap b/projects/standard-rulesets/src/naming-changes/__tests__/__snapshots__/naming-changes.test.ts.snap index 816f9c3058..1af854f4bd 100644 --- a/projects/standard-rulesets/src/naming-changes/__tests__/__snapshots__/naming-changes.test.ts.snap +++ b/projects/standard-rulesets/src/naming-changes/__tests__/__snapshots__/naming-changes.test.ts.snap @@ -2068,4 +2068,4 @@ exports[`naming changes configuration naming change configuration validation 2`] exports[`naming changes configuration naming change configuration validation 3`] = `"Expected config.applies in NamingChangesRuleset to be specified and be one of added, addedOrChanged, always"`; -exports[`naming changes configuration naming change configuration validation 4`] = `"Expected casing option to be one of snake_case, camelCase, Capital-Param-Case, param-case, PascalCase, received not a valid format for queryParameters"`; +exports[`naming changes configuration naming change configuration validation 4`] = `"Expected casing option to be one of snake_case, camelCase, Capital-Param-Case, param-case, PascalCase, case-insensitive-param-case, received not a valid format for queryParameters"`; diff --git a/projects/standard-rulesets/src/naming-changes/__tests__/is-case.test.ts b/projects/standard-rulesets/src/naming-changes/__tests__/is-case.test.ts index a82f6e45c3..88d7dd0a33 100644 --- a/projects/standard-rulesets/src/naming-changes/__tests__/is-case.test.ts +++ b/projects/standard-rulesets/src/naming-changes/__tests__/is-case.test.ts @@ -134,4 +134,29 @@ describe('isCase', () => { expect(isCase(failingCase, 'PascalCase')).toBe(false); } }); + + test('case-insensitive-param-case', () => { + const passingCases = [ + 'kebab-case-For-fun', + 'snake', + 'kebabwithoutfriends', + 'param1-Wwit2h-num3bers', + '1param-2with-Leading-number', + ]; + const failingCases = [ + '', + 'some-kebab-someCamel', + 'some-AeAab-someCamel', + 'camelCase', + 'snake_case_for_fun', + ]; + for (const passingCase of passingCases) { + console.log(passingCase); + expect(isCase(passingCase, 'case-insensitive-param-case')).toBe(true); + } + + for (const failingCase of failingCases) { + expect(isCase(failingCase, 'case-insensitive-param-case')).toBe(false); + } + }); }); diff --git a/projects/standard-rulesets/src/naming-changes/constants.ts b/projects/standard-rulesets/src/naming-changes/constants.ts index f2cb0f3bd7..1c14871a80 100644 --- a/projects/standard-rulesets/src/naming-changes/constants.ts +++ b/projects/standard-rulesets/src/naming-changes/constants.ts @@ -4,6 +4,7 @@ export const casing = [ 'Capital-Param-Case', 'param-case', 'PascalCase', + 'case-insensitive-param-case', ] as const; export const appliesWhen = ['added', 'addedOrChanged', 'always'] as const; diff --git a/projects/standard-rulesets/src/naming-changes/isCase.ts b/projects/standard-rulesets/src/naming-changes/isCase.ts index a90cd167fd..56e9da6480 100644 --- a/projects/standard-rulesets/src/naming-changes/isCase.ts +++ b/projects/standard-rulesets/src/naming-changes/isCase.ts @@ -12,6 +12,8 @@ function regexForRule(format: (typeof casing)[number]) { return /^[A-Z][a-z0-9]+(?:[A-Z0-9][a-z0-9]+)*$/; case 'snake_case': return /^[a-z0-9]+(?:_[a-z0-9]+)*$/; + case 'case-insensitive-param-case': + return /^[a-zA-Z0-9][a-z0-9]*(-[a-zA-Z0-9][a-z0-9]*)*$/; default: return /(.*?)/; }