diff --git a/.oxfmtrc.json b/.oxfmtrc.json new file mode 100644 index 00000000000..b98dbf65689 --- /dev/null +++ b/.oxfmtrc.json @@ -0,0 +1,24 @@ +{ + "$schema": "./node_modules/oxfmt/configuration_schema.json", + "printWidth": 80, + "semi": false, + "singleQuote": true, + "trailingComma": "all", + "sortPackageJson": false, + "ignorePatterns": [ + "**/worker-configuration.d.ts", + "**/prisma/migrations/migration_lock.toml", + "examples/solid/start-basic-netlify/netlify.toml" + ], + "overrides": [ + { + "files": ["examples/react/start-workos/**/*.{js,jsx,ts,tsx,d.ts}"], + "options": { + "printWidth": 120, + "semi": true, + "singleQuote": true, + "trailingComma": "all" + } + } + ] +} diff --git a/e2e/react-router/view-transitions/src/main.tsx b/e2e/react-router/view-transitions/src/main.tsx index 065d69a2cf8..bc3f972d07b 100644 --- a/e2e/react-router/view-transitions/src/main.tsx +++ b/e2e/react-router/view-transitions/src/main.tsx @@ -10,7 +10,7 @@ const router = createRouter({ defaultPreload: 'intent', defaultStaleTime: 5000, scrollRestoration: true, - /* + /* Using defaultViewTransition would prevent the need to manually add `viewTransition: true` to every navigation. diff --git a/e2e/solid-router/view-transitions/src/main.tsx b/e2e/solid-router/view-transitions/src/main.tsx index 740315c011e..3e25ce8e475 100644 --- a/e2e/solid-router/view-transitions/src/main.tsx +++ b/e2e/solid-router/view-transitions/src/main.tsx @@ -9,7 +9,7 @@ const router = createRouter({ defaultPreload: 'intent', defaultStaleTime: 5000, scrollRestoration: true, - /* + /* Using defaultViewTransition would prevent the need to manually add `viewTransition: true` to every navigation. diff --git a/examples/react/kitchen-sink-file-based/src/routes/__root.tsx b/examples/react/kitchen-sink-file-based/src/routes/__root.tsx index 421fb8a683e..7a18dee9954 100644 --- a/examples/react/kitchen-sink-file-based/src/routes/__root.tsx +++ b/examples/react/kitchen-sink-file-based/src/routes/__root.tsx @@ -51,13 +51,11 @@ function RootComponent() {
{ ) }) -/* disabled until HMR bug is fixed +/* disabled until HMR bug is fixed describe('throws invariant exception when trying to access properties before `createRouter` completed', () => { function setup() { const rootRoute = createRootRoute() diff --git a/packages/router-core/src/new-process-route-tree.ts b/packages/router-core/src/new-process-route-tree.ts index ba6244a4d97..d5624dd1207 100644 --- a/packages/router-core/src/new-process-route-tree.ts +++ b/packages/router-core/src/new-process-route-tree.ts @@ -648,7 +648,8 @@ type RouteLike = { } } & // router tree - (| { fullPath: string; from?: never } // full path from the root + ( + | { fullPath: string; from?: never } // full path from the root // flat route masks list | { fullPath?: never; from: string } // full path from the root ) diff --git a/packages/router-core/src/route.ts b/packages/router-core/src/route.ts index 1c8d4a20a5c..5f5028445c2 100644 --- a/packages/router-core/src/route.ts +++ b/packages/router-core/src/route.ts @@ -187,12 +187,12 @@ export type ParamsOptions = { stringify?: StringifyParamsFn } - /** + /** @deprecated Use params.parse instead */ parseParams?: ParseParamsFn - /** + /** @deprecated Use params.stringify instead */ stringifyParams?: StringifyParamsFn @@ -1267,13 +1267,13 @@ export interface UpdatableRouteOptions< > > } - /** + /** @deprecated Use search.middlewares instead */ preSearchFilters?: Array< SearchFilter> > - /** + /** @deprecated Use search.middlewares instead */ postSearchFilters?: Array< diff --git a/packages/router-core/tests/utils.test.ts b/packages/router-core/tests/utils.test.ts index 95874f230e3..70ae98cc737 100644 --- a/packages/router-core/tests/utils.test.ts +++ b/packages/router-core/tests/utils.test.ts @@ -456,40 +456,31 @@ describe('deepEqual', () => { // This might not be what we want, but this test documents how things are now describe('symbol and non-enumerable properties are not handled', () => { - it.fails( - 'should return `false` for unequal objects with symbol properties', - () => { - const key = Symbol('foo') - const a = { [key]: 1 } - const b = { [key]: 2 } - expect(deepEqual(a, b)).toEqual(false) - }, - ) + it.fails('should return `false` for unequal objects with symbol properties', () => { + const key = Symbol('foo') + const a = { [key]: 1 } + const b = { [key]: 2 } + expect(deepEqual(a, b)).toEqual(false) + }) - it.fails( - 'should return `false` for unequal objects with non-enumerable properties', - () => { - const a = {} - Object.defineProperty(a, 'prop', { value: 1, enumerable: false }) - const b = {} - Object.defineProperty(b, 'prop', { value: 2, enumerable: false }) - expect(deepEqual(a, b)).toEqual(false) - }, - ) + it.fails('should return `false` for unequal objects with non-enumerable properties', () => { + const a = {} + Object.defineProperty(a, 'prop', { value: 1, enumerable: false }) + const b = {} + Object.defineProperty(b, 'prop', { value: 2, enumerable: false }) + expect(deepEqual(a, b)).toEqual(false) + }) }) // We voluntarily fail in this case, because users should not do it, and ignoring it enables some performance improvements describe('augmented object prototype fail case (no one should do this anyway)', () => { - it.fails( - 'should not compare objects with augmented prototype properties', - () => { - // @ts-expect-error -- typescript is right to complain here, don't do this! - Object.prototype.x = 'x' - const a = { a: 1 } - const b = { a: 1 } - expect(deepEqual(a, b, { ignoreUndefined: false })).toEqual(true) - }, - ) + it.fails('should not compare objects with augmented prototype properties', () => { + // @ts-expect-error -- typescript is right to complain here, don't do this! + Object.prototype.x = 'x' + const a = { a: 1 } + const b = { a: 1 } + expect(deepEqual(a, b, { ignoreUndefined: false })).toEqual(true) + }) afterEach(() => { // it's probably not necessary to clean this up because vitest isolates tests diff --git a/packages/router-devtools-core/src/useStyles.tsx b/packages/router-devtools-core/src/useStyles.tsx index 5524ed0ae8f..a29c0b7265c 100644 --- a/packages/router-devtools-core/src/useStyles.tsx +++ b/packages/router-devtools-core/src/useStyles.tsx @@ -496,12 +496,16 @@ const stylesFactory = (shadowDOMTarget?: ShadowRoot) => { const base = css` ${position === 'top-left' ? `top: ${size[2]}; left: ${size[2]};` : ''} ${position === 'top-right' ? `top: ${size[2]}; right: ${size[2]};` : ''} - ${position === 'bottom-left' - ? `bottom: ${size[2]}; left: ${size[2]};` - : ''} - ${position === 'bottom-right' - ? `bottom: ${size[2]}; right: ${size[2]};` - : ''} + ${ + position === 'bottom-left' + ? `bottom: ${size[2]}; left: ${size[2]};` + : '' + } + ${ + position === 'bottom-right' + ? `bottom: ${size[2]}; right: ${size[2]};` + : '' + } ` return base }, diff --git a/packages/solid-router/src/fileRoute.ts b/packages/solid-router/src/fileRoute.ts index 83f8466cf2d..86d27f35796 100644 --- a/packages/solid-router/src/fileRoute.ts +++ b/packages/solid-router/src/fileRoute.ts @@ -55,7 +55,7 @@ export function createFileRoute< }).createRoute } -/** +/** @deprecated It's no longer recommended to use the `FileRoute` class directly. Instead, use `createFileRoute('/path/to/file')(options)` to create a file route. */ @@ -150,7 +150,7 @@ export class FileRoute< } } -/** +/** @deprecated It's recommended not to split loaders into separate files. Instead, place the loader function in the the main route file, inside the `createFileRoute('/path/to/file)(options)` options. diff --git a/packages/solid-router/tests/route.test.tsx b/packages/solid-router/tests/route.test.tsx index 12d86430c92..3b02c3b5045 100644 --- a/packages/solid-router/tests/route.test.tsx +++ b/packages/solid-router/tests/route.test.tsx @@ -76,7 +76,7 @@ describe('createRoute has the same hooks as getRouteApi', () => { ) }) -/* disabled until HMR bug is fixed +/* disabled until HMR bug is fixed describe('throws invariant exception when trying to access properties before `createRouter` completed', () => { function setup() { const rootRoute = createRootRoute() diff --git a/packages/vue-router/tests/route.test.tsx b/packages/vue-router/tests/route.test.tsx index 70930e7ad40..66ed80368ca 100644 --- a/packages/vue-router/tests/route.test.tsx +++ b/packages/vue-router/tests/route.test.tsx @@ -76,7 +76,7 @@ describe('createRoute has the same hooks as getRouteApi', () => { ) }) -/* disabled until HMR bug is fixed +/* disabled until HMR bug is fixed describe('throws invariant exception when trying to access properties before `createRouter` completed', () => { function setup() { const rootRoute = createRootRoute() diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 90b1eb10370..c57f637d9de 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -112,9 +112,9 @@ importers: nx: specifier: 22.5.1 version: 22.5.1 - prettier: - specifier: ^3.8.0 - version: 3.8.0 + oxfmt: + specifier: ^0.35.0 + version: 0.35.0 publint: specifier: ^0.3.16 version: 0.3.16 @@ -11988,7 +11988,7 @@ importers: version: link:../virtual-file-routes prettier: specifier: ^3.5.0 - version: 3.5.0 + version: 3.6.2 recast: specifier: ^0.23.11 version: 0.23.11 @@ -15676,6 +15676,120 @@ packages: cpu: [x64] os: [win32] + '@oxfmt/binding-android-arm-eabi@0.35.0': + resolution: {integrity: sha512-BaRKlM3DyG81y/xWTsE6gZiv89F/3pHe2BqX2H4JbiB8HNVlWWtplzgATAE5IDSdwChdeuWLDTQzJ92Lglw3ZA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + + '@oxfmt/binding-android-arm64@0.35.0': + resolution: {integrity: sha512-/O+EbuAJYs6nde/anv+aID6uHsGQApyE9JtYBo/79KyU8e6RBN3DMbT0ix97y1SOnCglurmL2iZ+hlohjP2PnQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@oxfmt/binding-darwin-arm64@0.35.0': + resolution: {integrity: sha512-pGqRtqlNdn9d4VrmGUWVyQjkw79ryhI6je9y2jfqNUIZCfqceob+R97YYAoG7C5TFyt8ILdLVoN+L2vw/hSFyA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@oxfmt/binding-darwin-x64@0.35.0': + resolution: {integrity: sha512-8GmsDcSozTPjrCJeGpp+sCmS9+9V5yRrdEZ1p/sTWxPG5nYeAfSLuS0nuEYjXSO+CtdSbStIW6dxa+4NM58yRw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@oxfmt/binding-freebsd-x64@0.35.0': + resolution: {integrity: sha512-QyfKfTe0ytHpFKHAcHCGQEzN45QSqq1AHJOYYxQMgLM3KY4xu8OsXHpCnINjDsV4XGnQzczJDU9e04Zmd8XqIQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@oxfmt/binding-linux-arm-gnueabihf@0.35.0': + resolution: {integrity: sha512-u+kv3JD6P3J38oOyUaiCqgY5TNESzBRZJ5lyZQ6c2czUW2v5SIN9E/KWWa9vxoc+P8AFXQFUVrdzGy1tK+nbPQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxfmt/binding-linux-arm-musleabihf@0.35.0': + resolution: {integrity: sha512-1NiZroCiV57I7Pf8kOH4XGR366kW5zir3VfSMBU2D0V14GpYjiYmPYFAoJboZvp8ACnZKUReWyMkNKSa5ad58A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@oxfmt/binding-linux-arm64-gnu@0.35.0': + resolution: {integrity: sha512-7Q0Xeg7ZnW2nxnZ4R7aF6DEbCFls4skgHZg+I63XitpNvJCbVIU8MFOTZlvZGRsY9+rPgWPQGeUpLHlyx0wvMA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + + '@oxfmt/binding-linux-arm64-musl@0.35.0': + resolution: {integrity: sha512-5Okqi+uhYFxwKz8hcnUftNNwdm8BCkf6GSCbcz9xJxYMm87k1E4p7PEmAAbhLTk7cjSdDre6TDL0pDzNX+Y22Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + + '@oxfmt/binding-linux-ppc64-gnu@0.35.0': + resolution: {integrity: sha512-9k66pbZQXM/lBJWys3Xbc5yhl4JexyfqkEf/tvtq8976VIJnLAAL3M127xHA3ifYSqxdVHfVGTg84eiBHCGcNw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + + '@oxfmt/binding-linux-riscv64-gnu@0.35.0': + resolution: {integrity: sha512-aUcY9ofKPtjO52idT6t0SAQvEF6ctjzUQa1lLp7GDsRpSBvuTrBQGeq0rYKz3gN8dMIQ7mtMdGD9tT4LhR8jAQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + + '@oxfmt/binding-linux-riscv64-musl@0.35.0': + resolution: {integrity: sha512-C6yhY5Hvc2sGM+mCPek9ZLe5xRUOC/BvhAt2qIWFAeXMn4il04EYIjl3DsWiJr0xDMTJhvMOmD55xTRPlNp39w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [riscv64] + os: [linux] + + '@oxfmt/binding-linux-s390x-gnu@0.35.0': + resolution: {integrity: sha512-RG2hlvOMK4OMZpO3mt8MpxLQ0AAezlFqhn5mI/g5YrVbPFyoCv9a34AAvbSJS501ocOxlFIRcKEuw5hFvddf9g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + + '@oxfmt/binding-linux-x64-gnu@0.35.0': + resolution: {integrity: sha512-wzmh90Pwvqj9xOKHJjkQYBpydRkaXG77ZvDz+iFDRRQpnqIEqGm5gmim2s6vnZIkDGsvKCuTdtxm0GFmBjM1+w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + + '@oxfmt/binding-linux-x64-musl@0.35.0': + resolution: {integrity: sha512-+HCqYCJPCUy5I+b2cf+gUVaApfgtoQT3HdnSg/l7NIcLHOhKstlYaGyrFZLmUpQt4WkFbpGKZZayG6zjRU0KFA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + + '@oxfmt/binding-openharmony-arm64@0.35.0': + resolution: {integrity: sha512-kFYmWfR9YL78XyO5ws+1dsxNvZoD973qfVMNFOS4e9bcHXGF7DvGC2tY5UDFwyMCeB33t3sDIuGONKggnVNSJA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@oxfmt/binding-win32-arm64-msvc@0.35.0': + resolution: {integrity: sha512-uD/NGdM65eKNCDGyTGdO8e9n3IHX+wwuorBvEYrPJXhDXL9qz6gzddmXH8EN04ejUXUujlq4FsoSeCfbg0Y+Jg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@oxfmt/binding-win32-ia32-msvc@0.35.0': + resolution: {integrity: sha512-oSRD2k8J2uxYDEKR2nAE/YTY9PobOEnhZgCmspHu0+yBQ665yH8lFErQVSTE7fcGJmJp/cC6322/gc8VFuQf7g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ia32] + os: [win32] + + '@oxfmt/binding-win32-x64-msvc@0.35.0': + resolution: {integrity: sha512-WCDJjlS95NboR0ugI2BEwzt1tYvRDorDRM9Lvctls1SLyKYuNRCyrPwp1urUPFBnwgBNn9p2/gnmo7gFMySRoQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + '@panva/hkdf@1.2.1': resolution: {integrity: sha512-6oclG6Y3PiDFcoyk8srjLfVKyMfVCKJ27JwNPViuXziFpmdz+MZnZN/aKY0JGXgYuO/VghU0jcOAZgWXZ1Dmrw==} @@ -22372,6 +22486,11 @@ packages: resolution: {integrity: sha512-/fymQNzzUoKZweH0nC5yvbI2eR0yWYusT9TEKDYVgOgYrf9Qmdez9lUFyvxKR9ycx+PTHi/reIOzqf3wkShQsw==} engines: {node: ^20.19.0 || >=22.12.0} + oxfmt@0.35.0: + resolution: {integrity: sha512-QYeXWkP+aLt7utt5SLivNIk09glWx9QE235ODjgcEZ3sd1VMaUBSpLymh6ZRCA76gD2rMP4bXanUz/fx+nLM9Q==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + p-event@6.0.1: resolution: {integrity: sha512-Q6Bekk5wpzW5qIyUP4gdMEujObYstZl6DMMOSenwBvV0BlE5LkDwkjs5yHbZmdCEq2o4RJx4tE1vwxFVf2FG1w==} engines: {node: '>=16.17'} @@ -22695,21 +22814,11 @@ packages: engines: {node: '>=14'} hasBin: true - prettier@3.5.0: - resolution: {integrity: sha512-quyMrVt6svPS7CjQ9gKb3GLEX/rl3BCL2oa/QkNcXv4YNVBC9olt3s+H7ukto06q7B1Qz46PbrKLO34PR6vXcA==} - engines: {node: '>=14'} - hasBin: true - prettier@3.6.2: resolution: {integrity: sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==} engines: {node: '>=14'} hasBin: true - prettier@3.8.0: - resolution: {integrity: sha512-yEPsovQfpxYfgWNhCfECjG5AQaO+K3dp6XERmOepyPDVqcJm+bjyCVO3pmU+nAPe0N5dDvekfGezt/EIiRe1TA==} - engines: {node: '>=14'} - hasBin: true - pretty-bytes@5.6.0: resolution: {integrity: sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==} engines: {node: '>=6'} @@ -23947,6 +24056,10 @@ packages: resolution: {integrity: sha512-Zba82s87IFq9A9XmjiX5uZA/ARWDrB03OHlq+Vw1fSdt0I+4/Kutwy8BP4Y/y/aORMo61FQ0vIb5j44vSo5Pkg==} engines: {node: ^18.0.0 || >=20.0.0} + tinypool@2.1.0: + resolution: {integrity: sha512-Pugqs6M0m7Lv1I7FtxN4aoyToKg1C4tu+/381vH35y8oENM/Ai7f7C4StcoK4/+BSw9ebcS8jRiVrORFKCALLw==} + engines: {node: ^20.0.0 || >=22.0.0} + tinyrainbow@2.0.0: resolution: {integrity: sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==} engines: {node: '>=14.0.0'} @@ -28036,6 +28149,63 @@ snapshots: '@oxc-transform/binding-win32-x64-msvc@0.110.0': optional: true + '@oxfmt/binding-android-arm-eabi@0.35.0': + optional: true + + '@oxfmt/binding-android-arm64@0.35.0': + optional: true + + '@oxfmt/binding-darwin-arm64@0.35.0': + optional: true + + '@oxfmt/binding-darwin-x64@0.35.0': + optional: true + + '@oxfmt/binding-freebsd-x64@0.35.0': + optional: true + + '@oxfmt/binding-linux-arm-gnueabihf@0.35.0': + optional: true + + '@oxfmt/binding-linux-arm-musleabihf@0.35.0': + optional: true + + '@oxfmt/binding-linux-arm64-gnu@0.35.0': + optional: true + + '@oxfmt/binding-linux-arm64-musl@0.35.0': + optional: true + + '@oxfmt/binding-linux-ppc64-gnu@0.35.0': + optional: true + + '@oxfmt/binding-linux-riscv64-gnu@0.35.0': + optional: true + + '@oxfmt/binding-linux-riscv64-musl@0.35.0': + optional: true + + '@oxfmt/binding-linux-s390x-gnu@0.35.0': + optional: true + + '@oxfmt/binding-linux-x64-gnu@0.35.0': + optional: true + + '@oxfmt/binding-linux-x64-musl@0.35.0': + optional: true + + '@oxfmt/binding-openharmony-arm64@0.35.0': + optional: true + + '@oxfmt/binding-win32-arm64-msvc@0.35.0': + optional: true + + '@oxfmt/binding-win32-ia32-msvc@0.35.0': + optional: true + + '@oxfmt/binding-win32-x64-msvc@0.35.0': + optional: true + '@panva/hkdf@1.2.1': {} '@parcel/watcher-android-arm64@2.5.1': @@ -36087,6 +36257,30 @@ snapshots: '@oxc-transform/binding-win32-ia32-msvc': 0.110.0 '@oxc-transform/binding-win32-x64-msvc': 0.110.0 + oxfmt@0.35.0: + dependencies: + tinypool: 2.1.0 + optionalDependencies: + '@oxfmt/binding-android-arm-eabi': 0.35.0 + '@oxfmt/binding-android-arm64': 0.35.0 + '@oxfmt/binding-darwin-arm64': 0.35.0 + '@oxfmt/binding-darwin-x64': 0.35.0 + '@oxfmt/binding-freebsd-x64': 0.35.0 + '@oxfmt/binding-linux-arm-gnueabihf': 0.35.0 + '@oxfmt/binding-linux-arm-musleabihf': 0.35.0 + '@oxfmt/binding-linux-arm64-gnu': 0.35.0 + '@oxfmt/binding-linux-arm64-musl': 0.35.0 + '@oxfmt/binding-linux-ppc64-gnu': 0.35.0 + '@oxfmt/binding-linux-riscv64-gnu': 0.35.0 + '@oxfmt/binding-linux-riscv64-musl': 0.35.0 + '@oxfmt/binding-linux-s390x-gnu': 0.35.0 + '@oxfmt/binding-linux-x64-gnu': 0.35.0 + '@oxfmt/binding-linux-x64-musl': 0.35.0 + '@oxfmt/binding-openharmony-arm64': 0.35.0 + '@oxfmt/binding-win32-arm64-msvc': 0.35.0 + '@oxfmt/binding-win32-ia32-msvc': 0.35.0 + '@oxfmt/binding-win32-x64-msvc': 0.35.0 + p-event@6.0.1: dependencies: p-timeout: 6.1.4 @@ -36400,12 +36594,8 @@ snapshots: prettier@3.4.2: {} - prettier@3.5.0: {} - prettier@3.6.2: {} - prettier@3.8.0: {} - pretty-bytes@5.6.0: {} pretty-bytes@7.1.0: {} @@ -37826,6 +38016,8 @@ snapshots: tinypool@1.1.1: {} + tinypool@2.1.0: {} + tinyrainbow@2.0.0: {} tinyrainbow@3.0.3: {} diff --git a/prettier.config.js b/prettier.config.js deleted file mode 100644 index 2c53b10e3bc..00000000000 --- a/prettier.config.js +++ /dev/null @@ -1,10 +0,0 @@ -// @ts-check - -/** @type {import('prettier').Config} */ -const config = { - semi: false, - singleQuote: true, - trailingComma: 'all', -} - -export default config diff --git a/scripts/generate-labeler-config.ts b/scripts/generate-labeler-config.ts index 77f4842d1bd..2c88a594c94 100644 --- a/scripts/generate-labeler-config.ts +++ b/scripts/generate-labeler-config.ts @@ -1,10 +1,27 @@ import * as fs from 'node:fs' import * as path from 'node:path' -import * as prettier from 'prettier' +import { format as formatWithOxfmt } from 'oxfmt' +import type { FormatOptions } from 'oxfmt' /** Pairs of package labels and their corresponding paths */ type LabelerPair = [string, string] +const oxfmtConfigPath = path.resolve('.oxfmtrc.json') + +function readOxfmtConfig(): FormatOptions { + if (!fs.existsSync(oxfmtConfigPath)) { + throw new Error(`No Oxfmt config file found at \`${oxfmtConfigPath}\`.`) + } + + const rawConfig = fs.readFileSync(oxfmtConfigPath, 'utf-8') + const parsedConfig = JSON.parse(rawConfig) as { + $schema?: string + } & FormatOptions + const { $schema: _schema, ...formatOptions } = parsedConfig + + return formatOptions +} + function readPairsFromFs(): Array { const ignored = new Set(['.DS_Store']) @@ -52,26 +69,24 @@ async function generateLabelerYaml(pairs: Array): Promise { }) .join('\n') - // Get the location of the Prettier config file - const prettierConfigPath = await prettier.resolveConfigFile() - if (!prettierConfigPath) { + const oxfmtConfig = readOxfmtConfig() + + // Format the YAML string using Oxfmt + const formatResult = await formatWithOxfmt( + 'labeler-config.yml', + formattedPairs, + oxfmtConfig, + ) + + if (formatResult.errors.length > 0) { throw new Error( - 'No Prettier config file found. Please ensure you have a Prettier config file in your project.', + `Failed to format labeler config: ${formatResult.errors + .map((error) => error.message) + .join(', ')}`, ) } - console.info('using prettier config file at:', prettierConfigPath) - - // Resolve the Prettier config - const prettierConfig = await prettier.resolveConfig(prettierConfigPath) - console.info('using resolved prettier config:', prettierConfig) - - // Format the YAML string using Prettier - const formattedStr = await prettier.format(formattedPairs, { - parser: 'yaml', - ...prettierConfig, - }) - return formattedStr + return formatResult.code } async function run() {