Skip to content

Commit

Permalink
fix(casing): pascal and camel cases do not support single uppercase l…
Browse files Browse the repository at this point in the history
…etters at the end (#1506)
  • Loading branch information
P0lip authored Feb 15, 2021
1 parent 32e12bd commit 20b1866
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/functions/__tests__/casing.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('casing', () => {

describe('camel', () => {
const invalid = ['foo_test', 'Foo', '1fooBarBaz', '123', 'foo-bar'];
const valid = ['foo', 'fooBar', 'fooBarBaz'];
const valid = ['foo', 'fooBar', 'fooBarBaz', 'coordinateX'];
const validWithDigits = ['foo1', 'foo24Bar', 'fooBar0Baz323'];

test.each(invalid)('should recognize invalid target %s', target => {
Expand All @@ -70,7 +70,7 @@ describe('casing', () => {

describe('pascal', () => {
const invalid = ['foo_test', '123', '1fooBarBaz', 'fooBarBaz1', 'fooBar', 'foo1', 'foo-bar'];
const valid = ['Foo', 'FooBar', 'FooBarBaz'];
const valid = ['Foo', 'FooBar', 'FooBarBaz', 'CoordinateZ'];
const validWithDigits = ['Foo1', 'FooBarBaz1'];

test.each(invalid)('should recognize invalid target %s', target => {
Expand Down
4 changes: 2 additions & 2 deletions src/functions/casing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export interface ICasingOptions {

const CASES: Dictionary<string, CasingType> = {
[CasingType.flat]: '[a-z][a-z{__DIGITS__}]*',
[CasingType.camel]: '[a-z][a-z{__DIGITS__}]*(?:[A-Z{__DIGITS__}][a-z{__DIGITS__}]+)*',
[CasingType.pascal]: '[A-Z][a-z{__DIGITS__}]*(?:[A-Z{__DIGITS__}][a-z{__DIGITS__}]+)*',
[CasingType.camel]: '[a-z][a-z{__DIGITS__}]*(?:[A-Z{__DIGITS__}](?:[a-z{__DIGITS__}]+|$))*',
[CasingType.pascal]: '[A-Z][a-z{__DIGITS__}]*(?:[A-Z{__DIGITS__}](?:[a-z{__DIGITS__}]+|$))*',
[CasingType.kebab]: '[a-z][a-z{__DIGITS__}]*(?:-[a-z{__DIGITS__}]+)*',
[CasingType.cobol]: '[A-Z][A-Z{__DIGITS__}]*(?:-[A-Z{__DIGITS__}]+)*',
[CasingType.snake]: '[a-z][a-z{__DIGITS__}]*(?:_[a-z{__DIGITS__}]+)*',
Expand Down

0 comments on commit 20b1866

Please sign in to comment.