Skip to content

Commit b418035

Browse files
committed
build: configure Oxfmt and contributor formatting commands
1 parent f41b947 commit b418035

5 files changed

Lines changed: 267 additions & 0 deletions

File tree

‎.oxfmtrc.jsonc‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "./node_modules/oxfmt/configuration_schema.json",
3+
"printWidth": 100,
4+
"tabWidth": 4,
5+
"singleQuote": true,
6+
"endOfLine": "lf",
7+
// Keep imports and package metadata in their existing order.
8+
"sortImports": false,
9+
"sortPackageJson": false,
10+
// Format TypeScript files only for now: ignore everything, then re-include
11+
// directories and TypeScript sources. The CLI and the Oxc VS Code extension
12+
// both read this file.
13+
"ignorePatterns": ["*", "!*/", "!*.ts", "!*.tsx", "!*.mts", "!*.cts"],
14+
}

‎.vscode/settings.json‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
"out": true // set this to false to include "out" folder in search results
88
},
99
"r.lsp.diagnostics": true,
10+
"[typescript][typescriptreact]": {
11+
"editor.defaultFormatter": "oxc.oxc-vscode",
12+
"editor.formatOnSave": true
13+
},
1014
"editor.codeActionsOnSave": {
1115
"source.fixAll.markdownlint": "explicit"
1216
}

‎CONTRIBUTING.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,24 @@ If launching reports `Configured debug type 'extensionHost' is not supported`, e
2525

2626
On VS Code 1.139, the regression can leave the development host paused before any extension activates; the launching window's extension host log shows `ECONNREFUSED ::1` and `Could not find any debuggable target`. Upgrade to VS Code 1.140.0 or newer, or use Microsoft's [JavaScript Debugger Nightly](https://marketplace.visualstudio.com/items?itemName=ms-vscode.js-debug-nightly) as a temporary workaround: disable the built-in **JavaScript Debugger**, enable Nightly, and reload VS Code.
2727

28+
## Formatting and linting
29+
30+
Run `pnpm run format` to format TypeScript files with Oxfmt, and
31+
`pnpm run format:check` to check formatting without changing files. CI runs the
32+
same check for pull requests and pushes to `main`. Formatting currently applies
33+
to TypeScript files only (`.ts`, `.tsx`, `.mts`, and `.cts`); other file types,
34+
including JavaScript, JSON, Markdown, YAML, R, C, and EJS files, are not formatted.
35+
36+
The checked-in `.oxfmtrc.jsonc` is shared by the CLI and the recommended Oxc
37+
VS Code extension, and its `ignorePatterns` restrict both to TypeScript files.
38+
TypeScript files use four-space indentation and single quotes. Import and
39+
`package.json` sorting are disabled. Oxfmt respects the repository's `.gitignore`
40+
files, so generated bundles, compiled tests, and dependencies are excluded.
41+
42+
Workspace settings select Oxc as the formatter and enable format on save for
43+
TypeScript. Run `pnpm run lint` and `pnpm run typecheck` separately to check
44+
TypeScript code.
45+
2846
## Building bundled sess
2947

3048
Builds require Git and a checkout with HEAD. `scripts/prepare-sess.js` fingerprints

‎package.json‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2604,6 +2604,8 @@
26042604
"test:node": "mocha \"out/test/node/**/*.test.js\" --config .mocharc.interactive.cjs",
26052605
"test:extension": "vscode-test",
26062606
"lint": "oxlint src",
2607+
"format": "oxfmt .",
2608+
"format:check": "oxfmt --check .",
26072609
"typecheck": "tsc --noEmit -p ./",
26082610
"test:sess-identity": "Rscript --vanilla R/tests/sess_source.R",
26092611
"test:sess-attach": "Rscript --vanilla R/tests/attach_sess.R",
@@ -2627,6 +2629,7 @@
26272629
"glob": "^13.0.6",
26282630
"mocha": "^11.7.5",
26292631
"ovsx": "^0.10.8",
2632+
"oxfmt": "0.73.0",
26302633
"sinon": "^15.2.0",
26312634
"typescript": "~7.0.2",
26322635
"oxlint": "^1.86.0",

‎pnpm-lock.yaml‎

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

0 commit comments

Comments
 (0)