Skip to content

Commit 0f9e29a

Browse files
authored
chore: add codely eslint linter (#15)
* chore: add codely eslint linter * chore: apply codely linter
1 parent aa0563d commit 0f9e29a

17 files changed

+4247
-3916
lines changed

.eslintrc.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import eslintConfigCodely from "eslint-config-codely";
2+
3+
export default [...eslintConfigCodely.ts];

jest.config.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
2-
testMatch: ["**/tests/**/*.test.ts"],
3-
transform: {
4-
"\\.ts$": "ts-jest",
5-
},
2+
testMatch: ["**/tests/**/*.test.ts"],
3+
transform: {
4+
"\\.ts$": "ts-jest",
5+
},
66
};

package-lock.json

Lines changed: 4084 additions & 3728 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
],
1616
"scripts": {
1717
"build": "tsc",
18-
"lint": "eslint --ignore-path .gitignore . --ext .ts",
18+
"lint": "eslint src tests eslint.config.mjs jest.config.js",
1919
"lint:fix": "npm run lint -- --fix",
2020
"test": "jest"
2121
},
@@ -33,14 +33,11 @@
3333
"homepage": "https://github.com/CodelyTV/typescript-primitives-type#readme",
3434
"devDependencies": {
3535
"@types/jest": "^27.5.2",
36-
"@typescript-eslint/eslint-plugin": "^5.21.0",
37-
"@typescript-eslint/parser": "^5.21.0",
38-
"eslint": "^8.14.0",
39-
"eslint-config-prettier": "^8.5.0",
40-
"eslint-plugin-import": "^2.26.0",
41-
"eslint-plugin-jest": "^26.1.5",
42-
"eslint-plugin-prettier": "^4.0.0",
43-
"eslint-plugin-simple-import-sort": "^7.0.0",
36+
"@typescript-eslint/eslint-plugin": "^8.15.0",
37+
"@typescript-eslint/parser": "^8.15.0",
38+
"eslint": "^8.56.0",
39+
"eslint-config-codely": "^4.2.0",
40+
"eslint-import-resolver-typescript": "^3.7.0",
4441
"expect-type": "^0.13.0",
4542
"jest": "^28.0.1",
4643
"prettier": "^2.6.2",

src/Primitives.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/* eslint-disable @typescript-eslint/ban-types */
1+
/* eslint-disable @typescript-eslint/no-unsafe-function-type */
22
type Methods<T> = {
3-
[P in keyof T]: T[P] extends Function ? P : never;
3+
[P in keyof T]: T[P] extends Function ? P : never;
44
}[keyof T];
55

66
type MethodsAndProperties<T> = { [key in keyof T]: T[key] };
@@ -10,19 +10,19 @@ type Properties<T> = Omit<MethodsAndProperties<T>, Methods<T>>;
1010
type PrimitiveTypes = string | number | boolean | Date | undefined | null;
1111

1212
type ValueObjectValue<T> = T extends PrimitiveTypes
13-
? T
14-
: T extends { value: infer U }
15-
? U
16-
: T extends Array<{ value: infer U }>
17-
? U[]
18-
: T extends Array<infer U>
19-
? Array<ValueObjectValue<U>>
20-
: T extends { [K in keyof Properties<T>]: unknown }
21-
? { [K in keyof Properties<T>]: ValueObjectValue<Properties<T>[K]> }
22-
: T extends unknown
23-
? T
24-
: never;
13+
? T
14+
: T extends { value: infer U }
15+
? U
16+
: T extends Array<{ value: infer U }>
17+
? U[]
18+
: T extends Array<infer U>
19+
? Array<ValueObjectValue<U>>
20+
: T extends { [K in keyof Properties<T>]: unknown }
21+
? { [K in keyof Properties<T>]: ValueObjectValue<Properties<T>[K]> }
22+
: T extends unknown
23+
? T
24+
: never;
2525

2626
export type Primitives<T> = {
27-
[key in keyof Properties<T>]: ValueObjectValue<T[key]>;
27+
[key in keyof Properties<T>]: ValueObjectValue<T[key]>;
2828
};

tests/.eslintrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/Address.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ import { City } from "./City";
33
import { Street } from "./Street";
44

55
export class Address {
6-
constructor(
7-
readonly street: Street,
8-
readonly city: City,
9-
readonly number: number
10-
) {}
6+
constructor(
7+
readonly street: Street,
8+
readonly city: City,
9+
readonly number: number,
10+
) {}
1111

12-
toPrimitives(): Primitives<Address> {
13-
return {
14-
street: this.street.value,
15-
city: this.city.value,
16-
number: this.number,
17-
};
18-
}
12+
toPrimitives(): Primitives<Address> {
13+
return {
14+
street: this.street.value,
15+
city: this.city.value,
16+
number: this.number,
17+
};
18+
}
1919
}

tests/Course.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { Primitives } from "../src/Primitives";
1+
import { Primitives } from "../src";
22
import { CourseId } from "./CourseId";
33

44
export class Course {
5-
constructor(readonly courseId: CourseId) {}
5+
constructor(readonly courseId: CourseId) {}
66

7-
toPrimitives(): Primitives<Course> {
8-
return {
9-
courseId: this.courseId.value,
10-
};
11-
}
7+
toPrimitives(): Primitives<Course> {
8+
return {
9+
courseId: this.courseId.value,
10+
};
11+
}
1212

13-
thisFunctionShouldNotBeIncludedInTheToPrimitives(): boolean {
14-
return true;
15-
}
13+
thisFunctionShouldNotBeIncludedInTheToPrimitives(): boolean {
14+
return true;
15+
}
1616
}

tests/DeliveryInfo.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { Primitives } from "../src/Primitives";
1+
import { Primitives } from "../src";
22
import { Address } from "./Address";
33

44
export class DeliveryInfo {
5-
constructor(readonly addresses: Address[]) {}
5+
constructor(readonly addresses: Address[]) {}
66

7-
toPrimitives(): Primitives<DeliveryInfo> {
8-
return {
9-
addresses: this.addresses.map((address) => address.toPrimitives()),
10-
};
11-
}
7+
toPrimitives(): Primitives<DeliveryInfo> {
8+
return {
9+
addresses: this.addresses.map((address) => address.toPrimitives()),
10+
};
11+
}
1212
}

0 commit comments

Comments
 (0)