Skip to content

Commit d7ce851

Browse files
authored
fmt changes (#856)
swap prettier with oxfmt/oxlint, update CI, and fix the formatting/lint issues needed for the new checks to pass.
1 parent a5946c9 commit d7ce851

File tree

13 files changed

+208
-73
lines changed

13 files changed

+208
-73
lines changed

.github/workflows/format-lint.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Format and Lint
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
jobs:
8+
fmt:
9+
name: Format Check
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Setup Bun
17+
uses: oven-sh/setup-bun@v2
18+
with:
19+
bun-version: latest
20+
21+
- name: Install dependencies
22+
run: bun install
23+
24+
- name: Check formatting
25+
run: bun run fmt:check
26+
27+
- name: Show formatting differences
28+
if: failure()
29+
run: |
30+
echo "=== Showing differences for each file ==="
31+
bun run fmt
32+
git diff --color=always
33+
34+
lint:
35+
name: Lint Check
36+
runs-on: ubuntu-latest
37+
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v4
41+
42+
- name: Setup Bun
43+
uses: oven-sh/setup-bun@v2
44+
with:
45+
bun-version: latest
46+
47+
- name: Install dependencies
48+
run: bun install
49+
50+
- name: Run linter
51+
run: bun run lint:ci
52+
53+
checks-complete:
54+
name: Format and Lint
55+
needs: [fmt, lint]
56+
runs-on: ubuntu-latest
57+
if: always()
58+
59+
steps:
60+
- name: Check results
61+
run: |
62+
if [ "${{ needs.fmt.result }}" != "success" ] || [ "${{ needs.lint.result }}" != "success" ]; then
63+
echo "Format or lint checks failed"
64+
exit 1
65+
fi
66+
echo "Format and lint checks passed"

.github/workflows/prettier.yml

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

.oxfmtrc.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"semi": false,
4+
"printWidth": 120,
5+
"sortPackageJson": false,
6+
"ignorePatterns": ["**/.zig-cache/**", "packages/core/src/lib/tree-sitter/default-parsers.ts"]
7+
}

.oxlintrc.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "./node_modules/oxlint/configuration_schema.json",
3+
"plugins": ["react", "typescript", "import"],
4+
"categories": {
5+
"correctness": "off",
6+
"suspicious": "off",
7+
"pedantic": "off",
8+
"perf": "off",
9+
"style": "off",
10+
"restriction": "off",
11+
"nursery": "off"
12+
},
13+
"rules": {
14+
"no-async-promise-executor": "error",
15+
"react/react-in-jsx-scope": "off",
16+
"react/no-unknown-property": "off"
17+
}
18+
}

.prettierignore

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

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ FROM THE `packages/core` DIRECTORY.
4646
## Typescript Code Style
4747

4848
- **Runtime**: Bun with TypeScript
49-
- **Formatting**: Prettier (semi: false, printWidth: 120)
49+
- **Formatting**: oxfmt (semi: false, printWidth: 120)
5050
- **Imports**: Use explicit imports, group by: built-ins, external deps, internal modules
5151
- **Types**: Strict TypeScript, use interfaces for options/configs, explicit return types for public APIs
5252
- **Naming**: camelCase for variables/functions, PascalCase for classes/interfaces, UPPER_CASE for constants

bun.lock

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

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,21 @@
77
],
88
"scripts": {
99
"build": "cd packages/core && bun run build && cd ../solid && bun run build && cd ../react && bun run build",
10+
"fmt": "oxfmt --write .",
11+
"fmt:check": "oxfmt --check .",
12+
"lint": "oxlint .",
13+
"lint:ci": "oxlint . --deny-warnings",
14+
"lint:fix": "oxlint --fix .",
1015
"pre-publish": "bun scripts/pre-publish.ts",
1116
"publish": "bun run pre-publish && bun run publish:core && bun run publish:react && bun run publish:solid",
1217
"publish:core": "cd packages/core && bun run publish",
1318
"publish:react": "cd packages/react && bun run publish",
1419
"publish:solid": "cd packages/solid && bun run publish",
1520
"prepare-release": "bun scripts/prepare-release.ts",
16-
"prettier:write": "prettier --write .",
1721
"test": "bun run --filter '@opentui/core' --filter '@opentui/solid' --filter '@opentui/react' --if-present test"
1822
},
1923
"devDependencies": {
20-
"prettier": "3.6.2"
21-
},
22-
"prettier": {
23-
"semi": false,
24-
"printWidth": 120
24+
"oxfmt": "0.41.0",
25+
"oxlint": "1.56.0"
2526
}
2627
}

packages/core/src/lib/tree-sitter/parser.worker.ts

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -81,34 +81,29 @@ class ParserWorker {
8181
if (this.initializePromise) {
8282
return this.initializePromise
8383
}
84-
this.initializePromise = new Promise(async (resolve, reject) => {
84+
this.initializePromise = (async () => {
8585
this.dataPath = dataPath
8686
this.tsDataPath = path.join(dataPath, "tree-sitter")
8787

88-
try {
89-
await mkdir(path.join(this.tsDataPath, "languages"), { recursive: true })
90-
await mkdir(path.join(this.tsDataPath, "queries"), { recursive: true })
88+
await mkdir(path.join(this.tsDataPath, "languages"), { recursive: true })
89+
await mkdir(path.join(this.tsDataPath, "queries"), { recursive: true })
9190

92-
let { default: treeWasm } = await import("web-tree-sitter/tree-sitter.wasm" as string, {
93-
with: { type: "wasm" },
94-
})
91+
let { default: treeWasm } = await import("web-tree-sitter/tree-sitter.wasm" as string, {
92+
with: { type: "wasm" },
93+
})
9594

96-
if (isBunfsPath(treeWasm)) {
97-
treeWasm = normalizeBunfsPath(path.parse(treeWasm).base)
98-
}
95+
if (isBunfsPath(treeWasm)) {
96+
treeWasm = normalizeBunfsPath(path.parse(treeWasm).base)
97+
}
9998

100-
await Parser.init({
101-
locateFile() {
102-
return treeWasm
103-
},
104-
})
99+
await Parser.init({
100+
locateFile() {
101+
return treeWasm
102+
},
103+
})
105104

106-
this.initialized = true
107-
resolve()
108-
} catch (error) {
109-
reject(error)
110-
}
111-
})
105+
this.initialized = true
106+
})()
112107
return this.initializePromise
113108
}
114109

0 commit comments

Comments
 (0)