Skip to content

Commit 97c850a

Browse files
committed
replace Prettier with Biome
1 parent a207638 commit 97c850a

18 files changed

+233
-57
lines changed

.prettierignore

-1
This file was deleted.

.vscode/settings.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"typescript.tsdk": "node_modules/typescript/lib"}
1+
{ "typescript.tsdk": "node_modules/typescript/lib" }

biome.jsonc

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
3+
"formatter": { "indentStyle": "space" },
4+
"javascript": {
5+
"formatter": {
6+
"arrowParentheses": "asNeeded",
7+
"bracketSpacing": false,
8+
"indentStyle": "space",
9+
"jsxQuoteStyle": "single",
10+
"quoteStyle": "single",
11+
"semicolons": "asNeeded",
12+
"trailingComma": "none"
13+
}
14+
},
15+
"json": {
16+
"formatter": { "indentStyle": "space" },
17+
"parser": { "allowComments": true }
18+
},
19+
"linter": {
20+
"rules": {
21+
"style": { "noInferrableTypes": "off", "noNonNullAssertion": "off" }
22+
}
23+
},
24+
"vcs": { "enabled": true, "clientKind": "git" }
25+
}

package-lock.json

+156
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+5-17
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
},
1212
"devDependencies": {
1313
"@ampproject/filesize": "4.3.0",
14+
"@biomejs/biome": "1.7.3",
1415
"@types/jsdom": "21.1.6",
1516
"@types/node": "18.19.31",
1617
"mem-font": "11.0.0-2",
17-
"prettier": "3.2.5",
1818
"typescript": "5.5.0-beta",
1919
"vitest": "1.6.0"
2020
},
@@ -34,22 +34,10 @@
3434
}
3535
},
3636
"homepage": "https://github.com/oidoid/void",
37-
"keywords": [
38-
"game engine",
39-
"webgl"
40-
],
37+
"keywords": ["game engine", "webgl"],
4138
"license": "AGPL-3.0-only",
4239
"main": "dist/index.js",
4340
"name": "@oidoid/void",
44-
"prettier": {
45-
"arrowParens": "avoid",
46-
"bracketSpacing": false,
47-
"jsxSingleQuote": true,
48-
"proseWrap": "always",
49-
"semi": false,
50-
"singleQuote": true,
51-
"trailingComma": "none"
52-
},
5341
"publishConfig": {
5442
"access": "public"
5543
},
@@ -60,13 +48,13 @@
6048
"scripts": {
6149
"build": "tsc --build",
6250
"clean": "rm -rf dist",
63-
"format": "npm run formatter -- --write",
64-
"formatter": "prettier --cache --log-level warn './**/*.{js,json,md,ts,yaml}'",
51+
"format": "npm run formatter -- --apply",
52+
"formatter": "biome check --error-on-warnings .",
6553
"preversion": "[ -z \"$(git status -z)\" ]",
6654
"prepublishOnly": "! git symbolic-ref --quiet HEAD || git push --follow-tags origin \"$(git branch --show-current)\"",
6755
"start": "npm run build -- --watch",
6856
"test": "npm run test:format && npm run test:unit && npm run build && npm run test:size",
69-
"test:format": "npm run formatter -- --check",
57+
"test:format": "npm run formatter",
7058
"test:size": "npx esbuild --bundle --format=esm --metafile=dist/void.meta.json --minify --outfile=dist/void.js --sourcemap=linked --target=es2022 src/index.ts && filesize",
7159
"test:unit": "vitest --config=tools/vitest.config.ts run",
7260
"version": "npm test"

src/graphics/sprite.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type {Bitmap} from '../renderer/bitmap.js'
2-
import {boxHits, type Box, type WH, type XY} from '../types/2d.js'
2+
import {type Box, type WH, type XY, boxHits} from '../types/2d.js'
33
import type {Anim, TagFormat} from './anim.js'
44
import type {Atlas} from './atlas.js'
55

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {Tileset} from './graphics/tileset.js'
66
import {Input, type StandardButton} from './input/input.js'
77
import {Random} from './random.js'
88
import {BitmapAttribBuffer, TileAttribBuffer} from './renderer/attrib-buffer.js'
9-
import {type Bitmap} from './renderer/bitmap.js'
9+
import type {Bitmap} from './renderer/bitmap.js'
1010
import {Cam} from './renderer/cam.js'
1111
import {FrameListener} from './renderer/frame-listener.js'
1212
import {Renderer} from './renderer/renderer.js'

src/input/input.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {Cam} from '../renderer/cam.js'
1+
import type {Cam} from '../renderer/cam.js'
22
import type {XY} from '../types/2d.js'
33
import {KeyPoller} from './key-poller.js'
44
import {PadPoller} from './pad-poller.js'
55
import {PointerPoller} from './pointer-poller.js'
66

7-
// prettier-ignore
7+
// biome-ignore format:
88
export type StandardButton =
99
'L' | 'R' | 'U' | 'D' | // Dpad.
1010
'A' | 'B' | 'C' | // Primary, secondary, tertiary.
@@ -198,7 +198,7 @@ export class Input<T extends string> {
198198
}
199199

200200
#map(button: T): number {
201-
return (this.#bitByButton[button] ??=
202-
1 << Object.keys(this.#bitByButton).length)
201+
this.#bitByButton[button] ??= 1 << Object.keys(this.#bitByButton).length
202+
return this.#bitByButton[button]
203203
}
204204
}

src/input/pointer-poller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Cam} from '../renderer/cam.js'
1+
import type {Cam} from '../renderer/cam.js'
22
import type {XY} from '../types/2d.js'
33

44
export class PointerPoller {

src/renderer/frame-listener.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import {Input} from '../input/input.js'
1+
import type {Input} from '../input/input.js'
22
import type {AttribBuffer} from './attrib-buffer.js'
3-
import {Cam} from './cam.js'
4-
import {Renderer} from './renderer.js'
3+
import type {Cam} from './cam.js'
4+
import type {Renderer} from './renderer.js'
55

66
export class FrameListener {
77
/** The running lifetime in milliseconds. */

src/renderer/renderer.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type {Atlas} from '../graphics/atlas.js'
22
import type {AttribBuffer} from './attrib-buffer.js'
3-
import {Cam} from './cam.js'
3+
import type {Cam} from './cam.js'
44
import {fragGLSL} from './frag.glsl.js'
5-
import {Shader, type GL} from './shader.js'
5+
import {type GL, Shader} from './shader.js'
66
import {spriteVertGLSL} from './sprite-vert.glsl.js'
77
import {tileVertGLSL} from './tile-vert.glsl.js'
88

src/test/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414
"tsBuildInfoFile": "../../dist/test/tsconfig.tsbuildinfo"
1515
},
1616
"include": ["**/*", "../**/*.test.ts"],
17-
"references": [{"path": ".."}]
17+
"references": [{ "path": ".." }]
1818
}

src/text/text-layout.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {memProp5x5, type Font} from 'mem-font'
1+
import {type Font, memProp5x5} from 'mem-font'
22
import {describe, expect, test} from 'vitest'
33
import {layoutText, layoutWord} from './text-layout.js'
44

@@ -608,7 +608,7 @@ describe('layoutWord()', () => {
608608
}
609609
]
610610
]).entries()) {
611-
test(`case ${caseNumber}: xy=${(xy.x, xy.y)}, width=${width}, string="${string}", index=${index}.`, () =>
611+
test(`case ${caseNumber}: xy=(${xy.x}, ${xy.y}), width=${width}, string="${string}", index=${index}.`, () =>
612612
expect(layoutWord(font, xy, width, string, index)).toStrictEqual(
613613
expected
614614
))

src/text/text-layout.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function layoutText(font: Font, str: string, maxW: number): TextLayout {
1515
while (chars.length < str.length) {
1616
const i = chars.length
1717
const char = str[i]!
18-
let layout
18+
let layout: TextLayout
1919
if (char === '\n') layout = layoutNewline(font, cursor)
2020
else if (/^\s*$/.test(char)) {
2121
layout = layoutSpace(font, cursor, maxW, tracking(font, char, str[i + 1]))
@@ -54,14 +54,15 @@ export function layoutWord(
5454
const span = tracking(font, char, word[index + 1])
5555
if (x > 0 && x + span > maxW) ({x, y} = nextLine(font, y))
5656

57-
// Width is not span since, with kerning, that may exceed the actual
58-
// width of the character's sprite. For example, if w has the maximal
57+
// width is not span since, with kerning, that may exceed the actual
58+
// width of the character's sprite. for example, if w has the maximal
5959
// character width of five pixels and a one pixel kerning for a given pair
6060
// of characters, it will have a span of six pixels which is greater than
6161
// the maximal five pixel sprite that can be rendered.
6262
chars.push({x, y, w: fontCharWidth(font, char), h: font.cellHeight})
6363
x += span
6464

65+
// biome-ignore lint/style/noParameterAssign:
6566
index++
6667
}
6768
return {chars, cursor: {x, y}}
@@ -76,7 +77,7 @@ function layoutNewline(font: Font, cursor: Readonly<XY>): TextLayout {
7677
}
7778

7879
/**
79-
* @arg span The distance in pixels from the start of the current character to
80+
* @arg span the distance in pixels from the start of the current character to
8081
* the start of the next including scale.
8182
*/
8283
function layoutSpace(
@@ -92,7 +93,7 @@ function layoutSpace(
9293
return {chars: [undefined], cursor: nextCursor}
9394
}
9495

95-
/** Returns the distance in pixels from the start of lhs to the start of rhs. */
96+
/** @return the distance in pixels from the start of lhs to the start of rhs. */
9697
function tracking(font: Font, lhs: string, rhs: string | undefined): number {
9798
return fontCharWidth(font, lhs) + fontKerning(font, lhs, rhs)
9899
}

tools/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
"types": ["node"]
1616
},
1717
"include": ["**/*", "../package.json"],
18-
"references": [{"path": "../src"}]
18+
"references": [{ "path": "../src" }]
1919
}

0 commit comments

Comments
 (0)