Skip to content

Commit 336a39a

Browse files
author
Markus Howard
committed
run lint fix changes
1 parent 2b05eb6 commit 336a39a

File tree

10 files changed

+681
-676
lines changed

10 files changed

+681
-676
lines changed

src/index.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,26 @@ import { User } from './models/user';
99
const logger = new Logger();
1010

1111
async function main(): Promise<void> {
12-
logger.info('🚀 Starting TypeScript Starter Application...');
12+
logger.info('🚀 Starting TypeScript Starter Application...');
1313

14-
// Example usage of the Calculator service
15-
const calculator = new Calculator();
16-
const result = calculator.add(5, 3);
17-
logger.info(`Calculator example: 5 + 3 = ${result}`);
14+
// Example usage of the Calculator service
15+
const calculator = new Calculator();
16+
const result = calculator.add(5, 3);
17+
logger.info(`Calculator example: 5 + 3 = ${result}`);
1818

19-
// Example usage of the User model
20-
const user = new User('John Doe', 'john.doe@example.com', 25);
21-
logger.info(`User example: ${user.toString()}`);
19+
// Example usage of the User model
20+
const user = new User('John Doe', 'john.doe@example.com', 25);
21+
logger.info(`User example: ${user.toString()}`);
2222

23-
logger.info('✅ Application completed successfully!');
23+
logger.info('✅ Application completed successfully!');
2424
}
2525

2626
// Run the application
2727
if (require.main === module) {
28-
main().catch((error) => {
29-
console.error('❌ Application failed:', error);
30-
process.exit(1);
31-
});
28+
main().catch((error) => {
29+
console.error('❌ Application failed:', error);
30+
process.exit(1);
31+
});
3232
}
3333

3434
export { main };

src/models/user.ts

Lines changed: 80 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -3,97 +3,97 @@
33
*/
44

55
export class User {
6-
private readonly id: string;
7-
private readonly createdAt: Date;
6+
private readonly id: string;
7+
private readonly createdAt: Date;
88

9-
constructor(
10-
public readonly name: string,
11-
public readonly email: string,
12-
public readonly age: number
13-
) {
14-
this.id = this.generateId();
15-
this.createdAt = new Date();
16-
this.validateInput();
17-
}
18-
19-
/**
20-
* Get the user's ID
21-
*/
22-
public getId(): string {
23-
return this.id;
24-
}
25-
26-
/**
27-
* Get when the user was created
28-
*/
29-
public getCreatedAt(): Date {
30-
return this.createdAt;
31-
}
9+
constructor(
10+
public readonly name: string,
11+
public readonly email: string,
12+
public readonly age: number,
13+
) {
14+
this.id = this.generateId();
15+
this.createdAt = new Date();
16+
this.validateInput();
17+
}
3218

33-
/**
34-
* Check if the user is an adult
35-
*/
36-
public isAdult(): boolean {
37-
return this.age >= 18;
38-
}
19+
/**
20+
* Get the user's ID
21+
*/
22+
public getId(): string {
23+
return this.id;
24+
}
3925

40-
/**
41-
* Get user display name
42-
*/
43-
public getDisplayName(): string {
44-
return `${this.name} (${this.age})`;
45-
}
26+
/**
27+
* Get when the user was created
28+
*/
29+
public getCreatedAt(): Date {
30+
return this.createdAt;
31+
}
4632

47-
/**
48-
* Convert user to string representation
49-
*/
50-
public toString(): string {
51-
return `User(id=${this.id}, name=${this.name}, email=${this.email}, age=${this.age}, isAdult=${this.isAdult()})`;
52-
}
33+
/**
34+
* Check if the user is an adult
35+
*/
36+
public isAdult(): boolean {
37+
return this.age >= 18;
38+
}
5339

54-
/**
55-
* Convert user to JSON object
56-
*/
57-
public toJSON(): Record<string, unknown> {
58-
return {
59-
id: this.id,
60-
name: this.name,
61-
email: this.email,
62-
age: this.age,
63-
isAdult: this.isAdult(),
64-
createdAt: this.createdAt.toISOString(),
65-
};
66-
}
40+
/**
41+
* Get user display name
42+
*/
43+
public getDisplayName(): string {
44+
return `${this.name} (${this.age})`;
45+
}
6746

68-
/**
69-
* Validate user input
70-
*/
71-
private validateInput(): void {
72-
if (!this.name || this.name.trim().length === 0) {
73-
throw new Error('Name cannot be empty');
47+
/**
48+
* Convert user to string representation
49+
*/
50+
public toString(): string {
51+
return `User(id=${this.id}, name=${this.name}, email=${this.email}, age=${this.age}, isAdult=${this.isAdult()})`;
7452
}
7553

76-
if (!this.email || !this.isValidEmail(this.email)) {
77-
throw new Error('Invalid email address');
54+
/**
55+
* Convert user to JSON object
56+
*/
57+
public toJSON(): Record<string, unknown> {
58+
return {
59+
id: this.id,
60+
name: this.name,
61+
email: this.email,
62+
age: this.age,
63+
isAdult: this.isAdult(),
64+
createdAt: this.createdAt.toISOString(),
65+
};
7866
}
7967

80-
if (this.age < 0 || this.age > 150) {
81-
throw new Error('Age must be between 0 and 150');
68+
/**
69+
* Validate user input
70+
*/
71+
private validateInput(): void {
72+
if (!this.name || this.name.trim().length === 0) {
73+
throw new Error('Name cannot be empty');
74+
}
75+
76+
if (!this.email || !this.isValidEmail(this.email)) {
77+
throw new Error('Invalid email address');
78+
}
79+
80+
if (this.age < 0 || this.age > 150) {
81+
throw new Error('Age must be between 0 and 150');
82+
}
8283
}
83-
}
8484

85-
/**
86-
* Simple email validation
87-
*/
88-
private isValidEmail(email: string): boolean {
89-
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
90-
return emailRegex.test(email);
91-
}
85+
/**
86+
* Simple email validation
87+
*/
88+
private isValidEmail(email: string): boolean {
89+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
90+
return emailRegex.test(email);
91+
}
9292

93-
/**
94-
* Generate a simple ID (in real apps, use UUID or similar)
95-
*/
96-
private generateId(): string {
97-
return Math.random().toString(36).substr(2, 9);
98-
}
93+
/**
94+
* Generate a simple ID (in real apps, use UUID or similar)
95+
*/
96+
private generateId(): string {
97+
return Math.random().toString(36).substr(2, 9);
98+
}
9999
}

src/services/calculator.ts

Lines changed: 64 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,79 +3,79 @@
33
*/
44

55
export class Calculator {
6-
/**
7-
* Add two numbers
8-
*/
9-
public add(a: number, b: number): number {
10-
return a + b;
11-
}
6+
/**
7+
* Add two numbers
8+
*/
9+
public add(a: number, b: number): number {
10+
return a + b;
11+
}
1212

13-
/**
14-
* Subtract two numbers
15-
*/
16-
public subtract(a: number, b: number): number {
17-
return a - b;
18-
}
13+
/**
14+
* Subtract two numbers
15+
*/
16+
public subtract(a: number, b: number): number {
17+
return a - b;
18+
}
1919

20-
/**
21-
* Multiply two numbers
22-
*/
23-
public multiply(a: number, b: number): number {
24-
return a * b;
25-
}
20+
/**
21+
* Multiply two numbers
22+
*/
23+
public multiply(a: number, b: number): number {
24+
return a * b;
25+
}
2626

27-
/**
28-
* Divide two numbers
29-
*/
30-
public divide(a: number, b: number): number {
31-
if (b === 0) {
32-
throw new Error('Division by zero is not allowed');
27+
/**
28+
* Divide two numbers
29+
*/
30+
public divide(a: number, b: number): number {
31+
if (b === 0) {
32+
throw new Error('Division by zero is not allowed');
33+
}
34+
return a / b;
3335
}
34-
return a / b;
35-
}
3636

37-
/**
38-
* Calculate power of a number
39-
*/
40-
public power(base: number, exponent: number): number {
41-
return Math.pow(base, exponent);
42-
}
37+
/**
38+
* Calculate power of a number
39+
*/
40+
public power(base: number, exponent: number): number {
41+
return Math.pow(base, exponent);
42+
}
4343

44-
/**
45-
* Calculate square root of a number
46-
*/
47-
public sqrt(value: number): number {
48-
if (value < 0) {
49-
throw new Error('Cannot calculate square root of negative number');
44+
/**
45+
* Calculate square root of a number
46+
*/
47+
public sqrt(value: number): number {
48+
if (value < 0) {
49+
throw new Error('Cannot calculate square root of negative number');
50+
}
51+
return Math.sqrt(value);
5052
}
51-
return Math.sqrt(value);
52-
}
5353

54-
/**
55-
* Calculate percentage
56-
*/
57-
public percentage(value: number, percentage: number): number {
58-
return (value * percentage) / 100;
59-
}
54+
/**
55+
* Calculate percentage
56+
*/
57+
public percentage(value: number, percentage: number): number {
58+
return (value * percentage) / 100;
59+
}
6060

61-
/**
62-
* Check if a number is even
63-
*/
64-
public isEven(value: number): boolean {
65-
return value % 2 === 0;
66-
}
61+
/**
62+
* Check if a number is even
63+
*/
64+
public isEven(value: number): boolean {
65+
return value % 2 === 0;
66+
}
6767

68-
/**
69-
* Check if a number is odd
70-
*/
71-
public isOdd(value: number): boolean {
72-
return !this.isEven(value);
73-
}
68+
/**
69+
* Check if a number is odd
70+
*/
71+
public isOdd(value: number): boolean {
72+
return !this.isEven(value);
73+
}
7474

75-
/**
76-
* Get the absolute value of a number
77-
*/
78-
public abs(value: number): number {
79-
return Math.abs(value);
80-
}
75+
/**
76+
* Get the absolute value of a number
77+
*/
78+
public abs(value: number): number {
79+
return Math.abs(value);
80+
}
8181
}

0 commit comments

Comments
 (0)