From 1ac9e23572514b8fa463a75fc433c41e6f93cd38 Mon Sep 17 00:00:00 2001 From: Pranav Date: Wed, 27 Nov 2024 17:01:05 -0800 Subject: [PATCH] Update eslint --- src/helpers.ts | 11 ++++++----- test/helpers.test.ts | 15 +++++++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/helpers.ts b/src/helpers.ts index d676ded..b5be36b 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -162,12 +162,14 @@ export const fileNameWithEllipsis = ( * splitName('John Doe') // { firstName: 'John', lastName: 'Doe' } * splitName('') // { firstName: '', lastName: '' } */ -export const splitName = (fullName: string): { firstName: string; lastName: string } => { +export const splitName = ( + fullName: string +): { firstName: string; lastName: string } => { const trimmedName = fullName.trim(); if (!trimmedName) { return { firstName: '', - lastName: '' + lastName: '', }; } @@ -178,7 +180,7 @@ export const splitName = (fullName: string): { firstName: string; lastName: stri if (nameParts.length === 1) { return { firstName: nameParts[0], - lastName: '' + lastName: '', }; } @@ -186,6 +188,5 @@ export const splitName = (fullName: string): { firstName: string; lastName: stri const lastName = nameParts.pop() || ''; const firstName = nameParts.join(' '); - return { firstName, lastName + return { firstName, lastName }; }; -} diff --git a/test/helpers.test.ts b/test/helpers.test.ts index 98f9259..9958b13 100644 --- a/test/helpers.test.ts +++ b/test/helpers.test.ts @@ -1,4 +1,8 @@ -import { convertSecondsToTimeUnit, fileNameWithEllipsis, splitName } from '../src/helpers'; +import { + convertSecondsToTimeUnit, + fileNameWithEllipsis, + splitName, +} from '../src/helpers'; describe('#convertSecondsToTimeUnit', () => { it("it should return { time: 1, unit: 'm' } if 60 seconds passed", () => { @@ -93,35 +97,34 @@ describe('fileNameWithEllipsis', () => { const file = { name: 'a.txt' }; expect(fileNameWithEllipsis(file)).toBe('a.txt'); }); - }); describe('splitName', () => { it('splits a basic first and last name', () => { expect(splitName('John Doe')).toEqual({ firstName: 'John', - lastName: 'Doe' + lastName: 'Doe', }); }); it('handles single name', () => { expect(splitName('John')).toEqual({ firstName: 'John', - lastName: '' + lastName: '', }); }); it('handles empty string', () => { expect(splitName('Mary John Ann')).toEqual({ firstName: 'Mary John', - lastName: 'Ann' + lastName: 'Ann', }); }); it('handles extra whitespace', () => { expect(splitName(' Jane Doe ')).toEqual({ firstName: 'Jane', - lastName: 'Doe' + lastName: 'Doe', }); }); });