repository template for Node.js & TypeScript projects

feat: integrate oxfmt tool for formatting code (#466)

authored by samanthanguyen.me and committed by

GitHub 96281400 bee41863

+172 -11
+1
.github/dependabot.yml
··· 19 19 - "@types/*" 20 20 voidzero: 21 21 patterns: 22 + - "oxfmt" 22 23 - "oxlint" 23 24 - "rolldown" 24 25 - "rolldown-vite"
+14 -5
.github/workflows/main.yml
··· 37 37 - name: Build packages 38 38 run: npm run build 39 39 40 - lint: 41 - name: lint 40 + codequality: 41 + name: codequality (${{ matrix.tool }}) 42 42 runs-on: ubuntu-latest 43 + strategy: 44 + matrix: 45 + include: 46 + - tool: oxfmt 47 + tool-purpose: formatter 48 + npm-script: fmt-ci 49 + - tool: oxlint 50 + tool-purpose: linter 51 + npm-script: lint 43 52 steps: 44 53 - name: Checkout repository 45 54 uses: actions/checkout@v6 ··· 51 60 - name: Install dependencies 52 61 run: npm ci --verbose 53 62 - name: Print environment info 54 - run: npx oxlint --version 55 - - name: Lint 56 - run: npm run lint 63 + run: npx ${{ matrix.tool }} --version 64 + - name: Run ${{ matrix.tool-purpose }} checks 65 + run: npm run ${{ matrix.npm-script }} 57 66 58 67 test: 59 68 runs-on: ubuntu-latest
+7
.oxfmtrc.json
··· 1 + { 2 + "$schema": "./node_modules/oxfmt/configuration_schema.json", 3 + "useTabs": true, 4 + "semi": false, 5 + "singleQuote": true, 6 + "trailingComma": "all" 7 + }
+7 -4
README.md
··· 10 10 - [x] Uses the [VoidZero](https://voidzero.dev)-based JS toolchain 11 11 - [x] [Vite](https://vitejs.dev/) & [tsdown](https://tsdown.dev) for bundling & minifying source code 12 12 - [x] [Vitest](https://vitest.dev/) for unit testing & code coverage 13 - - [x] [Oxlint](https://oxc.rs/docs/guide/usage/linter.html) for linting code 13 + - [x] [Oxfmt](https://oxc.rs/docs/guide/usage/formatter.html) & [Oxlint](https://oxc.rs/docs/guide/usage/linter.html) for formatting & linting code 14 14 15 15 ## Getting started 16 16 ··· 58 58 | `npm run test-ui` | Run unit tests in UI/browser mode | 59 59 | `npm run test-html` | View test results in browser | 60 60 | `npm run test-json` | View test results in JSON format | 61 - | `npm run lint` | Check for Oxlint errors | 62 - | `npm run fix` | Fix Oxlint errors | 61 + | `npm run fmt` | Apply formatting fixes | 62 + | `npm run fmt-ci` | Check for formatting issues (used for CI) | 63 + | `npm run lint` | Check for Oxlint issues | 64 + | `npm run fix` | Apply Oxlint fixes | 63 65 64 66 ### Developer tools 65 67 | Tool | File | Documentation | ··· 67 69 | NPM | [`package.json`](package.json), [`packages/*/package.json`](./packages/pkg1/package.json) | [docs](https://docs.npmjs.com/cli/v10/configuring-npm/package-json), [website](https://docs.npmjs.com/) | 68 70 | TypeScript | [`tsconfig.json`](./tsconfig.json), [`packages/*/tsconfig.json`](packages/pkg1/tsconfig.json) | [docs](https://www.typescriptlang.org/tsconfig), [website](https://www.typescriptlang.org/) | 69 71 | TypeDoc | [`tsconfig.json`](tsconfig.json) (`typedocOptions`) | [docs](https://typedoc.org/options/configuration/), [website](https://typedoc.org/) | 70 - | Oxlint | [`.oxlintrc.json`](./.oxlintrc.json) | [docs](https://oxc.rs/docs/guide/usage/linter/config.html), [website](https://oxc.rs/docs/guide/usage/linter.html) | 72 + | Oxfmt | [`.oxfmtrc.json`](./.oxfmtrc.json) | [docs](https://oxc.rs/docs/guide/usage/formatter.html), [website](https://oxc.rs) | 73 + | Oxlint | [`.oxlintrc.json`](./.oxlintrc.json) | [docs](https://oxc.rs/docs/guide/usage/linter.html), [website](https://oxc.rs) | 71 74 | tsdown | [`packages/*/tsdown.config.ts`](packages/pkg1/tsdown.config.ts) | [docs](https://tsdown.dev/options/config-file), [website](https://tsdown.dev) | 72 75 | Vite | [`packages/*/vite.config.ts`](packages/pkg1/vite.config.ts) | [docs](https://vitejs.dev/config/), [website](https://vitejs.dev/) | 73 76 | Vitest | [`vitest.config.ts`](./vitest.config.ts), [`packages/*/vite.config.ts`](packages/pkg1/vite.config.ts) (`test`) | [docs](https://vitest.dev/config/), [website](https://vitest.dev/) |
+132
package-lock.json
··· 8 8 "workspaces": [ 9 9 "packages/**" 10 10 ], 11 + "dependencies": { 12 + "oxfmt": "^0.14.0" 13 + }, 11 14 "devDependencies": { 12 15 "@types/node": "^24.10.0", 13 16 "@vitest/coverage-v8": "^4.0.8", ··· 221 224 "funding": { 222 225 "url": "https://github.com/sponsors/Boshen" 223 226 } 227 + }, 228 + "node_modules/@oxfmt/darwin-arm64": { 229 + "version": "0.14.0", 230 + "resolved": "https://registry.npmjs.org/@oxfmt/darwin-arm64/-/darwin-arm64-0.14.0.tgz", 231 + "integrity": "sha512-g8FANFTuzEcB2KLsE2IcQYXjdgDi8x9GUf8c4t7iyFD7oj0HGucKHhoMz3XsRWTx8szBZoJJD+t4bzs4+AMFdQ==", 232 + "cpu": [ 233 + "arm64" 234 + ], 235 + "license": "MIT", 236 + "optional": true, 237 + "os": [ 238 + "darwin" 239 + ] 240 + }, 241 + "node_modules/@oxfmt/darwin-x64": { 242 + "version": "0.14.0", 243 + "resolved": "https://registry.npmjs.org/@oxfmt/darwin-x64/-/darwin-x64-0.14.0.tgz", 244 + "integrity": "sha512-Hd/DI+a8PKhl33CmaR3eQdx2P4zpaeoUwjOJQd090cFEbEX9auoCo6+t4LLm/JlzgnRSnFq0EaZOWJVK3wDu8Q==", 245 + "cpu": [ 246 + "x64" 247 + ], 248 + "license": "MIT", 249 + "optional": true, 250 + "os": [ 251 + "darwin" 252 + ] 253 + }, 254 + "node_modules/@oxfmt/linux-arm64-gnu": { 255 + "version": "0.14.0", 256 + "resolved": "https://registry.npmjs.org/@oxfmt/linux-arm64-gnu/-/linux-arm64-gnu-0.14.0.tgz", 257 + "integrity": "sha512-JzMyMKuDY9UmxRRnHWFdzYIXYZ2SK2/RmJKhYS47lcRELQC64nzuFe0d5JkRnt7KIJoM7RdUmYqEr+UKdiZ5mg==", 258 + "cpu": [ 259 + "arm64" 260 + ], 261 + "license": "MIT", 262 + "optional": true, 263 + "os": [ 264 + "linux" 265 + ] 266 + }, 267 + "node_modules/@oxfmt/linux-arm64-musl": { 268 + "version": "0.14.0", 269 + "resolved": "https://registry.npmjs.org/@oxfmt/linux-arm64-musl/-/linux-arm64-musl-0.14.0.tgz", 270 + "integrity": "sha512-sPLA+jvL5kArpnUpxlt6v/EZCGvIhe8Z6hnNuGUa4gdYfzVf2XhAK1jO6hrrjFMT+2cnkbqmxa5iuZqCT6Y5xg==", 271 + "cpu": [ 272 + "arm64" 273 + ], 274 + "license": "MIT", 275 + "optional": true, 276 + "os": [ 277 + "linux" 278 + ] 279 + }, 280 + "node_modules/@oxfmt/linux-x64-gnu": { 281 + "version": "0.14.0", 282 + "resolved": "https://registry.npmjs.org/@oxfmt/linux-x64-gnu/-/linux-x64-gnu-0.14.0.tgz", 283 + "integrity": "sha512-2hWVwIBa756NHs3+19om1mQp2C4vnGhFGe75AmsRRlkLq1vttC1iuQoF6slQQTS6n0/d7o4Pg1wGY3kldY6Msw==", 284 + "cpu": [ 285 + "x64" 286 + ], 287 + "license": "MIT", 288 + "optional": true, 289 + "os": [ 290 + "linux" 291 + ] 292 + }, 293 + "node_modules/@oxfmt/linux-x64-musl": { 294 + "version": "0.14.0", 295 + "resolved": "https://registry.npmjs.org/@oxfmt/linux-x64-musl/-/linux-x64-musl-0.14.0.tgz", 296 + "integrity": "sha512-bk98BFY2wArfWTVJ+T0zTCqF1deFfcyzrJ0/zppupQDFVdKUTga2XeKY8S1ImdyG+N7XcixdCrcT9db+SVNKMA==", 297 + "cpu": [ 298 + "x64" 299 + ], 300 + "license": "MIT", 301 + "optional": true, 302 + "os": [ 303 + "linux" 304 + ] 305 + }, 306 + "node_modules/@oxfmt/win32-arm64": { 307 + "version": "0.14.0", 308 + "resolved": "https://registry.npmjs.org/@oxfmt/win32-arm64/-/win32-arm64-0.14.0.tgz", 309 + "integrity": "sha512-UxctetV+XOXGXYcJp8uwP+/cUq3GSTAxq6UBbeGUq+0j1je3zC4XCQ6Kh/dm6kxOnAzrmMkX1uG4Su4bwvMq8w==", 310 + "cpu": [ 311 + "arm64" 312 + ], 313 + "license": "MIT", 314 + "optional": true, 315 + "os": [ 316 + "win32" 317 + ] 318 + }, 319 + "node_modules/@oxfmt/win32-x64": { 320 + "version": "0.14.0", 321 + "resolved": "https://registry.npmjs.org/@oxfmt/win32-x64/-/win32-x64-0.14.0.tgz", 322 + "integrity": "sha512-P/Cw1aP0UIf42HDH6t3+5IY0xx8e4HxCfDHQz/PDbJ+Vc2JhAB6rzkVFAOEo9inQsXoZVdApF/xklp4NJtrkqQ==", 323 + "cpu": [ 324 + "x64" 325 + ], 326 + "license": "MIT", 327 + "optional": true, 328 + "os": [ 329 + "win32" 330 + ] 224 331 }, 225 332 "node_modules/@oxlint/darwin-arm64": { 226 333 "version": "1.26.0", ··· 1685 1792 }, 1686 1793 "engines": { 1687 1794 "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" 1795 + } 1796 + }, 1797 + "node_modules/oxfmt": { 1798 + "version": "0.14.0", 1799 + "resolved": "https://registry.npmjs.org/oxfmt/-/oxfmt-0.14.0.tgz", 1800 + "integrity": "sha512-cZpXmiiEIHxEWq1bkqgCM/9vMv4TQ8RCSA9l+5PPEuCewL+2qNP/7vZynIrQnByvUnJc/G3YOj95XH+GXYLaKg==", 1801 + "license": "MIT", 1802 + "bin": { 1803 + "oxfmt": "bin/oxfmt" 1804 + }, 1805 + "engines": { 1806 + "node": "^20.19.0 || >=22.12.0" 1807 + }, 1808 + "funding": { 1809 + "url": "https://github.com/sponsors/Boshen" 1810 + }, 1811 + "optionalDependencies": { 1812 + "@oxfmt/darwin-arm64": "0.14.0", 1813 + "@oxfmt/darwin-x64": "0.14.0", 1814 + "@oxfmt/linux-arm64-gnu": "0.14.0", 1815 + "@oxfmt/linux-arm64-musl": "0.14.0", 1816 + "@oxfmt/linux-x64-gnu": "0.14.0", 1817 + "@oxfmt/linux-x64-musl": "0.14.0", 1818 + "@oxfmt/win32-arm64": "0.14.0", 1819 + "@oxfmt/win32-x64": "0.14.0" 1688 1820 } 1689 1821 }, 1690 1822 "node_modules/oxlint": {
+5
package.json
··· 15 15 "test-ui": "vitest --ui --coverage", 16 16 "test-html": "vitest run --reporter=html --coverage.clean; vite preview --outDir ./dist/vitest/report", 17 17 "test-json": "vitest run --reporter=json --coverage.clean", 18 + "fmt": "oxfmt", 19 + "fmt-ci": "oxfmt --check", 18 20 "lint": "oxlint", 19 21 "fix": "oxlint --fix" 20 22 }, ··· 29 31 "typescript": "^5.9.3", 30 32 "vite": "npm:rolldown-vite@^7.1.17", 31 33 "vitest": "^4.0.8" 34 + }, 35 + "dependencies": { 36 + "oxfmt": "^0.14.0" 32 37 } 33 38 }
+5 -1
packages/pkg1/package.json
··· 34 34 "scripts": { 35 35 "build": "tsdown", 36 36 "dev": "tsdown --watch", 37 - "test": "vitest" 37 + "test": "vitest", 38 + "fmt": "oxfmt --config=./../../.oxfmtrc.json", 39 + "fmt-check": "npm run fmt -- --check", 40 + "lint": "oxlint --config=./../../.oxlintrc.json", 41 + "fix": "npm run lint -- --fix" 38 42 } 39 43 }
+1 -1
vitest.config.ts
··· 12 12 html: 'dist/vitest/report/index.html', 13 13 json: 'dist/vitest/report/index.json', 14 14 clover: 'dist/vitest/report/index.xml', 15 - } 15 + }, 16 16 }, 17 17 })