Skip to content

Commit 89f78ea

Browse files
cinderblockclaude
andcommitted
Modernize dependencies and tooling: bun + Biome + TS 6
- Replace ESLint + Prettier (and the 5 config/plugin deps) with Biome for a single Rust-based lint+format tool. New `biome.json` mirrors the previous prettier settings (line width 120, single quotes, arrows without parens, trailing commas) and adds `recommended` lint rules. Drops `.eslintrc.json` and `.prettierrc`. - Bump TypeScript 4 -> 6, command-line-args 5 -> 6, @types/bun and @types/command-line-args to latest. winston is already current. - Rewrite tsconfig.json: drop the boilerplate of commented options, switch target to ESNext, module to Preserve, moduleResolution to bundler, types: ["bun"]. ts now just typechecks; bun runs the code. - Add `typecheck`, `check`, `check:fix`, `format` npm scripts. README documents them. - CI runs `bun run check` and `bun run typecheck` in addition to `bun test` on Ubuntu and Windows. Biome's reformat picked up cleanup the previous setup missed: `node:` prefixes for built-ins, `import type` for type-only imports, sorted imports, `==`/`!=` -> `===`/`!==`, and `let header` -> `const header`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent f96e40d commit 89f78ea

14 files changed

Lines changed: 132 additions & 717 deletions

File tree

.eslintrc.json

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

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ jobs:
2323

2424
- run: bun install --frozen-lockfile
2525

26+
- run: bun run check
27+
- run: bun run typecheck
2628
- run: bun test

.prettierrc

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

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,14 @@ bun run dev:ewe --verbose ./samples/Temp.ewprj.xml
7979
```
8080

8181
Both use `bun --watch` for fast reload on source changes.
82+
83+
## Lint, format, and typecheck
84+
85+
```bash
86+
bun run check # biome lint + format check (no changes)
87+
bun run check:fix # apply all safe fixes
88+
bun run format # format only
89+
bun run typecheck # tsc --noEmit
90+
```
91+
92+
CI on push/PR runs `check`, `typecheck`, and `test` on Ubuntu and Windows.

biome.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/2.4.15/schema.json",
3+
"vcs": {
4+
"enabled": true,
5+
"clientKind": "git",
6+
"useIgnoreFile": true
7+
},
8+
"files": {
9+
"includes": ["src/**", "*.json", "*.md"]
10+
},
11+
"formatter": {
12+
"enabled": true,
13+
"indentStyle": "space",
14+
"indentWidth": 2,
15+
"lineWidth": 120
16+
},
17+
"javascript": {
18+
"formatter": {
19+
"quoteStyle": "single",
20+
"arrowParentheses": "asNeeded",
21+
"trailingCommas": "all",
22+
"semicolons": "always"
23+
}
24+
},
25+
"linter": {
26+
"enabled": true,
27+
"rules": {
28+
"recommended": true
29+
}
30+
},
31+
"assist": {
32+
"actions": {
33+
"source": {
34+
"organizeImports": "on"
35+
}
36+
}
37+
},
38+
"overrides": [
39+
{
40+
"includes": ["**/cSpell.json"],
41+
"json": {
42+
"parser": {
43+
"allowComments": true,
44+
"allowTrailingCommas": true
45+
}
46+
}
47+
}
48+
]
49+
}

bun.lock

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

package.json

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,24 @@
1212
"ewe": "bun run src/ewe.ts",
1313
"dev:ewd": "bun --watch run src/ewd.ts",
1414
"dev:ewe": "bun --watch run src/ewe.ts",
15-
"test": "bun test"
15+
"test": "bun test",
16+
"typecheck": "tsc --noEmit",
17+
"check": "biome check",
18+
"check:fix": "biome check --write",
19+
"format": "biome format --write"
1620
},
1721
"engines": {
1822
"bun": ">=1.0.0"
1923
},
2024
"dependencies": {
21-
"command-line-args": "^5.1.1",
25+
"command-line-args": "^6.0.2",
2226
"node-pkware": "github:cinderblock/node-pkware",
23-
"winston": "^3.3.3"
27+
"winston": "^3.19.0"
2428
},
2529
"devDependencies": {
26-
"@types/bun": "^1.1.0",
27-
"@types/command-line-args": "^5.0.0",
28-
"@typescript-eslint/eslint-plugin": "^4.28.0",
29-
"@typescript-eslint/parser": "^4.28.0",
30-
"eslint": "^7.29.0",
31-
"eslint-config-airbnb": "^18.2.1",
32-
"eslint-config-prettier": "^8.3.0",
33-
"prettier": "^2.3.2",
34-
"typescript": "^4.3.4"
30+
"@biomejs/biome": "^2.4.15",
31+
"@types/bun": "^1.3.14",
32+
"@types/command-line-args": "^5.2.3",
33+
"typescript": "^6.0.3"
3534
}
3635
}

src/decode.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { promises as fs } from 'fs';
2-
import winston from 'winston';
3-
import { UnexpectedValue } from './util/UnexpectedValue';
1+
import { promises as fs } from 'node:fs';
2+
import { Readable } from 'node:stream';
43
import { explode, stream } from 'node-pkware';
5-
import { Readable } from 'stream';
4+
import type winston from 'winston';
5+
import { UnexpectedValue } from './util/UnexpectedValue';
6+
67
const { streamToBuffer, through } = stream;
78

89
async function decodeBlock(block: Buffer, expectedLength: number): Promise<Buffer> {
@@ -18,7 +19,7 @@ async function decodeBlock(block: Buffer, expectedLength: number): Promise<Buffe
1819
return ret;
1920
}
2021

21-
export async function decode(filename: string, logger: winston.Logger, outFile = filename + '.xml'): Promise<void> {
22+
export async function decode(filename: string, logger: winston.Logger, outFile = `${filename}.xml`): Promise<void> {
2223
if (!filename) throw new Error('No filename provided');
2324

2425
let expectedHeader: Buffer;
@@ -41,7 +42,7 @@ export async function decode(filename: string, logger: winston.Logger, outFile =
4142

4243
pos += bytesRead;
4344

44-
if (bytesRead != length) {
45+
if (bytesRead !== length) {
4546
throw new UnexpectedValue('Failed to read as many bytes as we expect', length, bytesRead);
4647
}
4748

@@ -58,7 +59,7 @@ export async function decode(filename: string, logger: winston.Logger, outFile =
5859
async function readNumber(size: 8): Promise<number | bigint>;
5960
async function readNumber(size: number) {
6061
const buffer = await read(size);
61-
if ((size == 8 && buffer[6] && buffer[7]) || (size == 7 && buffer[6])) {
62+
if ((size === 8 && buffer[6] && buffer[7]) || (size === 7 && buffer[6])) {
6263
return buffer.readBigUInt64LE();
6364
}
6465

@@ -77,7 +78,7 @@ export async function decode(filename: string, logger: winston.Logger, outFile =
7778
const outputFile = await fs.open(outFile, 'w');
7879

7980
try {
80-
let header = await read(expectedHeader.length);
81+
const header = await read(expectedHeader.length);
8182

8283
logger.silly('Read header successfully');
8384

@@ -89,7 +90,7 @@ export async function decode(filename: string, logger: winston.Logger, outFile =
8990

9091
const finalLength = await readNumber(8);
9192

92-
if (typeof finalLength == 'bigint') throw new Error('Cannot handle files this large');
93+
if (typeof finalLength === 'bigint') throw new Error('Cannot handle files this large');
9394

9495
logger.silly(`Full size: ${finalLength}`);
9596

src/encode.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { promises as fs } from 'fs';
2-
import winston from 'winston';
1+
import { promises as fs } from 'node:fs';
2+
import { Readable } from 'node:stream';
33
import { constants, implode, stream } from 'node-pkware';
4-
import { Readable } from 'stream';
4+
import type winston from 'winston';
55

66
const { COMPRESSION_ASCII, DICTIONARY_SIZE_LARGE } = constants;
77
const { streamToBuffer, through } = stream;

src/ewd.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import commandLineArgs from 'command-line-args';
12
import winston from 'winston';
23
import { decode } from './decode';
3-
import commandLineArgs from 'command-line-args';
44

55
export async function main() {
66
const { files, verbose, concurrent } = commandLineArgs([

0 commit comments

Comments
 (0)