Skip to content

Commit 19e0415

Browse files
committed
use formatter
1 parent e0074de commit 19e0415

File tree

20 files changed

+351
-158
lines changed

20 files changed

+351
-158
lines changed

typescript/.prettierrc.json

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

typescript/@types/Node.ts

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

typescript/@types/global.d.ts

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -18,59 +18,4 @@ declare global {
1818
function linkedListToArray(head: ListNode | null): number[];
1919
}
2020

21-
// Implementation
22-
(globalThis as any).ListNode = class ListNode {
23-
prev: ListNode | null;
24-
next: ListNode | null;
25-
val: number;
26-
key?: number;
27-
28-
constructor(
29-
valOrOptions: number | ListNodeConstructor,
30-
next: ListNode | null = null
31-
) {
32-
if (typeof valOrOptions === 'object') {
33-
this.prev = null;
34-
this.next = null;
35-
this.val = valOrOptions.value;
36-
this.key = valOrOptions.key;
37-
} else {
38-
this.prev = null;
39-
this.next = next;
40-
this.val = valOrOptions;
41-
this.key = undefined;
42-
}
43-
}
44-
};
45-
46-
(globalThis as any).createLinkedList = function (
47-
values: number[]
48-
): ListNode | null {
49-
if (values.length === 0) return null;
50-
51-
const head = new ListNode(values[0]);
52-
let current = head;
53-
54-
for (let i = 1; i < values.length; i++) {
55-
current.next = new ListNode(values[i]);
56-
current = current.next;
57-
}
58-
59-
return head;
60-
};
61-
62-
(globalThis as any).linkedListToArray = function (
63-
head: ListNode | null
64-
): number[] {
65-
const result: number[] = [];
66-
let current = head;
67-
68-
while (current !== null) {
69-
result.push(current.val);
70-
current = current.next;
71-
}
72-
73-
return result;
74-
};
75-
7621
export {};

typescript/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This workspace is configured for solving LeetCode problems in TypeScript.
44

55
## Setup
66
- **Vitest** for testing and test runner
7-
- **Prettier** for code formatting
7+
- **Biome** for fast linting and formatting
88
- **TypeScript** for type safety and modern JavaScript features
99

1010
## Prerequisites
@@ -72,6 +72,7 @@ npx vitest
7272
# Type checking
7373
npx tsc --noEmit
7474

75-
# Format code
76-
npx prettier --write *.ts
75+
# Lint and format code
76+
npm run lint
77+
npm run format
7778
```

typescript/biome.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3+
"formatter": {
4+
"enabled": true,
5+
"indentStyle": "space",
6+
"indentWidth": 2,
7+
"lineWidth": 100
8+
},
9+
"linter": {
10+
"enabled": true,
11+
"rules": {
12+
"recommended": true,
13+
"complexity": {
14+
"noExcessiveCognitiveComplexity": "off"
15+
},
16+
"style": {
17+
"noParameterAssign": "off",
18+
"useConst": "off",
19+
"useSingleVarDeclarator": "off"
20+
},
21+
"suspicious": {
22+
"noEmptyBlockStatements": "warn"
23+
},
24+
"correctness": {
25+
"noUnusedVariables": "warn"
26+
}
27+
}
28+
},
29+
"javascript": {
30+
"formatter": {
31+
"quoteStyle": "single",
32+
"semicolons": "always",
33+
"trailingCommas": "all",
34+
"arrowParentheses": "asNeeded"
35+
}
36+
}
37+
}

typescript/gitignore

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Compiled JavaScript files
2+
*.js
3+
*.js.map
4+
5+
# TypeScript build output
6+
dist/
7+
build/
8+
9+
# Node.js dependencies
10+
node_modules/
11+
12+
# IDE and editor files
13+
.vscode/
14+
.idea/
15+
*.swp
16+
*.swo
17+
*~
18+
19+
# OS generated files
20+
.DS_Store
21+
.DS_Store?
22+
._*
23+
.Spotlight-V100
24+
.Trashes
25+
ehthumbs.db
26+
Thumbs.db
27+
28+
# Logs
29+
*.log
30+
npm-debug.log*
31+
yarn-debug.log*
32+
yarn-error.log*
33+
34+
# Runtime data
35+
pids
36+
*.pid
37+
*.seed
38+
*.pid.lock
39+
40+
# Coverage directory used by tools like istanbul
41+
coverage/
42+
*.lcov
43+
44+
# nyc test coverage
45+
.nyc_output
46+
47+
# Optional npm cache directory
48+
.npm
49+
50+
# Optional eslint cache
51+
.eslintcache
52+
53+
# Environment variables
54+
.env
55+
.env.local
56+
.env.development.local
57+
.env.test.local
58+
.env.production.local
59+
60+
# Temporary files
61+
tmp/
62+
temp/

typescript/global-impl.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Global implementations
2+
type ListNodeConstructor = {
3+
key?: number;
4+
value: number;
5+
};
6+
7+
class ListNodeImpl {
8+
prev: ListNode | null;
9+
next: ListNode | null;
10+
val: number;
11+
key?: number;
12+
13+
constructor(valOrOptions: number | ListNodeConstructor, next: ListNode | null = null) {
14+
if (typeof valOrOptions === 'object') {
15+
this.prev = null;
16+
this.next = null;
17+
this.val = valOrOptions.value;
18+
this.key = valOrOptions.key;
19+
} else {
20+
this.prev = null;
21+
this.next = next;
22+
this.val = valOrOptions;
23+
this.key = undefined;
24+
}
25+
}
26+
}
27+
28+
(globalThis as any).ListNode = ListNodeImpl;
29+
30+
(globalThis as any).createLinkedList = function (values: number[]): ListNode | null {
31+
if (values.length === 0) return null;
32+
33+
const head = new ListNodeImpl(values[0]);
34+
let current = head;
35+
36+
for (let i = 1; i < values.length; i++) {
37+
current.next = new ListNodeImpl(values[i]);
38+
current = current.next;
39+
}
40+
41+
return head;
42+
};
43+
44+
(globalThis as any).linkedListToArray = function (head: ListNode | null): number[] {
45+
const result: number[] = [];
46+
let current = head;
47+
48+
while (current !== null) {
49+
result.push(current.val);
50+
current = current.next;
51+
}
52+
53+
return result;
54+
};

0 commit comments

Comments
 (0)